✨ deepinfra context provider
This commit is contained in:
parent
4b1d5ae8af
commit
7fea55cb26
1 changed files with 30 additions and 0 deletions
30
core/indexing/embeddings/DeepInfraEmbeddingsProvider.ts
Normal file
30
core/indexing/embeddings/DeepInfraEmbeddingsProvider.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { EmbedOptions } from "../..";
|
||||
import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider";
|
||||
|
||||
class DeepInfraEmbeddingsProvider extends BaseEmbeddingsProvider {
|
||||
static defaultOptions: Partial<EmbedOptions> | undefined = {
|
||||
model: "sentence-transformers/all-MiniLM-L6-v2",
|
||||
};
|
||||
|
||||
get id(): string {
|
||||
return "deepinfra::" + this.options.model;
|
||||
}
|
||||
|
||||
async embed(chunks: string[]) {
|
||||
const resp = await fetch(
|
||||
`https://api.deepinfra.com/v1/inference/${this.options.model}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `bearer ${this.options.apiKey}`,
|
||||
},
|
||||
body: JSON.stringify({ inputs: chunks }),
|
||||
},
|
||||
);
|
||||
const data = await resp.json();
|
||||
console.log(data);
|
||||
return data.embeddings;
|
||||
}
|
||||
}
|
||||
|
||||
export default DeepInfraEmbeddingsProvider;
|
||||
Loading…
Add table
Reference in a new issue