pydantic_ai.common_tools
DuckDuckGoResult
Bases: TypedDict
A DuckDuckGo search result.
Source code in pydantic_ai_slim/pydantic_ai/common_tools/duckduckgo.py
24 25 26 27 28 29 30 31 32 | |
DuckDuckGoSearchTool
dataclass
The DuckDuckGo search tool.
Source code in pydantic_ai_slim/pydantic_ai/common_tools/duckduckgo.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
client
instance-attribute
client: DDGS
The DuckDuckGo search client.
max_results
instance-attribute
max_results: int | None
The maximum number of results. If None, returns results only from the first response.
__call__
async
__call__(query: str) -> list[DuckDuckGoResult]
Searches DuckDuckGo for the given query and returns the results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The query to search for. |
required |
Returns:
| Type | Description |
|---|---|
list[DuckDuckGoResult]
|
The search results. |
Source code in pydantic_ai_slim/pydantic_ai/common_tools/duckduckgo.py
50 51 52 53 54 55 56 57 58 59 60 61 | |
duckduckgo_search_tool
duckduckgo_search_tool(
duckduckgo_client: DDGS | None = None,
max_results: int | None = None,
)
Creates a DuckDuckGo search tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
duckduckgo_client
|
DDGS | None
|
The DuckDuckGo search client. |
None
|
max_results
|
int | None
|
The maximum number of results. If None, returns results only from the first response. |
None
|
Source code in pydantic_ai_slim/pydantic_ai/common_tools/duckduckgo.py
64 65 66 67 68 69 70 71 72 73 74 75 | |
TavilySearchResult
Bases: TypedDict
A Tavily search result.
See Tavily Search Endpoint documentation for more information.
Source code in pydantic_ai_slim/pydantic_ai/common_tools/tavily.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
TavilySearchTool
dataclass
The Tavily search tool.
Source code in pydantic_ai_slim/pydantic_ai/common_tools/tavily.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
client
instance-attribute
client: AsyncTavilyClient
The Tavily search client.
__call__
async
__call__(
query: str,
search_deep: Literal["basic", "advanced"] = "basic",
topic: Literal["general", "news"] = "general",
time_range: (
Literal[
"day",
"week",
"month",
"year",
"d",
"w",
"m",
"y",
]
| None
) = None,
) -> list[TavilySearchResult]
Searches Tavily for the given query and returns the results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The search query to execute with Tavily. |
required |
search_deep
|
Literal['basic', 'advanced']
|
The depth of the search. |
'basic'
|
topic
|
Literal['general', 'news']
|
The category of the search. |
'general'
|
time_range
|
Literal['day', 'week', 'month', 'year', 'd', 'w', 'm', 'y'] | None
|
The time range back from the current date to filter results. |
None
|
Returns:
| Type | Description |
|---|---|
list[TavilySearchResult]
|
A list of search results from Tavily. |
Source code in pydantic_ai_slim/pydantic_ai/common_tools/tavily.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
tavily_search_tool
tavily_search_tool(api_key: str)
Creates a Tavily search tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str
|
The Tavily API key. You can get one by signing up at https://app.tavily.com/home. |
required |
Source code in pydantic_ai_slim/pydantic_ai/common_tools/tavily.py
69 70 71 72 73 74 75 76 77 78 79 80 81 | |