pydantic_ai.builtin_tools
AbstractBuiltinTool dataclass
基类:ABC
一个可供代理(agent)使用的内置工具。
此类是抽象的,不能直接实例化。
内置工具作为 ModelRequestParameters
的一部分传递给模型。
源代码位于 pydantic_ai_slim/pydantic_ai/builtin_tools.py
12 13 14 15 16 17 18 19 |
|
WebSearchTool dataclass
一个内置工具,允许您的代理在网络上搜索信息。
PydanticAI 传递的参数取决于模型,因为某些模型可能不支持某些参数。
支持的模型: * Anthropic * OpenAI * Groq * Google
源代码位于 pydantic_ai_slim/pydantic_ai/builtin_tools.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 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 67 68 69 70 71 72 73 74 75 |
|
search_context_size class-attribute
instance-attribute
search_context_size: Literal["low", "medium", "high"] = (
"medium"
)
search_context_size
参数控制从网络检索多少上下文来帮助工具形成响应。
支持的模型: * OpenAI
user_location class-attribute
instance-attribute
user_location: WebSearchUserLocation | None = None
user_location
参数允许您根据用户的位置对搜索结果进行本地化。
支持的模型: * Anthropic * OpenAI
blocked_domains class-attribute
instance-attribute
如果提供,这些域名将永远不会出现在结果中。
对于 Anthropic,您只能使用 blocked_domains
或 allowed_domains
中的一个,不能同时使用两者。
支持的模型: * Anthropic (https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool#domain-filtering) * Groq (https://console.groq.com/docs/agentic-tooling#search-settings)
allowed_domains class-attribute
instance-attribute
如果提供,结果中将只包含这些域名。
对于 Anthropic,您只能使用 blocked_domains
或 allowed_domains
中的一个,不能同时使用两者。
支持的模型: * Anthropic (https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool#domain-filtering) * Groq (https://console.groq.com/docs/agentic-tooling#search-settings)
max_uses class-attribute
instance-attribute
max_uses: int | None = None
如果提供,该工具将在达到给定的使用次数后停止网络搜索。
支持的模型: * Anthropic
WebSearchUserLocation
基类:TypedDict
允许您根据用户的位置对搜索结果进行本地化。
支持的模型: * Anthropic * OpenAI
源代码位于 pydantic_ai_slim/pydantic_ai/builtin_tools.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
CodeExecutionTool dataclass
一个内置工具,允许您的代理执行代码。
支持的模型: * Anthropic * OpenAI * Google
源代码位于 pydantic_ai_slim/pydantic_ai/builtin_tools.py
99 100 101 102 103 104 105 106 |
|
UrlContextTool dataclass
允许您的代理访问 URL 的内容。
支持的模型: * Google
源代码位于 pydantic_ai_slim/pydantic_ai/builtin_tools.py
109 110 111 112 113 114 |
|