TavilySearchAPIWrapper#
- class langchain_community.utilities.tavily_search.TavilySearchAPIWrapper[source]#
Bases:
BaseModel
Wrapper for Tavily Search API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- param tavily_api_key: SecretStr [Required]#
- clean_results(results: List[Dict]) List[Dict] [source]#
Clean results from Tavily Search API.
- Parameters:
results (List[Dict])
- Return type:
List[Dict]
- raw_results(query: str, max_results: int | None = 5, search_depth: str | None = 'advanced', include_domains: List[str] | None = [], exclude_domains: List[str] | None = [], include_answer: bool | None = False, include_raw_content: bool | None = False, include_images: bool | None = False) Dict [source]#
- Parameters:
query (str)
max_results (int | None)
search_depth (str | None)
include_domains (List[str] | None)
exclude_domains (List[str] | None)
include_answer (bool | None)
include_raw_content (bool | None)
include_images (bool | None)
- Return type:
Dict
- async raw_results_async(query: str, max_results: int | None = 5, search_depth: str | None = 'advanced', include_domains: List[str] | None = [], exclude_domains: List[str] | None = [], include_answer: bool | None = False, include_raw_content: bool | None = False, include_images: bool | None = False) Dict [source]#
Get results from the Tavily Search API asynchronously.
- Parameters:
query (str)
max_results (int | None)
search_depth (str | None)
include_domains (List[str] | None)
exclude_domains (List[str] | None)
include_answer (bool | None)
include_raw_content (bool | None)
include_images (bool | None)
- Return type:
Dict
- results(query: str, max_results: int | None = 5, search_depth: str | None = 'advanced', include_domains: List[str] | None = [], exclude_domains: List[str] | None = [], include_answer: bool | None = False, include_raw_content: bool | None = False, include_images: bool | None = False) List[Dict] [source]#
Run query through Tavily Search and return metadata.
- Parameters:
query (str) β The query to search for.
max_results (int | None) β The maximum number of results to return.
search_depth (str | None) β The depth of the search. Can be βbasicβ or βadvancedβ.
include_domains (List[str] | None) β A list of domains to include in the search.
exclude_domains (List[str] | None) β A list of domains to exclude from the search.
include_answer (bool | None) β Whether to include the answer in the results.
include_raw_content (bool | None) β Whether to include the raw content in the results.
include_images (bool | None) β Whether to include images in the results.
- Returns:
The query that was searched for. follow_up_questions: A list of follow up questions. response_time: The response time of the query. answer: The answer to the query. images: A list of images. 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.
- Return type:
query
- async results_async(query: str, max_results: int | None = 5, search_depth: str | None = 'advanced', include_domains: List[str] | None = [], exclude_domains: List[str] | None = [], include_answer: bool | None = False, include_raw_content: bool | None = False, include_images: bool | None = False) List[Dict] [source]#
- Parameters:
query (str)
max_results (int | None)
search_depth (str | None)
include_domains (List[str] | None)
exclude_domains (List[str] | None)
include_answer (bool | None)
include_raw_content (bool | None)
include_images (bool | None)
- Return type:
List[Dict]