openai agents SDK原理详解

openai agents开发新套件:Responses API和Agents SDK

上周manus大火,这周openai也坐不住了。3月12日凌晨,openai推出了新的agent开发套件,包括网页搜索、文件搜索、电脑使用、Responses API等,以及Agents SDK。
在这里插入图片描述

Responses API⁠

Responses API 是 OpenAI 推出的一种新的 API 原语,它结合了 Chat Completions API 的简洁性和 Assistants API 的工具使用能力,旨在帮助开发者更轻松地利用 OpenAI 的内置工具构建agents.
新增Responses API⁠的Built-in tools包括web search、file search、computer use。

  • Web Search:允许模型通过网络搜索获取最新信息,支持 gpt-4o 和 gpt-4o-mini 模型。
  • File Search:支持从大量文档中检索相关信息,支持多种文件类型、查询优化、元数据过滤和自定义重排。
  • Computer Use:基于Computer-Using Agent (CUA) 模型,允许开发者通过模拟鼠标和键盘操作来自动化计算机任务,例如浏览器自动化、数据录入等。

web search

const response = await openai.responses.create({
   
   
    model: "gpt-4o",
    tools: [ {
   
    type: "web_search_preview" } ],
    input: "What was a positive news story that happened today?",
});

console.log(response.output_text);

Web Search 的性能由与 ChatGPT 搜索相同的模型驱动。在 SimpleQA 基准测试中,GPT-4o search preview 和 GPT-4o mini search preview 分别达到了 90% 和 88% 的准确率。
在这里插入图片描述

File search
开发者现在可以利用改进后的文件搜索工具,轻松从海量文档中检索相关信息。该工具支持多种文件类型、查询优化、元数据过滤以及自定义重排,能够快速且准确地返回搜索结果。js的调用代码为:

const productDocs = await openai.vectorStores.create({
   
   
    name: "Product Documentation",
    file_ids: [file1.id, file2.id, file3.id],
});

const response = await openai.responses.create({
   
   
    model: "gpt-4o-mini",
    tools: [{
   
   
        type: "file_search",
        vector_store_ids: [productDocs.id],
    }],
    input: "What is deep research by OpenAI?",
});

console.log(response.output_text);

computer use
Computer Use tool是responses API内置的计算机使用工具,能够捕捉模型生成的鼠标和键盘操作,并将其直接转换为开发者环境中的可执行命令,从而实现计算机任务的自动化。
js调用代码为:

const response = await openai.responses.create({
   
   
    model: "computer-use-preview",
    tools: [{
   
   
        type: "computer_use_preview", # 说明工具类型
        display_width: 1024,
        display_height: 768,
        environment: "browser",
    }],
    truncation: "auto",
    input: "I'm looking for a new camera. Help me find the best one.",
});

console.log(response.output);

该工具由支持 Operator 的相同模型——计算机使用代理(Computer-Using Agent, CUA)模型驱动。这一研究预览模型创造了新的最高水平记录:在 OSWorld上成功率达到 38.1%,在 WebArena 上达到 58.1%,以及在 WebVoyager上达到 87%。
在这里插入图片描述


agents SDK

agents SDK是一个多智能体工作流协作的开源框架,可视为openai去年发布的swarm框架的升级版。
swarm框架的源码讲解可以查看这篇文章OpenAI Swarm框架源码详解及案例实战。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值