Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(embedder): 稀疏嵌入仅提交文本输入 (#4296)
Axiomoth41044af77901
diff --git a/openviking/models/embedder/volcengine_embedders.py b/openviking/models/embedder/volcengine_embedders.pyindex 1f6d74d82..bbec5e4ef 100644--- a/openviking/models/embedder/volcengine_embedders.py+++ b/openviking/models/embedder/volcengine_embedders.py@@ -405,8 +405,16 @@ class VolcengineSparseEmbedder(SparseEmbedderBase):@propertydef supports_multimodal(self) -> bool:- """Multimodal inputs are supported when using the multimodal endpoint."""- return self.input_type == "multimodal"+ """Sparse vectors require text-only input even on the multimodal endpoint.++ The provider accepts the request at the endpoint level, but rejects+ non-text parts (images and videos) whenever ``sparse_embedding`` is+ enabled. Returning ``False`` makes the common embedder guard retain the+ extracted text and drop those parts before the provider call. Image-only+ search remains unsupported and is rejected by the retrieval capability+ check instead of embedding empty text.+ """+ return Falseclass VolcengineHybridEmbedder(HybridEmbedderBase):@@ -489,8 +497,14 @@ class VolcengineHybridEmbedder(HybridEmbedderBase):@propertydef supports_multimodal(self) -> bool:- """Hybrid embeddings always use the multimodal endpoint."""- return True+ """Hybrid vectors include sparse output and therefore require text input.++ A hybrid provider request enables sparse embedding, for which image and+ video parts are unsupported. The base guard performs a deterministic+ text-only downgrade for mixed content. Image-only search remains+ unsupported because dropping its only input would produce an empty query.+ """+ return Falsedef embed(self, content: "EmbeddingInput", is_query: bool = False) -> EmbedResult:"""Perform hybrid embedding on text or multimodal contentdiff --git a/tests/unit/test_volcengine_embedder_input.py b/tests/unit/test_volcengine_embedder_input.pynew file mode 100644index 000000000..e0f74b19d--- /dev/null+++ b/tests/unit/test_volcengine_embedder_input.py@@ -0,0 +1,32 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""Input-guard tests for Volcengine sparse-capable embedding modes."""++from unittest.mock import patch++from openviking.models.embedder.volcengine_embedders import (+ VolcengineHybridEmbedder,+ VolcengineSparseEmbedder,+)++_MULTIMODAL_INPUT = [+ {"type": "text", "text": "diagram of a heat exchanger"},+ {"type": "image_url", "image_url": {"url": "https://example.test/image.png"}},+ {"type": "video_url", "video_url": {"url": "https://example.test/video.mp4"}},+]+++@patch("openviking.models.embedder.volcengine_embedders.volcenginesdkarkruntime.Ark")+def test_sparse_embedder_downgrades_multimodal_input_to_text(_mock_ark):+ embedder = VolcengineSparseEmbedder(model_name="test", api_key="test-key")++ assert embedder.supports_multimodal is False+ assert embedder.prepare_embedding_input(_MULTIMODAL_INPUT) == "diagram of a heat exchanger"+++@patch("openviking.models.embedder.volcengine_embedders.volcenginesdkarkruntime.Ark")+def test_hybrid_embedder_downgrades_multimodal_input_to_text(_mock_ark):+ embedder = VolcengineHybridEmbedder(model_name="test", api_key="test-key")++ assert embedder.supports_multimodal is False+ assert embedder.prepare_embedding_input(_MULTIMODAL_INPUT) == "diagram of a heat exchanger"