链载Ai

标题: 微软:探索AI Agent框架 [打印本页]

作者: 链载Ai    时间: 1 小时前
标题: 微软:探索AI Agent框架

AI Agent框架是为简化AI Agent的创建、部署和管理而设计的软件平台。这些框架为开发人员提供了预构建的组件、抽象和工具,以简化复杂AI系统的开发。

这些框架通过为常见的AI Agent开发挑战提供标准化的方法,帮助开发人员专注于其应用程序的独特方面。它们增强了构建AI系统的可扩展性、可访问性和效率。

涵盖以下内容:

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: center;">AI Agent框架是什么,能够做什么?

传统的AI框架可以帮助将AI集成到应用程序中,并通过以下方式提升这些应用程序的性能:

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: left;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;">为什么需要AI Agent框架呢?

AI Agent框架不仅仅是AI框架。它们旨在实现能够与用户、其他Agent和环境交互以实现特定目标的智能Agent。这些Agent可以表现出自主行为,做出决策,并适应变化的条件。让我们来看看AI Agent框架所支持的一些关键能力:

总之,Agent使能够做更多事情,将自动化提升到更高层次,创建能够适应并从环境中学习的更智能系统。

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: center;">如何快速原型设计、迭代并提升Agent的能力?

这是一个快速发展的领域,但大多数AI Agent框架有一些共同点,可以帮助快速原型设计和迭代,即模块化组件、协作工具和实时学习。让我们深入探讨这些内容:

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: left;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;">使用模块化组件

像LangChain和Microsoft Semantic Kernel这样的框架提供了预构建的组件,例如提示、解析器和内存管理。

团队如何使用这些组件:团队可以快速组装这些组件,无需从头开始,从而实现快速实验和迭代。

实际操作方式:可以使用预构建的解析器从用户输入中提取信息,使用内存模块存储和检索数据,以及使用提示生成器与用户交互,而无需从头构建这些组件。

示例代码。让我们看看如何使用预构建的解析器从用户输入中提取信息:

// Semantic Kernel example
ChatHistory chatHistory = [];chatHistory.AddUserMessage("I'd like to go To New York");
// Define a plugin that contains the function to book travelpublicclassBookTravelPlugin( IPizzaService pizzaService, IUserContext userContext, IPaymentService paymentService){
[KernelFunction("book_flight")] [Description("Book travel given location and date")] publicasyncTask<Booking> BookFlight( DateTime date, string location, ) { // book travel given date,location }}
IKernelBuilder kernelBuilder = new KernelBuilder();kernelBuilder..AddAzureOpenAIChatCompletion( deploymentName:"NAME_OF_YOUR_DEPLOYMENT", apiKey:"YOUR_API_KEY", endpoint:"YOUR_AZURE_ENDPOINT");kernelBuilder.Plugins.AddFromType<BookTravelPlugin>("BookTravel");Kernel kernel = kernelBuilder.Build();
/*Behind the scenes, it recognizes the tool to call, what arguments it already has (location)andwhat it needs (date){
"tool_calls": [ { "id":"call_abc123", "type":"function", "function": { "name":"BookTravelPlugin-book_flight", "arguments":"{\n\"location\": \"New York\",\n\"date\": \"\"\n}" } }]*/
ChatResponse response =awaitchatCompletion.GetChatMessageContentAsync( chatHistory, executionSettings: openAIPromptExecutionSettings, kernel: kernel)

Console.WriteLine(response);chatHistory.AddAssistantMessage(response);
// AI Response:"Before I can book your flight, I need to know your departure date. When are you planning to travel?"// Thatis,inthe previous code it figures out the tool to call, what arguments it already has (location)andwhat it needs (date)fromthe userinput, at this point it ends up asking the userforthe missing information
从这个示例中,可以看到如何利用预构建的解析器从用户输入中提取关键信息,例如航班预订请求的出发地、目的地和日期。这种模块化方法使能够专注于高层次的逻辑。

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: left;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;">利用协作工具

像CrewAI和Microsoft AutoGen这样的框架促进了多个Agent的创建,这些Agent可以协同工作。
团队如何使用这些工具:团队可以设计具有特定角色和任务的Agent,使它们能够测试和优化协作工作流程,从而提升整体系统效率。
实际操作方式:可以创建一个Agent团队,每个Agent都有专门的功能,例如数据检索、分析或决策。这些Agent可以通信和共享信息以实现共同目标,例如回答用户查询或完成任务。
示例代码(AutoGen):
# creating agents,thencreatea round robin schedulewherethey can work together,inthiscaseinorder
# Data Retrieval Agent# Data Analysis Agent# Decision Making Agent
agent_retrieve=AssistantAgent( name="dataretrieval", model_client=model_client, tools=[retrieve_tool], system_message="Use tools to solve tasks.")
agent_analyze=AssistantAgent( name="dataanalysis", model_client=model_client, tools=[analyze_tool], system_message="Use tools to solve tasks.")
# conversation endswhenusersays "APPROVE"termination=TextMentionTermination("APPROVE")
user_proxy=UserProxyAgent("user_proxy", input_func=input)
team=RoundRobinGroupChat([agent_retrieve, agent_analyze, user_proxy], termination_condition=termination)
stream=team.run_stream(task="Analyze data", max_turns=10)# Use asyncio.run(...)whenrunningina script.await Console(stream)
在之前的代码中,可以看到如何创建一个涉及多个Agent协同工作的任务,以分析数据。每个Agent执行特定功能,通过协调Agent来实现期望的结果。通过创建具有专门角色的专用Agent,可以提升任务的效率和性能。
实时学习
先进的框架提供了实时上下文理解和适应的能力。
团队如何使用这些能力:团队可以实现反馈循环,Agent可以从交互中学习并动态调整其行为,从而实现能力的持续改进和优化。
实际操作方式:Agent可以分析用户反馈、环境数据和任务结果,更新其知识库,调整决策算法,并随着时间的推移提升性能。这种迭代学习过程使Agent能够适应变化的条件和用户偏好,提升整体系统的有效性。
AutoGen、Semantic Kernel与Azure AI Agent Service区别
这些框架听起来确实有很多重叠之处,但在设计、功能和目标用例方面存在一些关键差异:
仍然不确定该选择哪一个?
使用场景
让我们通过一些常见使用场景来帮助您做出选择:
让我们用表格总结一下这些框架的关键差异:
ingFang SC", MIUI, "Hiragino Sans GB", "Microsoft YaHei", sans-serif;font-optical-sizing: inherit;font-kerning: inherit;font-feature-settings: inherit;font-variation-settings: inherit;vertical-align: baseline;border-collapse: collapse;border-spacing: 0px;display: block;width: max-content;overflow: auto;border-radius: 12px;color: rgba(245, 249, 255, 0.95);letter-spacing: 0.5px;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(49, 49, 58);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;">
框架
重点
核心概念
使用场景
AutoGen
事件驱动的分布式Agent应用
Agent、角色、功能、数据
代码生成、数据分析任务
Semantic Kernel
理解和生成类似人类的文本内容
Agent、模块化组件、协作
自然语言理解、内容生成
Azure AI Agent服务
灵活的模型、企业级安全、代码生成、工具调用
模块化、协作、流程编排
安全、可扩展且灵活的AI Agent部署

这些框架的理想使用场景是什么?


https://github.com/microsoft/ai-agents-for-beginners/tree/main






欢迎光临 链载Ai (https://www.lianzai.com/) Powered by Discuz! X3.5