공용 툴
공용 툴
Pydantic AI는 에이전트의 기능을 확장하는 공용 툴들과 함께 제공돼요.
출처: 문서
본문
DuckDuckGo 검색 툴
DuckDuckGo 검색 툴은 웹에서 정보를 검색할 수 있게 해줘요. DuckDuckGo API 위에 구축돼 있어요.
설치
duckduckgo_search_tool을 쓰려면 pydantic-ai-slim을 duckduckgo 옵션 그룹과 함께 설치해야 해요:
pip install "pydantic-ai-slim[duckduckgo]"
uv add "pydantic-ai-slim[duckduckgo]"
사용법
에이전트와 함께 DuckDuckGo 검색 툴을 사용하는 예시:
from pydantic_ai import Agent
from pydantic_ai.common_tools.duckduckgo import duckduckgo_search_tool
agent = Agent(
'openai:gpt-5.2',
tools=[duckduckgo_search_tool()],
instructions='Search DuckDuckGo for the given query and return the results.',
)
result = agent.run_sync(
'Can you list the top five highest-grossing animated films of 2025?'
)
print(result.output)
"""
I looked into several sources on animated box‐office performance in 2025, and while detailed
rankings can shift as more money is tallied, multiple independent reports have already
highlighted a couple of record‐breaking shows. For example:
• Ne Zha 2 - News outlets (Variety, Wikipedia's "List of animated feature films of 2025", and others)
have reported that this Chinese title not only became the highest‑grossing animated film of 2025
but also broke records as the highest‑grossing non‑English animated film ever. One article noted
its run exceeded US$1.7 billion.
• Inside Out 2 - According to data shared on Statista and in industry news, this Pixar sequel has been
on pace to set new records (with some sources even noting it as the highest‑grossing animated film
ever, as of January 2025).
Beyond those two, some entertainment trade sites (for example, a Just Jared article titled
"Top 10 Highest-Earning Animated Films at the Box Office Revealed") have begun listing a broader
top‑10. Although full consolidated figures can sometimes differ by source and are updated daily during
a box‑office run, many of the industry trackers have begun to single out five films as the biggest
earners so far in 2025.
Unfortunately, although multiple articles discuss the "top animated films" of 2025, there isn't yet a
single, universally accepted list with final numbers that names the complete top five. (Box‑office
rankings, especially mid‑year, can be fluid as films continue to add to their totals.)
Based on what several sources note so far, the two undisputed leaders are:
1. Ne Zha 2
2. Inside Out 2
The remaining top spots (3-5) are reported by some outlets in their "Top‑10 Animated Films"
lists for 2025 but the titles and order can vary depending on the source and the exact cut‑off
date of the data. For the most up‑to‑date and detailed ranking (including the 3rd, 4th, and 5th
highest‑grossing films), I recommend checking resources like:
• Wikipedia's "List of animated feature films of 2025" page
• Box‑office tracking sites (such as Box Office Mojo or The Numbers)
• Trade articles like the one on Just Jared
To summarize with what is clear from the current reporting:
1. Ne Zha 2
2. Inside Out 2
3-5. Other animated films (yet to be definitively finalized across all reporting outlets)
If you're looking for a final, consensus list of the top five, it may be best to wait until
the 2025 year‑end box‑office tallies are in or to consult a regularly updated entertainment industry source.
Would you like help finding a current source or additional details on where to look for the complete updated list?
"""
웹 페치 툴
웹 페치 툴은 에이전트가 웹 페이지의 콘텐츠를 가져와 마크다운으로 변환하게 해줘요. 서버 측 요청 위조(SSRF) 공격을 막기 위해 SSRF 보호를 사용해요.
설치
web_fetch_tool을 쓰려면 pydantic-ai-slim을 web-fetch 옵션 그룹과 함께 설치해야 해요:
pip install "pydantic-ai-slim[web-fetch]"
uv add "pydantic-ai-slim[web-fetch]"
사용법
에이전트와 함께 웹 페치 툴을 사용하는 예시:
from pydantic_ai import Agent
from pydantic_ai.common_tools.web_fetch import web_fetch_tool
agent = Agent(
'openai:gpt-5.2',
tools=[web_fetch_tool()],
instructions='Fetch web pages and summarize their content.',
)
result = agent.run_sync('What is on https://ai.pydantic.dev?')
print(result.output)
WebFetch 기능을 통한 자동 폴백
web_fetch_tool을 직접 사용할 필요는 없어요. WebFetch 기능이 모델이 네이티브 URL 페치를 지원하지 않을 때 자동으로 그것을 로컬 폴백으로 사용해요.
기본적으로 툴은 반환되는 텍스트를 50,000자(max_content_length), 다운로드되는 응답 본문을 50 MiB(max_download_bytes)로 상한을 둬요. 어느 한도를 무효화하려면 None을 전달하세요.
headers의 자격증명
web_fetch_tool(headers=...)로 구성한 헤더는 모델이 URL을 선택하므로 모델이 요청하는 어떤 URL로든 보내져요. Authorization 같은 자격증명을 구성한다면 allowed_domains로 어떤 호스트가 받을 수 있는지 제한하고, 도메인 필터는 호스트네임만 일치시킨다는 점을 명심하세요. 모델은 허용된 호스트의 평범한 http://나 비표준 포트로도 자격증명을 보낼 수 있어요. 리다이렉트에서 구성된 민감 헤더(Authorization, Cookie, Proxy-Authorization)는 리다이렉트가 같은 오리진(스킴, 호스트, 포트)에 머물거나 같은 호스트의 기본 포트에서 http에서 https로 업그레이드할 때만 전달되고, 다른 리다이렉트에서는 제거돼요.
Tavily 검색 툴
참고
Tavily는 유료 서비스지만 제품을 탐색할 수 있는 무료 크레딧이 있어요.
Tavily 검색 툴을 쓰려면 계정에 가입하고 API 키를 받아야 해요.
Tavily 검색 툴은 웹에서 정보를 검색할 수 있게 해줘요. Tavily API 위에 구축돼 있어요.
설치
tavily_search_tool을 쓰려면 pydantic-ai-slim을 tavily 옵션 그룹과 함께 설치해야 해요:
pip install "pydantic-ai-slim[tavily]"
uv add "pydantic-ai-slim[tavily]"
사용법
에이전트와 함께 Tavily 검색 툴을 사용하는 예시:
import os
from pydantic_ai import Agent
from pydantic_ai.common_tools.tavily import tavily_search_tool
api_key = os.getenv('TAVILY_API_KEY')
assert api_key is not None
agent = Agent(
'openai:gpt-5.2',
tools=[tavily_search_tool(api_key)],
instructions='Search Tavily for the given query and return the results.',
)
result = agent.run_sync('Tell me the top news in the GenAI world, give me links.')
print(result.output)
"""
Here are some of the top recent news articles related to GenAI:
1. How CLEAR users can improve risk analysis with GenAI - Thomson Reuters
Read more: https://legal.thomsonreuters.com/blog/how-clear-users-can-improve-risk-analysis-with-genai/
(This article discusses how CLEAR's new GenAI-powered tool streamlines risk analysis by quickly summarizing key information from various public data sources.)
2. TELUS Digital Survey Reveals Enterprise Employees Are Entering Sensitive Data Into AI Assistants More Than You Think - FT.com
Read more: https://markets.ft.com/data/announce/detail?dockey=600-202502260645BIZWIRE_USPRX____20250226_BW490609-1
(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.)
3. The Essential Guide to Generative AI - Virtualization Review
Read more: https://virtualizationreview.com/Whitepapers/2025/02/SNOWFLAKE-The-Essential-Guide-to-Generative-AI.aspx
(This guide provides insights into how GenAI is revolutionizing enterprise strategies and productivity, with input from industry leaders.)
Feel free to click on the links to dive deeper into each story!
"""
매개변수 구성
tavily_search_tool 팩토리는 검색 동작을 제어하는 선택적 매개변수를 받아요. max_results는 항상 개발자가 제어하고 LLM 툴 스키마에 절대 나타나지 않아요. 제공되면 다른 매개변수는 모든 검색에 고정되고 LLM의 툴 스키마에서 숨겨져요. 설정하지 않은 매개변수는 LLM이 호출별로 설정할 수 있게 남아요.
예를 들어 툴 생성 시 max_results와 include_domains를 고정하면서 LLM이 exclude_domains를 제어하게 둘 수 있어요:
import os
from pydantic_ai import Agent
from pydantic_ai.common_tools.tavily import tavily_search_tool
api_key = os.getenv('TAVILY_API_KEY')
assert api_key is not None
agent = Agent(
'openai:gpt-5.2',
tools=[tavily_search_tool(api_key, max_results=5, include_domains=['arxiv.org'])],
instructions='Search for information and return the results.',
)
result = agent.run_sync(
'Find recent papers about transformer architectures'
)
print(result.output)
"""
Here are some recent papers about transformer architectures from arxiv.org:
1. "Attention Is All You Need" - The foundational paper on the Transformer model.
2. "FlashAttention: Fast and Memory-Efficient Exact Attention" - Proposes an IO-aware attention algorithm.
"""
Exa 검색 툴
Deprecated
Exa 공용 툴(exa_search_tool, exa_find_similar_tool, exa_get_contents_tool, exa_answer_tool, ExaToolset)은 deprecated이며 v3에서 제거될 거예요.
대신 Pydantic AI Harness의 ExaSearch 기능을 사용하세요. 웹 검색, 전체 페이지 검색, 딥 검색, 장기 실행 리서치를 위한 ExaAgent 기능을 묶어요:
pip install "pydantic-ai-harness[exa]"
uv add "pydantic-ai-harness[exa]"
from pydantic_ai_harness.exa import ExaSearch
from pydantic_ai import Agent
agent = Agent('openai:gpt-5.2', capabilities=[ExaSearch()])
result = agent.run_sync('What are the latest developments in quantum computing?')
print(result.output)