Skip to content

Commit

Permalink
docs: extract custom embedding provider
Browse files Browse the repository at this point in the history
  • Loading branch information
priyashpatil committed Aug 18, 2024
1 parent 3a594fd commit 2ca0b66
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
28 changes: 28 additions & 0 deletions docs/docs/advanced/custom-embedding-provider.md
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;
}
```
27 changes: 0 additions & 27 deletions docs/docs/features/codebase-embeddings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
1 change: 1 addition & 0 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 2ca0b66

Please sign in to comment.