From f60a39e944122f19337a19759bacebc3639ef69a Mon Sep 17 00:00:00 2001 From: Hieu Pham Date: Sat, 21 Dec 2024 12:24:15 -0800 Subject: [PATCH 1/2] Fix embedding provider not respecting batch size --- core/llm/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/llm/index.ts b/core/llm/index.ts index fbea69104..d789f724e 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -809,12 +809,12 @@ export abstract class BaseLLM implements ILLM { if (this.shouldUseOpenAIAdapter("embed") && this.openaiAdapter) { const result = await this.openaiAdapter.embed({ model: this.model, - input: chunks, + input: batch, }); - return result.data.map((chunk) => chunk.embedding); + return result.data.map((batch) => batch.embedding); } - return await this._embed(chunks); + return await this._embed(batch); }, ); From 4fdf5d5bc358f91f8a6569beb685bca368719603 Mon Sep 17 00:00:00 2001 From: Hieu Pham Date: Sat, 21 Dec 2024 12:58:35 -0800 Subject: [PATCH 2/2] Remove unnecessary change --- core/llm/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/llm/index.ts b/core/llm/index.ts index d789f724e..5c0253e86 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -811,7 +811,7 @@ export abstract class BaseLLM implements ILLM { model: this.model, input: batch, }); - return result.data.map((batch) => batch.embedding); + return result.data.map((chunk) => chunk.embedding); } return await this._embed(batch);