Tools
Tavily
TavilyTools enable an Agent to search the web using the Tavily API.
Prerequisites
The following examples requires the tavily-python
library and an API key from Tavily.
Example
The following agent will run a search on Tavily for “language models” and print the response.
cookbook/tools/tavily_tools.py
Toolkit Params
Parameter | Type | Default | Description |
---|---|---|---|
api_key | str | - | API key for authentication. If not provided, will check TAVILY_API_KEY environment variable. |
search | bool | True | Enables search functionality. |
max_tokens | int | 6000 | Maximum number of tokens to use in search results. |
include_answer | bool | True | Whether to include an AI-generated answer summary in the response. |
search_depth | Literal['basic', 'advanced'] | 'advanced' | Depth of search - ‘basic’ for faster results or ‘advanced’ for more comprehensive search. |
format | Literal['json', 'markdown'] | 'markdown' | Output format - ‘json’ for raw data or ‘markdown’ for formatted text. |
use_search_context | bool | False | Whether to use Tavily’s search context API instead of regular search. |
Toolkit Functions
Function | Description |
---|---|
web_search_using_tavily | Searches the web for a query using Tavily API. Takes a query string and optional max_results parameter (default 5). Returns results in specified format with titles, URLs, content and relevance scores. |
web_search_with_tavily | Alternative search function that uses Tavily’s search context API. Takes a query string and returns contextualized search results. Only available if use_search_context is True. |
Information
- View on Github