
OpenAI Agents SDK 是 OpenAI 发布的开源智能体开发框架,包括联网搜索、文件搜索、计算机使用(Computer Use)以及响应 API 等部分组成。
核心概念
- Agents: LLMs configured with instructions, tools, guardrails, and handoffs
代理:LLMs 配置了指令、工具、防护措施和交接 - Handoffs: Allow agents to transfer control to other agents for specific tasks
交接:允许代理将控制权转移给其他代理以执行特定任务 - Guardrails: Configurable safety checks for input and output validation
护栏:可配置的安全检查,用于输入和输出验证 - Tracing: Built-in tracking of agent runs, allowing you to view, debug and optimize your workflows
跟踪:内置的代理运行跟踪,允许您查看、调试和优化您的工作流程
如何使用
1.设置您的 Python 环境
python -m venv env source env/bin/activate
2.安装 Agents SDK
pip install openai-agents
3.你好世界示例
from agents import Agent, Runner agent = Agent(name="Assistant", instructions="You are a helpful assistant") result = Runner.run_sync(agent, "Write a haiku about recursion in programming.") print(result.final_output) # Code within the code, # Functions calling themselves, # Infinite loop's dance.
(如果运行此程序,请确保设置 OPENAI_API_KEY 环境变量)
本文采用 CC BY-NC 4.0 许可协议。商业转载、引用请联系本站获得授权,非商业转载、引用须注明出处。
链接:https://appmark.cn/sites/openai-agents-sdk.html -APPMARK
OWL 是一个优化劳动力学习的通用智能体,用于处理现实世界的自动化任务。