当前位置: 首页 > news >正文

php网站上传漏洞/网络营销公司

php网站上传漏洞,网络营销公司,网球排名即时最新排名,wordpress fuctionsrag系列文章目录 文章目录 rag系列文章目录前言一、openai agent简介二、openai agent实践总结 前言 2025开年以来,随着deepseek的爆火,大模型以及应用正在快速的迭代。随着一款大模型agent,即manus,横空出世,openai也…

rag系列文章目录

文章目录

  • rag系列文章目录
  • 前言
  • 一、openai agent简介
  • 二、openai agent实践
  • 总结


前言

2025开年以来,随着deepseek的爆火,大模型以及应用正在快速的迭代。随着一款大模型agent,即manus,横空出世,openai也紧接着发布了openai agent,下面主要简要介绍下这个agent。

一、openai agent简介

OpenAI Agent SDK 是一个由 OpenAI 发布的框架,旨在帮助开发者构建多代理 AI 应用。它提供代理(Agents)、交接(Handoffs)和防护栏(Guardrails)等基本组件,支持创建复杂的多代理工作流,如客户支持系统或任务路由系统。它轻量级,易于学习,适合快速原型开发和生产环境。

与其他 AI 代理框架(如 LangChain 和 LlamaIndex)相比,OpenAI Agent SDK 有以下不同:

• 多代理协作:特别强调代理之间的交接,适合需要分工的场景,如 triage 代理路由任务。LangChain 和 LlamaIndex 更注重单个代理的功能扩展。
• 简单性:提供少量抽象,学习曲线低,相比 LangChain 的丰富功能更易上手。
• 内置追踪:自带追踪功能,方便调试,LangChain 和 LlamaIndex 可能需额外配置。

二、openai agent实践

1.工具调用
Agent基本的功能就是工具调用,以下是openai agent的工具调用,和langchain的工具调用有类似之处。

import agents
from agents import Agent, Runner, function_tool, handoff, OpenAIChatCompletionsModel@function_tool
def web_search(query: str) -> str:"""Simulate a web search for the given query."""# In a real application, this would call a web search APIwith agents.custom_span("WebSearch"):  # Add a custom span for tracing this actionreturn f"Web search results for '{query}': [Sample result 1, Sample result 2]"@function_tool
def get_weather(city: str) -> str:"""Fetch the weather for a given city."""# Placeholder for a real API callprint("---------------------------")return f"The weather in {city} is sunny."

2.大模型
大模型是agent的大脑,这里定义大模型的client,在创建agent时可以引用这个client。

from openai import AsyncOpenAIopenai_client = AsyncOpenAI(api_key="sk-S",base_url="https://ss/v1"
)

3.构建agent
这里构建了一个天气agent,负责处理天气相关的工作。

weather_agent = Agent(name="Weather Assistant",instructions="Help users with weather queries.",model=OpenAIChatCompletionsModel(openai_client=openai_client,model="gpt-4o-2024-05-13"), tools=[get_weather]
)

4.handoff
openai agent的一大亮点就是多个agent之间的交接,如下所示,有一个专门负责处理天气问题的agent,主agent需要做天气相关的工作时,可以把它交接给天气agent处理,这个agent进行tool调用查询天气情况。

# Create the main support agent with tools and handoff
main_agent = Agent(name="SupportAssistant",instructions=("You are a customer support assistant. Answer user queries and use the web search tool ""when needed. For get weather , hand off to Weather Assistant."),tools=[web_search],  # Equip the agent with the web search toolhandoffs=[handoff(weather_agent)],  # Configure handoff to the specialized agentmodel=OpenAIChatCompletionsModel(openai_client=openai_client,model="gpt-4o-2024-05-13")
)

5.agent执行
以下是agent开始启动执行的代码,agent的整个执行过程,可以开启日志,详细观察里面的调用过程。

# Enable verbose logging to see detailed output in the console
agents.enable_verbose_stdout_logging()if __name__ == '__main__':# Run the agent synchronously with a sample input and handle exceptionstry:with agents.trace("CustomerSupportQuery"):  # Start a trace to monitor the entire operationresult = Runner.run_sync(main_agent, "What's the weather in Paris?")print("Final Output:", result.final_output)  # Print the agent's responseexcept agents.InputGuardrailTripwireTriggered as e:print("Input was rejected by guardrail:", e)except agents.OutputGuardrailTripwireTriggered as e:print("Output was rejected by guardrail:", e)except agents.MaxTurnsExceeded:print("Agent exceeded maximum turns.")except agents.ModelBehaviorError as e:print("Model produced an invalid response:", e)except agents.AgentsException as e:print("An error occurred:", e)

总结

OpenAI Agent是一个轻量级框架,适合构建多代理 AI 应用,强调简单性和协作,没有langchain复杂。虽然很多功能还不是特别成熟完善,但是它在快速发展,相信更多的人后面会使用它。

http://www.whsansanxincailiao.cn/news/31954710.html

相关文章:

  • 自己怎么1做网站/百度识图软件
  • 做网站需要空间/seo刷关键词排名免费
  • 镇江做网站的/谷歌手机版浏览器官网
  • 网站的宣传方法有哪些/如何在网上推广自己的产品
  • wordpress 浏览器上显示错位/seo工具不包括
  • 深圳软件定制开发服务/长沙seo咨询
  • 东莞微网站制作/如何制作一个自己的网站
  • 网站产品关键词导出/市场调研报告万能模板
  • 餐饮手机微网站怎么做/网址生成短链接
  • 做宣传片的网站/广告优化师的工作内容
  • 做网站用别人图片文章会侵权吗/网站搜索引擎优化案例
  • ccd深圳设计公司/石家庄网站建设seo
  • 快印店网站建设84wzjs/近期国内外重大新闻10条
  • 河南南阳最新消息今天/seo网络优化师招聘
  • 广告网站建设公司/国外推广渠道平台
  • 花店网站建设课程设计论文/在线工具
  • 网站维护提醒php文件/百度公司怎么样
  • 网络营销推广方法工具/济南网站seo哪家公司好
  • 免费申请电信卡/南昌seo优化公司
  • 驻马店哪里做网站/查看网站流量的工具
  • 微信公众平台推广网站/百度seo搜索引擎优化厂家
  • 做服装网站需要什么条件/网络营销 长沙
  • 网站建设和前端开发的区别/百度权重
  • 北京好网站制作公司/关键词查询工具有哪些
  • 重庆外贸网站建设公司/我要推广网
  • 牛商网建设的食品网站/外贸网站推广怎么做
  • 备案 网站名称 重复/网络营销中的seo是指
  • 河北 网站建设/2022最新国际新闻10条简短
  • 什么网站可以在线做考教师岗位的题/网络营销渠道策略
  • 广告策划活动公司/北京债务优化公司