fix(embedding): don't send encoding_format by default for OpenAI-compatible providers - #652
Merged
Merged
Conversation
…atible providers SiliconFlow and other OpenAI-compatible providers reject the `encoding_format` parameter with HTTP 400. Only send it when explicitly set by the user, matching the existing opt-in pattern used for `dimensions` (send_dimensions flag). Closes HKUDS#651
Collaborator
|
Thanks for your contribution! |
pancacake
added a commit
that referenced
this pull request
Jul 23, 2026
… gateways #652 added a guard so the gateway adapter only sends encoding_format when set, but it was a no-op: EmbeddingRequest.encoding_format defaulted to the truthy "float", so the guard always fired and the param was still posted — leaving the #651 HTTP 400 from gateways like SiliconFlow intact. Fix the root cause: default encoding_format to None. The gateway adapter now omits it unless a caller explicitly opts in, while the official OpenAI SDK path keeps pinning "float" (that API expects it). The intentional divergence is documented at both call sites. Adds a payload test proving the gateway omits it by default and includes it when set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
vaskoyudha
added a commit
to vaskoyudha/deeptutor-for-programmer-fork
that referenced
this pull request
Jul 25, 2026
…format fix(embedding): don't send encoding_format by default for OpenAI-compatible providers
vaskoyudha
added a commit
to vaskoyudha/deeptutor-for-programmer-fork
that referenced
this pull request
Jul 25, 2026
… gateways HKUDS#652 added a guard so the gateway adapter only sends encoding_format when set, but it was a no-op: EmbeddingRequest.encoding_format defaulted to the truthy "float", so the guard always fired and the param was still posted — leaving the HKUDS#651 HTTP 400 from gateways like SiliconFlow intact. Fix the root cause: default encoding_format to None. The gateway adapter now omits it unless a caller explicitly opts in, while the official OpenAI SDK path keeps pinning "float" (that API expects it). The intentional divergence is documented at both call sites. Adds a payload test proving the gateway omits it by default and includes it when set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
SiliconFlow (and possibly other OpenAI-compatible embedding providers) returns HTTP 400 when receiving the
encoding_formatparameter, which is currently always sent as"float"even when the user hasn't explicitly set it.Root Cause
In
openai_compatible.py, theencoding_formatdefaults to"float"unconditionally:Unlike
dimensions(which hassend_dimensionsflag and model-family heuristics),encoding_formathas no opt-out mechanism.Fix
Only include
encoding_formatin the request payload when the user explicitly sets it viarequest.encoding_format:This matches the existing pattern used for
dimensions/send_dimensions.Testing
BAAI/bge-large-zh-v1.5(previously returned HTTP 400)encoding_formatare unaffectedtext-embedding-3-*models still work (noencoding_format= default behavior)Closes #651