RetrieversIntegrationTests#
- class langchain_tests.integration_tests.retrievers.RetrieversIntegrationTests[source]#
Base class for retrievers integration tests.
Attributes
retriever_constructor
A BaseRetriever subclass to be tested.
retriever_constructor_params
Returns a dictionary of parameters to pass to the retriever constructor.
retriever_query_example
Returns a str representing the "query" of an example retriever call.
Methods
test_ainvoke_returns_documents
(retriever)If ainvoked with the example params, the retriever should return a list of Documents.
test_invoke_returns_documents
(retriever)If invoked with the example params, the retriever should return a list of Documents.
test_invoke_with_k_kwarg
(retriever)Test that the invoke method accepts a k parameter, representing the number of documents to return.
Test that the retriever constructor accepts a k parameter, representing the number of documents to return.
- async test_ainvoke_returns_documents(retriever: BaseRetriever) None [source]#
If ainvoked with the example params, the retriever should return a list of Documents.
See
test_invoke_returns_documents()
for more information on troubleshooting.- Parameters:
retriever (BaseRetriever)
- Return type:
None
- test_invoke_returns_documents(retriever: BaseRetriever) None [source]#
If invoked with the example params, the retriever should return a list of Documents.
Troubleshooting
If this test fails, the retriever’s invoke method does not return a list of langchain_core.document.Document objects. Please confirm that your _get_relevant_documents method returns a list of Document objects.
- Parameters:
retriever (BaseRetriever)
- Return type:
None
- test_invoke_with_k_kwarg(retriever: BaseRetriever) None [source]#
Test that the invoke method accepts a k parameter, representing the number of documents to return.
Troubleshooting
If this test fails, the retriever’s invoke method does not accept a k parameter, or the retriever does not return the correct number of documents (k) when it is set.
For example, a retriever like
MyRetriever().invoke("query", k=3)
should return 3 documents when invoked with a query.
- Parameters:
retriever (BaseRetriever)
- Return type:
None
- test_k_constructor_param() None [source]#
Test that the retriever constructor accepts a k parameter, representing the number of documents to return.
Troubleshooting
If this test fails, either the retriever constructor does not accept a k parameter, or the retriever does not return the correct number of documents (k) when it is set.
For example, a retriever like
MyRetriever(k=3).invoke("query")
should return 3 documents when invoked with a query.
- Return type:
None