fix: prevent embedding 422 on strict OpenAI-compatible endpoints (DeepInfra, vLLM, TEI)#1430
Closed
PaoloC68 wants to merge 1 commit intoagent0ai:developmentfrom
Closed
Conversation
LiteLLM >=1.80.11 sends encoding_format=null in embedding requests when the parameter is not explicitly set (BerriAI/litellm#19174). Strict validators such as DeepInfra, vLLM, and HuggingFace TEI reject null with: 422 Unprocessable Entity: Input should be 'float' or 'base64' Default to 'float' (the OpenAI spec default) before merging caller kwargs, so any explicitly configured value still takes precedence.
Contributor
Author
|
Superseded by #1437 which combines both embedding fixes (encoding_format null + context window truncation) in a single clean PR. |
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.
Fixes #1429
Summary
LiteLLM ≥1.80.11 sends
encoding_format: nullin embedding requests when the parameter is not explicitly set. Strict OpenAI-compatible validators (DeepInfra, vLLM, HuggingFace TEI) rejectnullwith a 422 error. This fix sets"float"as the default — the OpenAI spec default — before merging caller kwargs, so any explicitly configured value still takes precedence.Changes
models.pyembed_documentsandembed_query: buildembed_kwargswithencoding_format="float"default before**self.kwargsTesting
Tested on helpa0.com with DeepInfra embedding provider (
openai/BAAI/bge-m3) and LiteLLM 1.82.3. Memory search and recall both work correctly after the fix.Upstream LiteLLM issue: BerriAI/litellm#19174
Partial upstream fix (openai_like handler only): BerriAI/litellm#20056
Pending upstream fix (openai handler): BerriAI/litellm#24277