OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: vikingdb query_param/document_param are silently ignored - input_type never sent on the async embedding path

Open Tong-bit-art opened this issue 1 month ago • 1 comments

Issue Origin

Observed or reproduced in a real environment

Bug Description

For the vikingdb embedding provider, query_param and document_param never reach the embedding API. The configuration is accepted, validated and plumbed all the way to the embedder, then silently dropped on the only code path production uses.

This is the same defect #1110 set out to fix — its commit message reads "VikingDB embedders accepted is_query but ignored it. Now VikingDBDenseEmbedder and VikingDBHybridEmbedder accept query_param/document_param and pass input_type to the API when non-symmetric mode is configured." That change covered _call_api, embed() and embed_batch(). The async path was left behind:

  • _call_api_async has no input_type parameter.
  • VikingDBDenseEmbedder.embed_async accepts is_query but never calls _resolve_input_type.
  • VikingDBHybridEmbedder.embed_async likewise.

embed_compat() routes both ingestion and queries through embed_async (models/embedder/base.py:200 for documents, :219 for queries), and AccountBoundEmbedder reaches it through config/embedding.py:245. No production call site invokes the synchronous embed() that does honour input_type. So a correctly configured asymmetric model behaves as if the parameters were never set — no error, no warning.

Jina, Gemini and LiteLLM all resolve is_query in both embed() and embed_async(); VikingDB is the only provider that does not.

Steps to Reproduce

  1. Configure embedding.dense.provider = "vikingdb" with query_param and document_param, e.g. "query" / "passage".
  2. Ingest any resource.
  3. Search for it.

Expected Behavior

The request body sent to /api/vikingdb/embedding carries input_type: "passage" for ingestion and input_type: "query" for the search, as the sync path already does and as the config schema documents:

Parameter value for query-side embeddings when calling embed(is_query=True) … this maps to 'input_type'

(seen in issue #655, and #1110 added Gemini and Jina task-type passthrough the same way.)

Actual Behavior

No input_type key is present in any request. The configured value is discarded.

Minimal Reproducible Example

from types import SimpleNamespace
from unittest.mock import AsyncMock, Mock

from openviking.models.embedder.base import EmbedderBase
from openviking.models.embedder.vikingdb_embedders import VikingDBDenseEmbedder

embedder = VikingDBDenseEmbedder.__new__(VikingDBDenseEmbedder)
EmbedderBase.__init__(embedder, "test-model", {})
embedder.dimension = None
embedder.host = "test-host"
embedder.dense_model = {"name": "test-model", "version": None, "dim": None}
embedder.query_param = "query"
embedder.document_param = "passage"

sent = {}
embedder.client = Mock()
embedder.client.prepare_request.side_effect = lambda method, path, data=None: (
    sent.update(data or {}),
    SimpleNamespace(method=method, path=path, headers={}, body=b""),
)[1]
embedder._async_client_cache = Mock()
embedder._async_client_cache.get.return_value = SimpleNamespace(
    request=AsyncMock(
        return_value=SimpleNamespace(
            status_code=200, json=lambda: {"result": {"data": [{"dense_embedding": [0.1]}]}}
        )
    )
)

await embedder.embed_async("hello", is_query=True)
print(sent["data"][0])  # {'text': 'hello'} - input_type is gone

Error Logs

None. There is no failure to observe — the parameter simply has no effect, which is why it went unnoticed.

OpenViking Version

main @ d9352f2a8

Python Version

3.11.9

Operating System

Windows

Model Backend

Volcengine (Doubao)

Additional Context

_call_api_async at models/embedder/vikingdb_embedders.py:80-113 compared with _call_api at :44-78, which gained the parameter in #1110.

The same shape was reported and fixed once before for a different provider: #4134 "LiteLLMDenseEmbedder.embed_async() skips _truncate_vector(), breaking both ingest and search", fixed by #4146. That issue made the same observation about embed_compat routing all traffic through the async path.

I am not proposing a fix here — per CONTRIBUTING this changes configuration semantics, so I would like to confirm the boundary first. Happy to send a minimal PR that mirrors the sync path if that is the preferred shape.

Tong-bit-art avatar Oct 06 '26 05:10 Tong-bit-art

Claiming this with a PR so the issue is not picked up twice.

  • Fix: #5683 — fix(embedding): send input_type on the VikingDB async embedding path
  • Diff: +93/-3 across openviking/models/embedder/vikingdb_embedders.py and tests/unit/embedder/test_vikingdb_nonsymmetric.py

Reproduced against unmodified main before writing the fix: with query_param="query" / document_param="passage" configured, both async embedders send a request body without input_type, failing with KeyError: 'input_type'.

I cannot set the assignee field myself (no write access on this repository), so recording the link here instead. Happy to adjust the approach if you would rather resolve this differently.

Tong-bit-art avatar Oct 06 '26 07:10 Tong-bit-art