fix: only pass dimensions to OpenAI embeddings API when explicitly configured#4181
Closed
Br1an67 wants to merge 1 commit intomem0ai:mainfrom
Closed
fix: only pass dimensions to OpenAI embeddings API when explicitly configured#4181Br1an67 wants to merge 1 commit intomem0ai:mainfrom
Br1an67 wants to merge 1 commit intomem0ai:mainfrom
Conversation
…nfigured Non-matryoshka embedding models (e.g. on vLLM, Ollama) reject the dimensions parameter with a 400 error. Track whether embedding_dims was explicitly set and only include it in the API call when it was.
Contributor
Author
|
Hi — just a gentle bump on this. Happy to make any changes if needed! |
Himanshu-Sangshetti
approved these changes
Mar 22, 2026
13 tasks
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
OpenAIEmbedding.embed()always passesdimensions=self.config.embedding_dimsto the OpenAI API. For non-matryoshka models served by OpenAI-compatible backends (e.g. vLLM, Ollama), this causes a 400 error because those models don't support thedimensionsparameter.The fix tracks whether
embedding_dimswas explicitly provided in the config. If not,dimensionsis omitted from the API call entirely. When explicitly set, it continues to be passed as before.Fixes #4153
Type of change
How Has This Been Tested?
Unit Test
Updated 4 existing tests to reflect that
dimensionsis no longer passed by defaultAdded
test_embed_no_dimensions_when_not_configured: verifiesdimensionsis NOT sent whenembedding_dimsis not explicitly setAdded
test_embed_dimensions_when_explicitly_configured: verifiesdimensionsIS sent whenembedding_dimsis explicitly set (e.g., 512)All 7 tests pass.
Checklist: