Repository navigation
Conversation
…he run Document.score defaults to None, which is also the only state every converter produces (Document(content=..., metadata=...)) and what get_documents_by_id returns. adjust_similarity_scores multiplied that None: "unsupported operand type(s) for *: 'NoneType' and 'float'". A document with no date either stayed None and broke the sort: "'<' not supported between instances of 'NoneType' and 'float'". Through Node.run both surface as a FAILURE with the bare message, so a flow that ranks freshly loaded chunks by their date cannot run at all. An unscored document with a date now takes a neutral base of 1.0, so recency decides alone; one with neither a score nor a date keeps None and sorts last in input order.
This branch has not been deployed
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.
TimeWeightedDocumentRankerfailed on documents that carry no score, which is the default state ofDocumentand the only state every converter produces:Document.scoredefaults toNone, andadjust_similarity_scoresmultiplied it:unsupported operand type(s) for *: 'NoneType' and 'float'.dateand no score stayedNone, and the sort compared it:'<' not supported between instances of 'NoneType' and 'float'.Node.runboth surface asRunnableStatus.FAILUREcarrying that bare message, so the flow stops.No construction is needed to reach this: converter components return
{"documents": [...]}built asDocument(content=..., metadata=...)— the exact key this ranker takes — andRetriever.get_documents_by_idalso returns score-less documents. Ranking freshly loaded chunks by their date is what a time-weighted ranker is for.An unscored document with a date now takes a neutral base score of
1.0, so recency decides alone. One with neither a score nor a date keepsNoneand sorts last, preserving its input order.Compatibility
No change for scored documents: a document with a score and a date is adjusted exactly as before, and a scored document without a date keeps its score. Only documents that previously failed the run now rank.
Verified
tests/unit/nodes/rankers/test_recency_ranker_score.py: unscored documents ranked by recency, unscored documents without a date sorted after scored ones, the all-undated case keeping input order, andtop_kstill applying.tests/integration/nodes/rerankers/test_recency.py, 11 passed.pytest tests/unit/nodes/rankers tests/integration/nodes/rerankers→ 15 passed.flake8andisort --check-onlyclean.This change was prepared with AI assistance.