The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
fix(ts): request float OpenAI embeddings (#5170)
Pragnyan Ramtha64b9646e7dd2
diff --git a/mem0-ts/src/oss/src/embeddings/openai.ts b/mem0-ts/src/oss/src/embeddings/openai.tsindex 18f7df344..dd389886f 100644--- a/mem0-ts/src/oss/src/embeddings/openai.ts+++ b/mem0-ts/src/oss/src/embeddings/openai.ts@@ -20,6 +20,7 @@ export class OpenAIEmbedder implements Embedder {const response = await this.openai.embeddings.create({model: this.model,input: text,+ encoding_format: "float",...(this.embeddingDims !== undefined && {dimensions: this.embeddingDims,}),@@ -35,6 +36,7 @@ export class OpenAIEmbedder implements Embedder {const response = await this.openai.embeddings.create({model: this.model,input: chunk,+ encoding_format: "float",...(this.embeddingDims !== undefined && {dimensions: this.embeddingDims,}),diff --git a/mem0-ts/src/oss/tests/openai-embedder.test.ts b/mem0-ts/src/oss/tests/openai-embedder.test.tsindex 1dc7ba2a1..e5733e4ea 100644--- a/mem0-ts/src/oss/tests/openai-embedder.test.ts+++ b/mem0-ts/src/oss/tests/openai-embedder.test.ts@@ -2,7 +2,8 @@/*** OpenAI Embedder — unit tests (mocked OpenAI client).* Verifies that the `dimensions` parameter is only passed to the API- * when the user explicitly configures `embeddingDims`.+ * when the user explicitly configures `embeddingDims`, and that+ * embeddings are requested as floats for OpenAI-compatible proxies.*/const mockEmbeddingsCreate = jest.fn();@@ -42,6 +43,7 @@ describe("OpenAIEmbedder (unit)", () => {expect(callArgs).toEqual({model: "text-embedding-3-small",input: "hello",+ encoding_format: "float",});});@@ -58,6 +60,7 @@ describe("OpenAIEmbedder (unit)", () => {expect(callArgs).toEqual({model: "text-embedding-3-small",input: "hello",+ encoding_format: "float",dimensions: 1024,});});@@ -87,6 +90,7 @@ describe("OpenAIEmbedder (unit)", () => {const callArgs = mockEmbeddingsCreate.mock.calls[0][0];expect(callArgs).not.toHaveProperty("dimensions");+ expect(callArgs).toHaveProperty("encoding_format", "float");});it("passes dimensions in embedBatch when embeddingDims is explicitly set", async () => {@@ -105,6 +109,7 @@ describe("OpenAIEmbedder (unit)", () => {expect(callArgs).toEqual({model: "text-embedding-3-small",input: ["hello", "world"],+ encoding_format: "float",dimensions: 512,});});