Test/add document summary retriever tests #20412
Open
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.
Description
This PR adds missing test cases for
DocumentSummaryIndexretrievers. The original test filetests/indices/document_summary/test_retrievers.pyonly contained an emptytest_retrieve_defaultfunction with a TODO comment.Changes Made
test_retrieve_default: Tests the DEFAULT retriever mode (DocumentSummaryIndexRetriever) which uses LLM-based choice selection to retrieve relevant summariestest_retrieve_embedding: Tests the EMBEDDING retriever mode (DocumentSummaryIndexEmbeddingRetriever) which uses embedding similarity to retrieve summariesmock_llmpredictor_predict_for_choice_select: Mocks LLM predictor for choice select prompts with correct format expected bydefault_parse_choice_select_answer_fn_get_embeddings: Mocks embedding function for embedding-based retrievalThe tests follow the existing patterns used in other retriever tests (e.g.,
tests/indices/list/test_retrievers.py) and ensure both retriever modes are properly covered.Fixes # (N/A - this is a test coverage improvement, not fixing a specific issue)
New Package?
Did I fill in the
tool.llamahubsection in thepyproject.tomland provide a detailed README.md for my new integration or package?Version Bump?
Did I bump the version in the
pyproject.tomlfile of the package I am updating? (Except for thellama-index-corepackage)Type of Change
Please delete options that are not relevant.
How Has This Been Tested?
Your pull-request will likely not be merged unless it is covered by some form of impactful unit testing.
Test Coverage:
test_retrieve_default: Tests that the DEFAULT retriever mode correctly retrieves nodes using LLM-based choice selectiontest_retrieve_embedding: Tests that the EMBEDDING retriever mode correctly retrieves nodes using embedding similarityBoth tests:
DocumentSummaryIndexwith test documentsSuggested Checklist:
uv run make format; uv run make lintto appease the lint gods (Pending - will run before final submission)Additional Notes
This contribution addresses the TODO comment in the original test file and improves test coverage for the
DocumentSummaryIndexretrievers. The implementation: