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 .
This commit is contained in:
Stony 2026-01-05 14:48:33 +08:00 committed by GitHub
parent b339529621
commit 343099386c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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]