autogen

其他源码 2025-08-07

重要的是:这是官方项目。我们不隶属于任何叉子或启动。请参阅我们的陈述。

autogen

autogen是创建可以自主行动或与人一起工作的多代理AI应用程序的框架。

安装

autogen需要Python 3.10或更高版本

autogen -ext[openai]"">
 # Install AgentChat and OpenAI client from Extensions
pip install -U " autogen -agentchat " " autogen -ext[openai] "

当前稳定版本为v0.4。如果您正在从autogen V0.2升级,请参阅《迁移指南》,以获取有关如何更新代码和配置的详细说明。

autogen Studio for no-code GUI pip install -U " autogen studio"">
 # Install autogen Studio for no-code GUI
pip install -U " autogen studio " 

Quickstart

你好世界

使用OpenAI的GPT-4O模型创建助理代理。请参阅其他支持的模型。

autogen_agentchat.agents import AssistantAgent from autogen _ext.models.openai import OpenAIChatCompletionClient async def main() -> None: model_client = OpenAIChatCompletionClient(model="gpt-4o") agent = AssistantAgent("assistant", model_client=model_client) print(await agent.run(task="Say 'Hello World!'")) await model_client.close() asyncio.run(main())">
 import asyncio
from autogen _agentchat . agents import AssistantAgent
from autogen _ext . models . openai import OpenAIChatCompletionClient

async def main () -> None :
    model_client = OpenAIChatCompletionClient ( model = "gpt-4o" )
    agent = AssistantAgent ( "assistant" , model_client = model_client )
    print ( await agent . run ( task = "Say 'Hello World!'" ))
    await model_client . close ()

asyncio . run ( main ())

网络浏览代理团队

使用网络冲浪者代理和用于Web浏览任务的用户代理代理创建组聊天团队。您需要安装剧作家。

autogen -ext[openai,web-surfer] # playwright install import asyncio from autogen _agentchat.agents import UserProxyAgent from autogen _agentchat.conditions import TextMentionTermination from autogen _agentchat.teams import RoundRobinGroupChat from autogen _agentchat.ui import Console from autogen _ext.models.openai import OpenAIChatCompletionClient from autogen _ext.agents.web_surfer import MultimodalWebSurfer async def main() -> None: model_client = OpenAIChatCompletionClient(model="gpt-4o") # The web surfer will open a Chromium browser window to perform web browsing tasks. web_surfer = MultimodalWebSurfer("web_surfer", model_client, headless=False, animate_actions=True) # The user proxy agent is used to get user input after each step of the web surfer. # NOTE: you can skip input by pressing Enter. user_proxy = UserProxyAgent("user_proxy") # The termination condition is set to end the conversation when the user types 'exit'. termination = TextMentionTermination("exit", sources=["user_proxy"]) # Web surfer and user proxy take turns in a round-robin fashion. team = RoundRobinGroupChat([web_surfer, user_proxy], termination_condition=termination) try: # Start the team and wait for it to terminate. await Console(team.run_stream(task="Find information about autogen and write a short summary.")) finally: await web_surfer.close() await model_client.close() asyncio.run(main())">
 # pip install -U autogen -agentchat autogen -ext[openai,web-surfer]
# playwright install
import asyncio
from autogen _agentchat . agents import UserProxyAgent
from autogen _agentchat . conditions import TextMentionTermination
from autogen _agentchat . teams import RoundRobinGroupChat
from autogen _agentchat . ui import Console
from autogen _ext . models . openai import OpenAIChatCompletionClient
from autogen _ext . agents . web_surfer import MultimodalWebSurfer

