haive.core.engine.retriever.providers.TavilySearchAPIRetrieverConfigΒΆ
Tavily Search API Retriever implementation for the Haive framework.
from typing import Any This module provides a configuration class for the Tavily Search API retriever, which retrieves web search results using the Tavily search API service.
The TavilySearchAPIRetriever works by: 1. Taking a search query 2. Sending it to the Tavily Search API 3. Returning web search results as documents
This retriever is particularly useful when: - Need access to current web information - Building applications that require real-time search - Combining web search with other retrieval methods - Providing up-to-date information beyond training data
The implementation integrates with LangChainβs TavilySearchAPIRetriever while providing a consistent Haive configuration interface with secure API key management.
ClassesΒΆ
Configuration for Tavily Search API retriever in the Haive framework. |
Module ContentsΒΆ
- class haive.core.engine.retriever.providers.TavilySearchAPIRetrieverConfig.TavilySearchAPIRetrieverConfig[source]ΒΆ
Bases:
haive.core.common.mixins.secure_config.SecureConfigMixin
,haive.core.engine.retriever.retriever.BaseRetrieverConfig
Configuration for Tavily Search API retriever in the Haive framework.
This retriever searches the web using the Tavily Search API and returns web search results as documents. It requires a Tavily API key.
- retriever_typeΒΆ
The type of retriever (always TAVILY_SEARCH_API).
- Type:
- api_keyΒΆ
Tavily API key (auto-resolved from TAVILY_API_KEY env var).
- Type:
Optional[SecretStr]
Examples
>>> from haive.core.engine.retriever import TavilySearchAPIRetrieverConfig >>> >>> # Create the tavily search retriever config >>> config = TavilySearchAPIRetrieverConfig( ... name="tavily_retriever", ... k=5, ... include_answer=True, ... exclude_domains=["example.com"] ... ) >>> >>> # Instantiate and use the retriever >>> retriever = config.instantiate() >>> docs = retriever.get_relevant_documents("latest AI developments 2024")
- instantiate()[source]ΒΆ
Create a Tavily Search API retriever from this configuration.
- Returns:
Instantiated retriever ready for web search.
- Return type:
TavilySearchAPIRetriever
- Raises:
ImportError β If required packages are not available.
ValueError β If API key is not available.