Files
DeepTutor/tests
Bingxi Zhao (Frank) c4a6f1b228 fix(embedding): recover from gateways that require an explicit encoding_format
ModelScope reads a missing `encoding_format` as `''` and refuses the request:
`encoding_format must be 'float' or 'base64', got ''`. So the probe and every
real embedding call failed for #934, while the same config worked through the
vendor SDK, which defaults the field to "float".

The report's root cause is right and its suggested fix keys off the wrong
thing. Special-casing the qwen3-embedding family reads the constraint as
belonging to the model, but it belongs to the gateway, and the gateways
disagree: SiliconFlow rejects the param when it is *present* (#651, which is
why it is omitted), ModelScope when it is *absent*. The same Qwen3-Embedding
weights are served on both sides of that disagreement, so no default and no
model-family rule can satisfy both.

Recover from the provider's own refusal instead. The happy path is
byte-identical — the param is still omitted, so every working config sends
exactly what it sent before — and a 400 that names both the parameter and the
value we are about to send earns one retry with `encoding_format="float"`.
Requiring the body to name "float" is what separates "you must send this"
from "I do not support this", so a gateway in the second camp is not retried
into the same failure. The retry is bounded by the param then being present.

Also notes at the omit site why a default must not be reintroduced there:
it would trade #934 for #651.
2026-08-21 16:25:18 +08:00
..
2026-08-19 17:34:52 +08:00