DeepTutor
DeepTutor copied to clipboard
fix(embedding): don't send encoding_format by default for OpenAI-compatible providers
Problem
SiliconFlow (and possibly other OpenAI-compatible embedding providers) returns HTTP 400 when receiving the encoding_format parameter, which is currently always sent as "float" even when the user hasn't explicitly set it.
Root Cause
In openai_compatible.py, the encoding_format defaults to "float" unconditionally:
"encoding_format": request.encoding_format or "float",
Unlike dimensions (which has send_dimensions flag and model-family heuristics), encoding_format has no opt-out mechanism.
Fix
Only include encoding_format in the request payload when the user explicitly sets it via request.encoding_format:
if request.encoding_format:
payload["encoding_format"] = request.encoding_format
This matches the existing pattern used for dimensions / send_dimensions.
Testing
- Works with SiliconFlow
BAAI/bge-large-zh-v1.5(previously returned HTTP 400) - Backward compatible: users who explicitly set
encoding_formatare unaffected - OpenAI's
text-embedding-3-*models still work (noencoding_format= default behavior)
Closes #651