diff --git a/docs/docs/advanced/custom-embedding-provider.md b/docs/docs/advanced/custom-embedding-provider.md new file mode 100644 index 0000000000..da85d2a7bd --- /dev/null +++ b/docs/docs/advanced/custom-embedding-provider.md @@ -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; +} +``` diff --git a/docs/docs/features/codebase-embeddings.md b/docs/docs/features/codebase-embeddings.md index 6ad8746c1a..e6206c3d46 100644 --- a/docs/docs/features/codebase-embeddings.md +++ b/docs/docs/features/codebase-embeddings.md @@ -64,33 +64,6 @@ Final number of results to use after re-ranking (default: 5) Whether to use re-ranking, which will allow initial selection of `nRetrieve` results, then will use an LLM to select the top `nFinal` results (default: true) - - -### Writing a custom `EmbeddingsProvider` - -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; -} -``` - ## Ignore files during indexing Continue respects `.gitignore` files in order to determine which files should not be indexed. If you'd like to exclude additional files, you can add them to a `.continueignore` file, which follows the exact same rules as `.gitignore`. diff --git a/docs/sidebars.js b/docs/sidebars.js index 531fb4dc8a..78c9fdf0e0 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -68,6 +68,7 @@ const sidebars = { items: [ "advanced/custom-llm-provider", "advanced/custom-context-provider", + "advanced/custom-embedding-provider", "advanced/custom-slash-command", "advanced/customizing-the-chat-template", "advanced/customizing-edit-commands-prompt"