fix: Improve imports for new rankers #5696
Merged
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.
Why:
The PR aims to standardize how new rankers:
RecentnessRanker
,DiversityRanker
, andLostInTheMiddleRanker
are imported in Haystack. Currently, these rankers are inconsistently imported compared to existing rankers. By modifyinghaystack/nodes/ranker/__init__.py
, we make it possible for users to import these rankers in a manner consistent with existing ones.What:
Updated
haystack/nodes/ranker/__init__.py
to include the new rankers and also updated examples to reflect this change.How can it be used:
After this change, users can import the new rankers as shown below, which is consistent with how existing rankers are imported:
How did you test it:
Manually tested the new import paths in the
haystack/examples
directory to ensure they work as expected.Notes For Reviewer:
Please double-check the examples on this branch to ensure that the new import paths are correctly implemented and that there are no unintended side effects.