From 343099386c28642699afa19328baea3b58be1635 Mon Sep 17 00:00:00 2001 From: Stony Date: Mon, 5 Jan 2026 14:48:33 +0800 Subject: [PATCH] Add dimensions parameter to embedding request Fixes LiteLLMEmbeddingEngine not passing EMBEDDING_DIMENSIONS to litellm. **Changes:** - Added `dimensions=self.dimensions` parameter to the `litellm.aembedding()` call in the `embed_text()` method of `LiteLLMEmbeddingEngine.py`. **Why?** This ensures that custom embedding dimensions configured in cognee (e.g., 512 instead of default 3072) are respected by LiteLLM, preventing dimension mismatches in downstream vector databases like Qdrant or Pinecone. **Impact:** - Actual embeddings now match the configured `self.dimensions`. - Only affects production mode; mock mode remains unchanged. - Tested with OpenAI models that support the `dimensions` parameter. Fixes #1961 . --- .../databases/vector/embeddings/LiteLLMEmbeddingEngine.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cognee/infrastructure/databases/vector/embeddings/LiteLLMEmbeddingEngine.py b/cognee/infrastructure/databases/vector/embeddings/LiteLLMEmbeddingEngine.py index 12de57617..93e3dd26a 100644 --- a/cognee/infrastructure/databases/vector/embeddings/LiteLLMEmbeddingEngine.py +++ b/cognee/infrastructure/databases/vector/embeddings/LiteLLMEmbeddingEngine.py @@ -117,6 +117,7 @@ class LiteLLMEmbeddingEngine(EmbeddingEngine): api_key=self.api_key, api_base=self.endpoint, api_version=self.api_version, + dimensions=self.dimensions, ) return [data["embedding"] for data in response.data]