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ΒΆ

TavilySearchAPIRetrieverConfig

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:

RetrieverType

api_keyΒΆ

Tavily API key (auto-resolved from TAVILY_API_KEY env var).

Type:

Optional[SecretStr]

kΒΆ

Maximum number of search results to retrieve (default: 10).

Type:

int

include_domainsΒΆ

Domains to include in search.

Type:

Optional[List[str]]

exclude_domainsΒΆ

Domains to exclude from search.

Type:

Optional[List[str]]

include_answerΒΆ

Whether to include answer in results (default: False).

Type:

bool

include_raw_contentΒΆ

Whether to include raw content (default: False).

Type:

bool

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")
get_input_fields()[source]ΒΆ

Return input field definitions for Tavily Search API retriever.

Return type:

dict[str, tuple[type, Any]]

get_output_fields()[source]ΒΆ

Return output field definitions for Tavily Search API retriever.

Return type:

dict[str, tuple[type, Any]]

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.