feat(splitter): 解耦 overlap 配置与上下文拼接#140
Merged
Merged
Conversation
新增 CHUNKING_OVERLAP_ENABLED 配置,并限制 CHUNKING_OVERLAP_TOKENS 为 0..64。 抽出 ChunkOverlapper 统一处理 overlap token 截取与拼接,语义分片与两阶段 neighbor context 复用同一实现,保持原有分片流程不变。 补充 splitter 与配置单元测试,并同步 .env.example、运维配置文档和 chunking 内部说明。
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.
关联 Issue
Closes #138
变更内容
CHUNKING_OVERLAP_ENABLED配置,显式控制 splitter overlap 是否启用。CHUNKING_OVERLAP_TOKENS限制为0..64,配置越界时启动校验失败。ChunkOverlapConfig/ChunkOverlapper,统一处理 overlap token 截取与上下文拼接。PercentileSemanticChunker与StructuredSemanticChunker复用同一 overlap 实现,不再由语义分片器承担 overlap 细节。.env.example、docs/ops/configure.md、docs/internals/chunking.md。验收覆盖
CHUNKING_OVERLAP_ENABLED=false时,语义分片 overlap 和 neighbor context overlap 都不追加。CHUNKING_OVERLAP_TOKENS=0时不追加 overlap。CHUNKING_OVERLAP_TOKENS=64时允许启动,并按 64 token 上限执行。CHUNKING_OVERLAP_TOKENS < 0或> 64时配置校验失败。验证
.venv/bin/pytest tests/unit -q:360 passed.venv/bin/pytest tests/unit/core/splitter tests/unit/test_config_sparse_vector.py -q:22 passed.venv/bin/mypy src/core/splitter src/config.py:通过.venv/bin/python scripts/check_docs_sync.py --staged:通过.venv/bin/python scripts/check_docs_sync.py --working:通过说明:全量
.venv/bin/mypy src仍存在仓库既有历史类型错误;本 PR 触碰范围的 mypy 已通过。