英文文档原文详见 OpenAI Agents SDK
https://openai.github.io/openai-agents-python/
本文是OpenAI-agents-sdk-python使用翻译软件翻译后的中文文档/教程。分多个帖子发布,帖子的目录如下:
(2)OpenAI agents sdk, agents,运行agents,结果,流,工具,交接
(3) OpenAi agents sdk, 跟踪,上下文管理,护栏
(4) Openai agents sdk, 编排多个代理,模型,配置SDK
(5)(6)..等等,后面的都放到openai agents sdk的这个专栏
https://blog.youkuaiyun.com/wtsolutions/category_12916751.html里面了,大家可以到专栏里面看到所有的目录,欢迎订阅这个专栏。
Tools
工具 module-attribute
Tool = Union[
FunctionTool,
FileSearchTool,
WebSearchTool,
ComputerTool,
]
可在代理中使用的工具。
FunctionTool 数据类
包装函数的工具。在大多数情况下,您应该使用帮助程序来 创建一个 FunctionTool,因为它们让你可以轻松地包装一个 Python 函数。function_tool
src/agents/tool.py
name 实例属性
name: str
工具的名称,如 LLM 所示。通常是函数的名称。
描述 instance-attribute
description: str
工具的描述,如 LLM 所示。
params_json_schema instance-attribute
params_json_schema: dict[str, Any]
工具参数的 JSON 架构。
on_invoke_tool instance-attribute
on_invoke_tool: Callable[
[RunContextWrapper[Any], str], Awaitable[str]
]
使用给定上下文和参数调用工具的函数。传递的参数 是: 1. 工具运行上下文。 2. 来自 LLM 的参数,以 JSON 字符串形式。
您必须返回工具输出的字符串表示。如果出现错误,您可以执行以下任一作 引发 Exception (这将导致运行失败) 或返回字符串错误消息 (该 将被发送回 LLM)。
strict_json_schema 类属性 instance-attribute
strict_json_schema: bool = True
JSON 架构是否处于严格模式。我们强烈建议将此设置为 True, 因为它增加了正确 JSON 输入的可能性。
FileSearchTool 数据类
一个托管工具,允许 LLM 在向量存储中进行搜索。目前仅支持 OpenAI 模型,使用响应 API。
源码src/agents/tool.py
vector_store_ids instance-attribute
vector_store_ids: list[str]
要搜索的向量存储的 ID。
max_num_results 类属性 instance-attribute
max_num_results: int | None = None
要返回的最大结果数。
include_search_results 类属性实例属性
include_search_results: bool = False
是否将搜索结果包含在 LLM 生成的输出中。
ranking_options 类属性 instance-attribute
ranking_options: RankingOptions | None = None
搜索的排名选项。
filters 类-属性 instance-attribute
filters: Filters | None = None

最低0.47元/天 解锁文章
940

被折叠的 条评论
为什么被折叠?



