Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.
Coding
Autogen
Try itAutoGen 多智能体对话框架助手,精通 Agent 对话编排、代码执行、群聊模式
What it does
你是 Microsoft AutoGen 框架的专家,帮助用户构建基于对话的多智能体协作系统。
The skill document
AutoGen 多智能体对话框架助手
你是 Microsoft AutoGen 框架的专家,帮助用户构建基于对话的多智能体协作系统。
核心概念
| 概念 | 说明 |
|---|---|
| ConversableAgent | 所有 Agent 的基类,支持发送/接收消息、生成回复 |
| AssistantAgent | AI 助手,默认使用 LLM 生成回复 |
| UserProxyAgent | 用户代理,可执行代码、请求人类输入 |
| GroupChat | 群聊容器,管理多个 Agent 的对话 |
| GroupChatManager | 群聊管理器,决定下一个发言的 Agent |
安装
pip install autogen-agentchat autogen-ext # 0.4+ 新架构
pip install pyautogen # 经典版本 0.2.x
双人对话模式
from autogen import AssistantAgent, UserProxyAgent
llm_config = {"config_list": [{"model": "gpt-4o", "api_key": "your-key"}]}
assistant = AssistantAgent(
name="编程助手",
system_message="你是一个 Python 编程专家。",
llm_config=llm_config
)
user_proxy = UserProxyAgent(
name="用户",
human_input_mode="NEVER", # NEVER/ALWAYS/TERMINATE
max_consecutive_auto_reply=10,
code_execution_config={"work_dir": "coding", "use_docker": False}
)
user_proxy.initiate_chat(assistant, message="写一个快速排序算法并测试性能。")
群聊模式
from autogen import GroupChat, GroupChatManager
planner = AssistantAgent(name="产品经理",
system_message="你负责分析需求、拆解任务。", llm_config=llm_config)
coder = AssistantAgent(name="开发工程师",
system_message="你负责编写代码实现功能。", llm_config=llm_config)
reviewer = AssistantAgent(name="代码审查员",
system_message="你负责审查代码质量。", llm_config=llm_config)
executor = UserProxyAgent(name="执行器",
human_input_mode="NEVER",
code_execution_config={"work_dir": "project", "use_docker": True})
group_chat = GroupChat(
agents=[planner, coder, reviewer, executor],
messages=[], max_round=20,
speaker_selection_method="auto" # auto/round_robin/random/manual
)
manager = GroupChatManager(groupchat=group_chat, llm_config=llm_config)
executor.initiate_chat(manager, message="开发一个 TODO List REST API")
代码执行
# 本地执行
user_proxy = UserProxyAgent(name="executor", code_execution_config={
"work_dir": "workspace", "use_docker": False, "timeout": 60
})
# Docker 沙箱(推荐生产环境)
user_proxy = UserProxyAgent(name="executor", code_execution_config={
"work_dir": "workspace", "use_docker": "python:3.11-slim", "timeout": 120
})
工具注册与嵌套对话
from autogen import register_function
def get_weather(city: str) -> str:
"""查询指定城市的天气信息。"""
return f"{city}:晴,25°C"
register_function(get_weather,
caller=assistant, executor=user_proxy,
name="get_weather", description="查询城市天气")
# 嵌套对话:Agent 内部触发子对话
assistant.register_nested_chats(
trigger=user_proxy,
chat_queue=[{"recipient": reviewer, "message": "请审查代码。", "max_turns": 3}]
)
与同类框架对比
| 特性 | AutoGen | CrewAI | LangGraph |
|---|---|---|---|
| 核心理念 | 对话驱动协作 | 角色扮演团队 | 图状态机 |
| 代码执行 | 原生 Docker 沙箱 | 需集成工具 | 需自行实现 |
| 群聊模式 | 原生 GroupChat | 不支持 | 需手动编排 |
| 人类介入 | human_input_mode 灵活控制 | 有限支持 | 中断点机制 |
| 嵌套对话 | 原生支持 | 不支持 | 子图实现 |
| 适用场景 | 代码生成、多轮讨论 | 内容生产、流程自动化 | 复杂工作流 |
Related skills
Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.
Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.
Fetch raw ad creative, app, ranking, and revenue data from AdMapix as structured JSON.
Write, debug, and tune Playwright specs with locator strategy, trace diagnosis, and CI-aware timeouts.
Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.
More from zhangifonly
Browse all skillsGet end-to-end guidance for QQ open platform development — official Bot API, channels, Mini Programs, and OAuth2.0.
Zero-dependency Python CLI for WeChat Official Account APIs with a real production-incident pitfall guide.
AI 小红薯 — 只允许智能体发言的图文社区。发帖、评论、点赞、加入圈子。
滴滴出行决策助手。Use for: (1) 按预算/时段/人数在快车/特惠/拼车/专车间选型并估算费用区间, (2) 早晚高峰/恶劣天气/节假日的叫车策略, (3) 企业版 API 对接与用车规则配置。DiDi ride-hailing decision guide: product selection and...
伙伴云零代码平台指南。Use for: (1) 零代码数据表格应用搭建(表格/看板/仪表盘)方法, (2) 与简道云/明道云/飞书多维表格的选型对比, (3) 从 Excel 迁移到在线协作数据库的路径设计。Huoban zero-code platform guide: app building, compet...
明道云 APaaS 平台指南。Use for: (1) 零代码应用搭建与 APaaS 能力边界(工作表/工作流/API集成), (2) 私有化部署选型——明道云是国内私有化最成熟的零代码方案之一, (3) 与 SaaS 型竞品的对比决策。Mingdao APaaS guide: app building, pri...