|
| 1 | +# Common Tools |
| 2 | + |
1 | 3 | PydanticAI ships with native tools that can be used to enhance your agent's capabilities.
|
2 | 4 |
|
3 | 5 | ## DuckDuckGo Search Tool
|
4 | 6 |
|
5 | 7 | The DuckDuckGo search tool allows you to search the web for information. It is built on top of the
|
6 | 8 | [DuckDuckGo API](https://github.com/deedy5/duckduckgo_search).
|
7 | 9 |
|
| 10 | +### Installation |
| 11 | + |
| 12 | +To use [`duckduckgo_search_tool`][pydantic_ai.common_tools.duckduckgo.duckduckgo_search_tool], you need to install |
| 13 | +[`pydantic-ai-slim`](install.md#slim-install) with the `duckduckgo` optional group: |
| 14 | + |
| 15 | +```bash |
| 16 | +pip/uv-add 'pydantic-ai-slim[duckduckgo]' |
| 17 | +``` |
| 18 | + |
| 19 | +### Usage |
| 20 | + |
| 21 | +Here's an example of how you can use the DuckDuckGo search tool with an agent: |
| 22 | + |
8 | 23 | ```py {title="main.py" test="skip"}
|
9 | 24 | from pydantic_ai import Agent
|
10 | 25 | from pydantic_ai.toolsets.duckduckgo import duckduckgo_search_tool
|
@@ -65,3 +80,62 @@ the 2025 year‑end box‑office tallies are in or to consult a regularly update
|
65 | 80 | Would you like help finding a current source or additional details on where to look for the complete updated list?
|
66 | 81 | """
|
67 | 82 | ```
|
| 83 | + |
| 84 | +## Tavily Search Tool |
| 85 | + |
| 86 | +!!! info |
| 87 | + Tavily is a paid service, but they have free credits to explore their product. |
| 88 | + |
| 89 | + You need to [sign up for an account](https://app.tavily.com/home) and get an API key to use the Tavily search tool. |
| 90 | + |
| 91 | +The Tavily search tool allows you to search the web for information. It is built on top of the [Tavily API](https://tavily.com/). |
| 92 | + |
| 93 | +### Installation |
| 94 | + |
| 95 | +To use [`tavily_search_tool`][pydantic_ai.common_tools.tavily.tavily_search_tool], you need to install |
| 96 | +[`pydantic-ai-slim`](install.md#slim-install) with the `tavily` optional group: |
| 97 | + |
| 98 | +```bash |
| 99 | +pip/uv-add 'pydantic-ai-slim[tavily]' |
| 100 | +``` |
| 101 | + |
| 102 | +### Usage |
| 103 | + |
| 104 | +Here's an example of how you can use the Tavily search tool with an agent: |
| 105 | + |
| 106 | +```py {title="main.py" test="skip"} |
| 107 | +import os |
| 108 | + |
| 109 | +from pydantic_ai.agent import Agent |
| 110 | +from pydantic_ai.common_tools.tavily import tavily_search_tool |
| 111 | + |
| 112 | +api_key = os.getenv('TAVILY_API_KEY') |
| 113 | +assert api_key is not None |
| 114 | + |
| 115 | + |
| 116 | +agent = Agent( |
| 117 | + 'openai:o3-mini', |
| 118 | + tools=[tavily_search_tool(api_key)], |
| 119 | + system_prompt='Search Tavily for the given query and return the results.', |
| 120 | +) |
| 121 | + |
| 122 | +result = agent.run_sync('Tell me the top news in the GenAI world, give me links.') |
| 123 | +print(result.data) |
| 124 | +""" |
| 125 | +Here are some of the top recent news articles related to GenAI: |
| 126 | +
|
| 127 | +1. How CLEAR users can improve risk analysis with GenAI – Thomson Reuters |
| 128 | + Read more: https://legal.thomsonreuters.com/blog/how-clear-users-can-improve-risk-analysis-with-genai/ |
| 129 | + (This article discusses how CLEAR's new GenAI-powered tool streamlines risk analysis by quickly summarizing key information from various public data sources.) |
| 130 | +
|
| 131 | +2. TELUS Digital Survey Reveals Enterprise Employees Are Entering Sensitive Data Into AI Assistants More Than You Think – FT.com |
| 132 | + Read more: https://markets.ft.com/data/announce/detail?dockey=600-202502260645BIZWIRE_USPRX____20250226_BW490609-1 |
| 133 | + (This news piece highlights findings from a TELUS Digital survey showing that many enterprise employees use public GenAI tools and sometimes even enter sensitive data.) |
| 134 | +
|
| 135 | +3. The Essential Guide to Generative AI – Virtualization Review |
| 136 | + Read more: https://virtualizationreview.com/Whitepapers/2025/02/SNOWFLAKE-The-Essential-Guide-to-Generative-AI.aspx |
| 137 | + (This guide provides insights into how GenAI is revolutionizing enterprise strategies and productivity, with input from industry leaders.) |
| 138 | +
|
| 139 | +Feel free to click on the links to dive deeper into each story! |
| 140 | +""" |
| 141 | +``` |
0 commit comments