OpenAI Agents SDK
智能体应用

OpenAI Agents SDK

是 OpenAI 发布的智能体开发框架,包括联网搜索、文件搜索、计算机使用(Computer Use)以及响应 API 等部分组成。

快点收藏起来

OpenAI Agents SDK 是 OpenAI 发布的开源智能体开发框架,包括联网搜索、文件搜索、计算机使用(Computer Use)以及响应 API 等部分组成。

openai-agents-sdk

核心概念

  1. Agents: LLMs configured with instructions, tools, guardrails, and handoffs
    代理:LLMs 配置了指令、工具、防护措施和交接
  2. Handoffs: Allow agents to transfer control to other agents for specific tasks
    交接:允许代理将控制权转移给其他代理以执行特定任务
  3. Guardrails: Configurable safety checks for input and output validation
    护栏:可配置的安全检查,用于输入和输出验证
  4. 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 环境变量)

相关导航