async def main () -> None :
    model_client = OpenAIChatCompletionClient ( model = "gpt-4o" )
    # The web surfer will open a Chromium browser window to perform web browsing tasks.
    web_surfer = MultimodalWebSurfer ( "web_surfer" , model_client , headless = False , animate_actions = True )
    # The user proxy agent is used to get user input after each step of the web surfer.
    # NOTE: you can skip input by pressing Enter.
    user_proxy = UserProxyAgent ( "user_proxy" )
    # The termination condition is set to end the conversation when the user types 'exit'.
    termination = TextMentionTermination ( "exit" , sources = [ "user_proxy" ])
    # Web surfer and user proxy take turns in a round-robin fashion.
    team = RoundRobinGroupChat ([ web_surfer , user_proxy ], termination_condition = termination )
    try :
        # Start the team and wait for it to terminate.
        await Console ( team . run_stream ( task = "Find information about autogen and write a short summary." ))
    finally :
        await web_surfer . close ()
        await model_client . close ()

asyncio . run ( main ())

autogen Studio

使用autogen Studio进行原型制作,并在不编写代码的情况下运行多代理工作流程。

autogen Studio on http://**lo*calhost:8080 autogen studio ui --port 8080 --appdir ./my-app">
 # Run autogen Studio on http://**lo*calhost:8080
autogen studio ui --port 8080 --appdir ./my-app

为什么要使用autogen ?

autogen生态系统提供了创建AI代理,尤其是多代理工作流程(框架,开发人员工具和应用程序)所需的一切。

框架使用分层且可扩展的设计。层明确分配了责任,并在下面的层顶上建立。该设计使您可以在不同级别的抽象级别上使用框架,从高级API到低级组件。

  • Core API实现消息传递,事件驱动的代理以及本地和分布式运行时,以进行灵活性和功率。它还支持.NET和Python的跨语言支持。
  • AgentChat API实现了快速原型制作的更简单但有用的API。该API建立在核心API之上,最接近V0.2的用户熟悉的用户,并支持常见的多代理模式,例如两种代理聊天或组聊天。
  • 扩展API启用第一和第三方扩展,不断扩展框架功能。它支持LLM客户端(例如OpenAI,Azureopenai)的特定实现以及代码执行等功能。

生态系统还支持两个基本开发人员工具

  • autogen Studio提供了用于构建多代理应用程序的无代码GUI。
  • autogen Batch提供了一个用于评估代理性能的基准测试套件。

您可以使用autogen框架和开发人员工具为您的域创建应用程序。例如,Magentic-One是使用AgentChat API和扩展API构建的最先进的多代理团队,可以处理需要Web浏览,代码执行和文件处理的各种任务。

使用autogen您可以加入并为蓬勃发展的生态系统做出贡献。我们每周举办办公时间,并与维护者和社区进行会谈。我们还提供一个用于实时聊天的Discord服务器,QUTHUB讨论问答以及一个用于教程和更新的博客。

接下来去哪里?

安装
Quickstart
教程
API参考
软件包




有兴趣贡献吗?有关如何入门的指南,请参见贡献。我们欢迎各种贡献,包括错误修复,新功能和文档改进。加入我们的社区,帮助我们改善autogen !

有问题吗?查看我们常见问题(FAQ)以获取常见查询的答案。如果您找不到想要的东西,请随时在我们的Github讨论中询问或加入我们的Discord服务器以进行实时支持。您还可以阅读我们的博客以获取更新。

法律通知

Microsoft和任何贡献者在Creative Commons Attribution 4.0国际公共许可证下授予Microsoft文档和该存储库中其他内容的许可证,请参阅许可证文件,并授予您在MIT许可证中的存储库中的任何代码的许可证,请参阅许可证代码文件。

文档中引用的Microsoft,Windows,Microsoft Azure和/或其他Microsoft产品和服务可以是美国和/或其他国家的Microsoft的商标或注册商标。该项目的许可证不授予您使用任何Microsoft名称,徽标或商标的权利。可以在http://go.m**icros*oft.com/fwlink/?linkid=254653上找到Microsoft的一般商标准则。

隐私信息可以在https://go.m*icro**soft.com/fwlink/?linkid=521839中找到

Microsoft和任何贡献者都保留所有其他权利,无论是在各自的版权,专利还是商标下,无论是通过暗示,禁止反言,还是其他权利。

↑回到顶部↑

下载源码

通过命令行克隆项目:

git clone https://github.com/microsoft/autogen.git