Repository navigation
fix: add standard split metadata when DocumentSplitter uses split_by="function" - #12505
Merged
davidsbatista merged 3 commits intoAug 31, 2026
Conversation
businessarshgoyal
requested review from
davidsbatista
and removed request for
a team
August 29, 2026 09:10
Contributor
|
@devin-ai-integration[bot] is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
devin-ai-integration
Bot
force-pushed
the
devin/1787994583-splitter-function-meta
branch
from
August 29, 2026 09:20
c0ca0f2 to
7f847dd
Compare
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
Contributor
|
@businessarshgoyal thanks for the contribution. I've added some missing behaviour, that's when the
|
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
davidsbatista
approved these changes
Aug 31, 2026
davidsbatista
left a comment
Contributor
There was a problem hiding this comment.
looks good, thanks for the contribution!
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.
Related Issues
DocumentSplitter(split_by="function")together withSentenceWindowRetriever.Proposed Changes:
DocumentSplitter._split_by_functionbuilt its outputDocuments by hand and only setsource_id, unlike every other split mode, which goes through_create_docs_from_splitsand setssplit_id,split_idx_startandpage_number. It also ignoredskip_empty_documents, so empty strings returned by a custom splitting function became empty documents.Consequences:
split_by="function"cannot be used with components that rely on that metadata.SentenceWindowRetrieverraisesValueError: The retrieved documents must have 'split_id' in their metadata.This PR routes the function path through
_create_docs_from_splitsas well:content.find(split, cur_start_idx)to computesplit_idx_startand thepage_number(form feeds before the match).skip_empty_documents=False, matching the other split modes.How did you test it?
test_split_by_functionassertions and added unit tests for page-number/offset tracking, transformed (non-verbatim) splits, empty-split handling withskip_empty_documentsboth on and off, and an end-to-end test showing the output now works withSentenceWindowRetriever.hatch run test:unit test/components/preprocessors/test_document_splitter.py-> 60 passedhatch run test:unit test/components/preprocessors test/components/retrievers-> 559 passedhatch run test:types-> Success: no issues found in 468 source fileshatch run fmt-> All checks passedNotes for the reviewer
The interesting case is the fallback when a split cannot be found verbatim in the source: offsets then become cumulative lengths of the (transformed) splits rather than true source offsets, which is the best available approximation. The existing
test_split_by_functionwas updated because the function path now emits the same metadata as all other modes; no assertions were weakened.This change was written with AI assistance (Devin); the behaviour was reproduced locally before the fix and all tests above were run.
Checklist
Written by Devin