ExaSearchRetriever Class — langchain Architecture
Architecture documentation for the ExaSearchRetriever class in retrievers.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 593f1ee8_77ed_951c_9250_d51c39a1a7a2["ExaSearchRetriever"] 3a20478a_3692_141f_433b_a32429b00020["BaseRetriever"] 593f1ee8_77ed_951c_9250_d51c39a1a7a2 -->|extends| 3a20478a_3692_141f_433b_a32429b00020 adcb3d5b_1090_8f27_8ae7_b26d830eb673["retrievers.py"] 593f1ee8_77ed_951c_9250_d51c39a1a7a2 -->|defined in| adcb3d5b_1090_8f27_8ae7_b26d830eb673 42671fa9_5b7a_3b20_b051_9ce39f628607["validate_environment()"] 593f1ee8_77ed_951c_9250_d51c39a1a7a2 -->|method| 42671fa9_5b7a_3b20_b051_9ce39f628607 5cd1a72f_50ef_d2d2_ed38_f5ce81dd0a4b["_get_relevant_documents()"] 593f1ee8_77ed_951c_9250_d51c39a1a7a2 -->|method| 5cd1a72f_50ef_d2d2_ed38_f5ce81dd0a4b
Relationship Graph
Source Code
libs/partners/exa/langchain_exa/retrievers.py lines 39–110
class ExaSearchRetriever(BaseRetriever):
"""Exa Search retriever."""
k: int = 10 # num_results
"""The number of search results to return (1 to 100)."""
include_domains: list[str] | None = None
"""A list of domains to include in the search."""
exclude_domains: list[str] | None = None
"""A list of domains to exclude from the search."""
start_crawl_date: str | None = None
"""The start date for the crawl (in YYYY-MM-DD format)."""
end_crawl_date: str | None = None
"""The end date for the crawl (in YYYY-MM-DD format)."""
start_published_date: str | None = None
"""The start date for when the document was published (in YYYY-MM-DD format)."""
end_published_date: str | None = None
"""The end date for when the document was published (in YYYY-MM-DD format)."""
use_autoprompt: bool | None = None
"""Whether to use autoprompt for the search."""
type: str = "neural"
"""The type of search, 'keyword', 'neural', or 'auto'. Default: neural"""
highlights: HighlightsContentsOptions | bool | None = None
"""Whether to set the page content to the highlights of the results."""
text_contents_options: TextContentsOptions | dict[str, Any] | Literal[True] = True
"""How to set the page content of the results. Can be True or a dict with options
like max_characters."""
livecrawl: Literal["always", "fallback", "never"] | None = None
"""Option to crawl live webpages if content is not in the index. Options: "always",
"fallback", "never"."""
summary: bool | dict[str, str] | None = None
"""Whether to include a summary of the content. Can be a boolean or a dict with a
custom query."""
client: Exa = Field(default=None) # type: ignore[assignment]
exa_api_key: SecretStr = Field(default=SecretStr(""))
exa_base_url: str | None = None
@model_validator(mode="before")
@classmethod
def validate_environment(cls, values: dict) -> Any:
"""Validate the environment."""
return initialize_client(values)
def _get_relevant_documents(
self, query: str, *, run_manager: CallbackManagerForRetrieverRun
) -> list[Document]:
response = self.client.search_and_contents( # type: ignore[call-overload]
query,
num_results=self.k,
text=self.text_contents_options,
highlights=self.highlights,
include_domains=self.include_domains,
exclude_domains=self.exclude_domains,
start_crawl_date=self.start_crawl_date,
end_crawl_date=self.end_crawl_date,
start_published_date=self.start_published_date,
end_published_date=self.end_published_date,
use_autoprompt=self.use_autoprompt,
livecrawl=self.livecrawl,
summary=self.summary,
type=self.type,
) # type: ignore[call-overload, misc]
results = response.results
return [
Document(
page_content=(result.text),
metadata=_get_metadata(result),
)
for result in results
]
Extends
Source
Frequently Asked Questions
What is the ExaSearchRetriever class?
ExaSearchRetriever is a class in the langchain codebase, defined in libs/partners/exa/langchain_exa/retrievers.py.
Where is ExaSearchRetriever defined?
ExaSearchRetriever is defined in libs/partners/exa/langchain_exa/retrievers.py at line 39.
What does ExaSearchRetriever extend?
ExaSearchRetriever extends BaseRetriever.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free