-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: extract custom embedding provider
- Loading branch information
1 parent
3a594fd
commit 2ca0b66
Showing
3 changed files
with
29 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
title: Writing a Custom Embeddings Provider | ||
sidebar_label: Custom Embeddings Provider | ||
description: Learn how to create a custom EmbeddingsProvider in Continue to use your own API for generating embeddings | ||
--- | ||
|
||
If you have your own API capable of generating embeddings, Continue makes it easy to write a custom `EmbeddingsProvider`. All you have to do is write a function that converts strings to arrays of numbers, and add this to your config in `config.ts`. Here's an example: | ||
|
||
```ts title="~/.continue/config.ts" | ||
export function modifyConfig(config: Config): Config { | ||
config.embeddingsProvider = { | ||
embed: (chunks: string[]) => { | ||
return Promise.all( | ||
chunks.map(async (chunk) => { | ||
const response = await fetch("https://example.com/embeddings", { | ||
method: "POST", | ||
body: JSON.stringify({ text: chunk }), | ||
}); | ||
const data = await response.json(); | ||
return data.embedding; | ||
}), | ||
); | ||
}, | ||
}; | ||
|
||
return config; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters