diff --git a/lib/embeddings.ts b/lib/embeddings.ts index fa28a82..866c465 100644 --- a/lib/embeddings.ts +++ b/lib/embeddings.ts @@ -92,7 +92,9 @@ async function searchEmbeddings( id: string, input: string, clientOptions: InputClientOptions = {}, -): Promise<{ id: string; content: string; similarity: number }[]> { +): Promise< + { id: string; content: string; similarity: number; metadatas: Record }[] +> { const { token, endpoint } = await defaultOptions(clientOptions); try { @@ -166,7 +168,11 @@ class Embeddings { return this.memoryId; } - async search(input: string): Promise<{ id: string; content: string; similarity: number }[]> { + async search( + input: string, + ): Promise< + { id: string; content: string; similarity: number; metadatas: Record }[] + > { const id = await this.memoryId; return searchEmbeddings(id, input, await this.clientOptions); } diff --git a/lib/generate.ts b/lib/generate.ts index ab23592..18979ee 100644 --- a/lib/generate.ts +++ b/lib/generate.ts @@ -110,6 +110,7 @@ export type Ressource = { similarity: number; id: string; content: string; + metadatas?: Record; }; export type GenerationResult = { diff --git a/package.json b/package.json index e24ad0f..4ce24c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polyfire-js", - "version": "0.2.59", + "version": "0.2.60", "main": "index.js", "types": "index.d.ts", "author": "Lancelot Owczarczak ", diff --git a/tests/generation.test.js b/tests/generation.test.js index cfa5152..2590d89 100644 --- a/tests/generation.test.js +++ b/tests/generation.test.js @@ -86,12 +86,13 @@ test( const embeddings = Embeddings(); - embeddings.add('The word you have to remember is "banana42"'); + await embeddings.add('The word you have to remember is "banana42"'); const message = await generate("Just answer with the word you have to remember", { temperature: 0, cache: false, embeddings, + model: "gpt-3.5-turbo", }); expect(message).toBe("banana42");