Skip to content

Adapter

TAVILY_API_URL = 'https://api.tavily.com' module-attribute

logger = logging.getLogger(__name__) module-attribute

FakeTavilyClient

Bases: MyTavilyClient

tavily_client = None class-attribute instance-attribute

raw_results_async(query, max_results=5, search_depth='advanced', include_domains=None, exclude_domains=None, include_answer=False, include_raw_content=False, include_images=False) async

MyTavilyClient

Bases: BaseModel

Wrapper for Tavily Search API.

2024-10-09 -- Modified from the langchain_community implementation, but uses the tavily implementation.

model_config = ConfigDict(extra='forbid', arbitrary_types_allowed=True) class-attribute instance-attribute

tavily_client instance-attribute

clean_results(results, as_dicts=False) staticmethod

Clean results from Tavily Search API.

raw_results_async(query, max_results=5, search_depth='advanced', include_domains=None, exclude_domains=None, include_answer=False, include_raw_content=False, include_images=False) async

Get results from the Tavily Search API asynchronously.

results_async(query, max_results=5, search_depth='advanced', include_domains=None, exclude_domains=None, include_answer=False, include_raw_content=False, include_images=False) async

Run query through Tavily Search and return metadata.

PARAMETER DESCRIPTION
query

The query to search for.

TYPE: str

max_results

The maximum number of results to return.

TYPE: int DEFAULT: 5

search_depth

The depth of the search. Can be "basic" or "advanced".

TYPE: Literal['basic', 'advanced'] DEFAULT: 'advanced'

include_domains

A list of domains to include in the search.

TYPE: list[str] | None DEFAULT: None

exclude_domains

A list of domains to exclude from the search.

TYPE: list[str] | None DEFAULT: None

include_answer

Whether to include the answer in the results.

TYPE: bool DEFAULT: False

include_raw_content

Whether to include the raw content in the results.

TYPE: bool DEFAULT: False

include_images

Whether to include images in the results.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
query

The query that was searched for.

TYPE: list[TavilyCleanedResult]

follow_up_questions

A list of follow-up questions.

TYPE: list[TavilyCleanedResult]

response_time

The response time of the query.

TYPE: list[TavilyCleanedResult]

answer

The answer to the query.

TYPE: list[TavilyCleanedResult]

images

A list of images.

TYPE: list[TavilyCleanedResult]

results

A list of dictionaries containing the results: title: The title of the result. url: The url of the result. content: The content of the result. score: The score of the result. raw_content: The raw content of the result.

TYPE: list[TavilyCleanedResult]

TavilyCleanedResult

Bases: BaseModel

content instance-attribute

url instance-attribute

TavilyResult

Bases: BaseModel

content instance-attribute

published_date = None class-attribute instance-attribute

raw_content = None class-attribute instance-attribute

score instance-attribute

title instance-attribute

url instance-attribute

TavilySearchResult

Bases: BaseModel

answer = None class-attribute instance-attribute

follow_up_questions = None class-attribute instance-attribute

images = [] class-attribute instance-attribute

query instance-attribute

response_time instance-attribute

results instance-attribute