Skip to content

fix(embedding): 统一 embedding 输入截断#2266

Merged
zhoujh01 merged 2 commits into
mainfrom
fix/embedding-input-limit
May 27, 2026
Merged

fix(embedding): 统一 embedding 输入截断#2266
zhoujh01 merged 2 commits into
mainfrom
fix/embedding-input-limit

Conversation

@qin-ctx
Copy link
Copy Markdown
Collaborator

@qin-ctx qin-ctx commented May 27, 2026

Description

本 PR 修复 embedding 输入超 token 时检索侧没有统一应用 max_input_tokens 的问题。现在输入截断由 embedder 自身负责,检索和写入都会在模型请求前走同一套输入保护逻辑。

Related Issue

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • max_input_tokens 写入 embedder runtime config,并在 EmbedderBase 中统一准备 embedding 输入
  • embed_compat 明确依赖 embedder 合同,检索和写入路径都通过 embedder 输入保护后再请求模型
  • 清理 queue/vectorize 层的重复截断逻辑,并补充超长输入错误分类与相关回归测试

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

本地验证:

  • .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.py
  • git diff --check

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

不适用

Additional Notes

本 PR 没有调整模型 SDK 的 max_retries;仅扩展现有非重试错误分类,确保类似 input (...) is too large to process 的错误不会被当作可重试错误处理。

@zhoujh01 zhoujh01 merged commit c72c8a8 into main May 27, 2026
13 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project May 27, 2026
@zhoujh01 zhoujh01 deleted the fix/embedding-input-limit branch May 27, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants