fix(embedding): 统一 embedding 输入截断#2266
Merged
Merged
Conversation
zhoujh01
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
本 PR 修复 embedding 输入超 token 时检索侧没有统一应用
max_input_tokens的问题。现在输入截断由 embedder 自身负责,检索和写入都会在模型请求前走同一套输入保护逻辑。Related Issue
无
Type of Change
Changes Made
max_input_tokens写入 embedder runtime config,并在EmbedderBase中统一准备 embedding 输入embed_compat明确依赖 embedder 合同,检索和写入路径都通过 embedder 输入保护后再请求模型Testing
本地验证:
.venv/bin/python -m ruff check openviking/utils/embedding_input.py openviking/models/embedder/base.py openviking/utils/embedding_utils.py openviking/storage/collection_schemas.py openviking_cli/utils/config/embedding_config.py tests/test_telemetry_runtime.py tests/unit/test_embedding_vectorize_strategy.py tests/unit/test_model_retry.py tests/unit/test_vectorize_file_strategy.py tests/storage/test_collection_schemas.py.venv/bin/python -m pytest tests/test_telemetry_runtime.py::test_embed_compat_binds_query_stage_for_embedding_tokens tests/unit/test_embedding_vectorize_strategy.py tests/unit/test_vectorize_file_strategy.py tests/storage/test_collection_schemas.py::test_embedding_handler_truncates_queue_input_before_embed tests/unit/test_model_retry.pygit diff --checkChecklist
Screenshots (if applicable)
不适用
Additional Notes
本 PR 没有调整模型 SDK 的
max_retries;仅扩展现有非重试错误分类,确保类似input (...) is too large to process的错误不会被当作可重试错误处理。