retrievers.py — langchain Source File
Architecture documentation for retrievers.py, a python file in the langchain codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 59f967db_9955_5bd5_8903_5fa19fb4ac25["retrievers.py"] 50e20440_a135_6be3_a5a5_67791be5a2a6["abc"] 59f967db_9955_5bd5_8903_5fa19fb4ac25 --> 50e20440_a135_6be3_a5a5_67791be5a2a6 feec1ec4_6917_867b_d228_b134d0ff8099["typing"] 59f967db_9955_5bd5_8903_5fa19fb4ac25 --> feec1ec4_6917_867b_d228_b134d0ff8099 f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"] 59f967db_9955_5bd5_8903_5fa19fb4ac25 --> f69d6389_263d_68a4_7fbf_f14c0602a9ba 6a98b0a5_5607_0043_2e22_a46a464c2d62["langchain_core.documents"] 59f967db_9955_5bd5_8903_5fa19fb4ac25 --> 6a98b0a5_5607_0043_2e22_a46a464c2d62 2b1aa4a8_5352_1757_010a_46ac9ef4b0b0["langchain_core.retrievers"] 59f967db_9955_5bd5_8903_5fa19fb4ac25 --> 2b1aa4a8_5352_1757_010a_46ac9ef4b0b0 6acb5c26_ca82_2e59_7635_f6897caf5d55["langchain_tests.base"] 59f967db_9955_5bd5_8903_5fa19fb4ac25 --> 6acb5c26_ca82_2e59_7635_f6897caf5d55 style 59f967db_9955_5bd5_8903_5fa19fb4ac25 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Integration tests for retrievers."""
from abc import abstractmethod
from typing import Any
import pytest
from langchain_core.documents import Document
from langchain_core.retrievers import BaseRetriever
from langchain_tests.base import BaseStandardTests
class RetrieversIntegrationTests(BaseStandardTests):
"""Base class for retrievers integration tests."""
@property
@abstractmethod
def retriever_constructor(self) -> type[BaseRetriever]:
"""A `BaseRetriever` subclass to be tested."""
...
@property
def retriever_constructor_params(self) -> dict[str, Any]:
"""Returns a dictionary of parameters to pass to the retriever constructor."""
return {}
@property
@abstractmethod
def retriever_query_example(self) -> str:
"""Returns a str representing the `query` of an example retriever call."""
@property
def num_results_arg_name(self) -> str:
"""Returns the name of the parameter for the number of results returned.
Usually something like `k` or `top_k`.
"""
return "k"
@pytest.fixture
def retriever(self) -> BaseRetriever:
"""Return retriever fixture."""
return self.retriever_constructor(**self.retriever_constructor_params)
def test_k_constructor_param(self) -> None:
"""Test the number of results constructor parameter.
Test that the retriever constructor accepts a parameter representing
the number of documents to return.
By default, the parameter tested is named `k`, but it can be overridden by
setting the `num_results_arg_name` property.
!!! note
If the retriever doesn't support configuring the number of results returned
via the constructor, this test can be skipped using a pytest `xfail` on
the test class:
```python
// ... (123 more lines)
Domain
Subdomains
Classes
Dependencies
- abc
- langchain_core.documents
- langchain_core.retrievers
- langchain_tests.base
- pytest
- typing
Source
Frequently Asked Questions
What does retrievers.py do?
retrievers.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, Runnables subdomain.
What does retrievers.py depend on?
retrievers.py imports 6 module(s): abc, langchain_core.documents, langchain_core.retrievers, langchain_tests.base, pytest, typing.
Where is retrievers.py in the architecture?
retrievers.py is located at libs/standard-tests/langchain_tests/integration_tests/retrievers.py (domain: LangChainCore, subdomain: Runnables, directory: libs/standard-tests/langchain_tests/integration_tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free