[Bug] `_should_send_dimensions` forces `dimensions` param for SiliconFlow BAAI/bge embeddings which rejects it (HTTP 400)
Summary
When configuring OpenViking 0.4.15 with a SiliconFlow (https://api.siliconflow.cn/v1) OpenAI-compatible embedding endpoint using BAAI/bge-large-zh-v1.5, embedding calls fail with HTTP 400 "The parameter is invalid" because OpenViking unconditionally sends the dimensions parameter for any provider=openai endpoint with a non-empty api_base.
SiliconFlow's embeddings API does not accept a dimensions parameter in the request body.
Environment
- OpenViking version: 0.4.15
- Embedding provider: SiliconFlow (https://api.siliconflow.cn/v1/embeddings)
- Model:
BAAI/bge-large-zh-v1.5(returns 1024-dim vectors by default)
Root cause
In openviking/models/embedder/openai_embedders.py, the method _should_send_dimensions():
def _should_send_dimensions(self) -> bool:
# Preserve existing behavior for official OpenAI embeddings: only custom
# OpenAI-compatible backends and Azure send explicit dimensions.
if self._provider == "openai":
return bool(self.api_base)
return bool(self.api_base)
For any provider=openai with a non-empty api_base, it returns True, so embed() always appends kwargs["dimensions"] = self.dimension. SiliconFlow rejects this with:
HTTP 400: {"code":20015,"message":"The parameter is invalid. Please check again.","data":null}
Repro
// ov.conf
{
"embedding": {
"dense": {
"provider": "openai",
"model": "BAAI/bge-large-zh-v1.5",
"api_base": "https://api.siliconflow.cn/v1",
"api_key": "<SILICONFLOW_KEY>",
"dimension": 1024,
"encoding_format": "float"
}
}
}
curl -X POST https://api.siliconflow.cn/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <KEY>" \
-d '{"model":"BAAI/bge-large-zh-v1.5","input":"test","dimensions":1024}'
# => HTTP 400: {"code":20015,"message":"The parameter is invalid. Please check again.","data":null}
Without dimensions:
curl -X POST https://api.siliconflow.cn/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <KEY>" \
-d '{"model":"BAAI/bge-large-zh-v1.5","input":"test"}'
# => 200 OK, 1024-dim vector
Expected behavior
OpenViking should either:
- Not send
dimensionswhen the backing provider doesn't support it (add a config knob likeembedding.dense.send_dimensionsto control this per-provider), or - Auto-detect: if the model returns a vector whose dimension matches
self.dimension, skip sendingdimensionson retry.
SiliconFlow is a widely-used free OpenAI-compatible host; this currently makes it impossible to use SiliconFlow's bge embeddings with OpenViking without patching source.
Workaround
We applied a local source patch to _should_send_dimensions() to return False when api_base contains siliconflow and model starts with BAAI/bge:
if self._provider == "openai":
if self.api_base and "siliconflow" in self.api_base and self.model_name.startswith("BAAI/bge"):
return False
return bool(self.api_base)
This is a stopgap; we will revert it once upstream provides first-class support. Dimension stays 1024 so existing vectors remain compatible (no reindex).
The _should_send_dimensions() implementation shown here does not match the published v0.4.15 or v0.4.16 tags: both return False for provider == "openai", so this path does not add dimensions. The return bool(self.api_base) behavior appeared in #2317 and #4253, but both PRs were closed without merge. Please reinstall or upgrade to openviking==0.4.16 and verify the loaded module path and method source. If the outgoing request still contains dimensions, that evidence would show whether another checkout, package, or extra_body is adding it.
Thanks for reporting this.
We checked the published v0.4.15 and v0.4.16 code. In both versions, _should_send_dimensions() returns False when provider == "openai", including when a custom api_base is configured, so that path does not add dimensions to the request. The implementation quoted here appeared in #2317 and #4253, but neither PR was merged.
This therefore points to a mixed or locally patched installation rather than behavior in a supported OpenViking release. Please reinstall openviking==0.4.16 and verify the loaded module path and method source. We are closing this issue because the reported code path is not present in the published versions.
Thanks for the detailed response — we accept the closing and confirm your diagnosis is correct.
Verification on our side (with evidence)
Following your advice to verify the loaded module path and method source, we inspected the actual installed 0.4.15 source:
# /usr/local/lib/python3.11/site-packages/openviking/models/embedder/openai_embedders.py:291
def _should_send_dimensions(self) -> bool:
# Preserve existing behavior for official OpenAI embeddings: only custom
# OpenAI-compatible backends and Azure send explicit dimensions.
if self._provider == "openai":
return False
return bool(self.api_base)
We confirmed provider == "openai" returns False, so no dimensions parameter is added for SiliconFlow (or any openai provider). We have reverted our local workaround patch back to this official code and SiliconFlow embeddings now work normally (200 OK, 1024-dim). We agree the 20015 issue was caused by our own local patch mixing in the unmerged #2317/#4253 behavior, not by a released OpenViking version.
Separate issue (not this one) — AddResource queue stuck tasks
Separate from the dimensions question, we are also hitting a different symptom: AddResource tasks that have already written data to disk sometimes stay stuck in processing forever (the worker appears blocked in TaskWorkIndex.has_work inside wait_for_descendants, which loops asyncio.sleep(0.05) with no timeout while some orphan work entry remains in the in-memory _work dict). This is reproducible on 0.4.15 and, from our source comparison, also present on 0.4.16 (the in-memory _work dict and the no-timeout loop are unchanged between the two tags). Since this is a different root cause than dimensions, we will file a separate issue with a minimal repro. Thanks again for the prompt response.