MetaGPT:多智能体框架,把一行需求变成软件公司流水线
MetaGPT 是 FoundationAgents(DeepWisdom)开源的多智能体框架,通过给 LLM 分配产品经理、架构师、项目经理、工程师等角色,把软件公司的 SOP 编排成协作流程:输入一行需求,输出用户故事、竞品分析、需求文档、数据结构、API 与代码仓库。项目同时提供 CLI、Python 库与 Data Interpreter 代码解释器用法,官方还推出了自然语言编程产品 MGX(MetaGPT X)。
社区作者 · zZz
它解决什么问题
MetaGPT:多智能体框架(The Multi-Agent Framework)
配图 1 为项目 Logo,配图 2 展示了“软件公司由多个基于 LLM 的角色组成”的示意结构。
项目定位
MetaGPT 的核心思想是 **Code = SOP(Team)**:把标准作业流程(SOP)固化下来,并应用到由 LLM 组成的团队中。项目内部包含产品经理、架构师、项目经理、工程师等角色,为复杂任务提供完整的软件公司式协作流程。
官方描述其能力为:输入一行需求,输出用户故事 / 竞品分析 / 需求 / 数据结构 / API / 文档等产物。
用途与能力
- 以一行自然语言需求为输入,驱动多角色智能体协作,产出需求分析、竞品分析、数据结构、接口设计和文档,并最终生成代码仓库(示例:
Create a 2048 game)。 - 内置软件公司全流程与精心编排的 SOP,多角色按流程接力完成任务。
- 提供 Data Interpreter 角色,可执行数据分析类代码任务。
- 可作为命令行工具使用,也可作为 Python 库集成到自己的工程中。
安装
- 环境要求:系统需安装 Python 3.9 或更高版本,但必须低于 3.12;可用
python --version检查。
- 可用 conda 创建环境:
conda create -n metagpt python=3.9 && conda activate metagpt。
- 安装包:
pip install --upgrade metagpt,或pip install --upgrade git+https://github.com/geekan/MetaGPT.git,或git clone https://github.com/geekan/MetaGPT && cd MetaGPT && pip install --upgrade -e .。
- 实际使用前还需要安装 node 和 pnpm。
- 详细安装说明可参考仓库中的
cli_install或docker_install文档。
配置
- 运行
metagpt --init-config初始化配置,会生成~/.metagpt/config2.yaml(也可手动创建该文件),按需修改。 - 在
config2.yaml中配置 LLM:api_type可取openai,或azure/ollama/groq等(更多选项见 LLMType);model示例为gpt-4-turbo或gpt-3.5-turbo;base_url可填https://api.openai.com/v1或转发地址 / 其他 LLM 地址;api_key填写自己的密钥。
使用
CLI 方式:metagpt "Create a 2048 game",会在 ./workspace 下创建一个仓库。
库方式:
from metagpt.software_company import generate_repo
from metagpt.utils.project_repo import ProjectRepo
repo: ProjectRepo = generate_repo("Create a 2048 game") # or ProjectRepo("<path>")
print(repo) # it will print the repo structure with filesData Interpreter 写代码方式:
import asyncio
from metagpt.roles.di.data_interpreter import DataInterpreter
async def main():
di = DataInterpreter()
await di.run("Run data analysis on sklearn Iris dataset, include a plot")
asyncio.run(main()) # or await main() in a jupyter notebook setting学习资源
- 在线文档、Usage、What can MetaGPT do?、How to build your own agents? 等教程。
- MetaGPT Usage & Development Guide | Agent 101 与 MultiAgent 101。
- Contribution、Develop Roadmap、Use Cases、FAQs 页面。
- 用例包含 Data Interpreter、Debate、Researcher、Receipt Assistant。
- 可在 MetaGPT Hugging Face Space 上直接试用;官方还提供了演示视频,以及第三方安装教程视频。
许可证与引用
**许可证:待核验。** 本次提供的来源正文未出现具体开源许可证名称,请以仓库根目录的 LICENSE 文件为准,不要凭猜测使用。
若在出版物中引用 MetaGPT,应使用官方给出的 BibTeX:论文标题为《MetaGPT: Meta Programming for A Multi-Agent Collaborative Framework》,作者包括 Sirui Hong、Mingchen Zhuge、Jonathan Chen、Xiawu Zheng、Yuheng Cheng、Jinlin Wang、Ceyao Zhang、Zili Wang、Steven Ka Shing Yau、Zijuan Lin、Liyang Zhou、Chenyu Ran、Lingfeng Xiao、Chenglin Wu、Jürgen Schmidhuber,发表于 The Twelfth International Conference on Learning Representations(ICLR 2024),链接 https://openreview.
net/forum?id=VtmBAGCN7o 。
项目动态(截至来源正文)
- 2025-03-10:mgx.dev 成为 Product Hunt 当周第一产品。
- 2025-03-04:mgx.dev 成为 Product Hunt 当日第一产品。
- 2025-02-19:正式发布自然语言编程产品 MGX(MetaGPT X),官方称其为“全球首个 AI 智能体开发团队”。
- 2025-02-17:发布 SPO 与 AOT 两篇论文,并公开代码。
- 2025-01-22:论文 AFlow: Automating Agentic Workflow Generation 被 ICLR 2025 接收为口头报告(top 1.8%),在基于 LLM 的 Agent 分类中排名第 2。
适用对象
- 想用一行自然语言需求快速生成项目骨架、需求文档与代码的开发者与独立开发者。
- 研究多智能体协作、SOP 编排与 Agent 工作流的研究人员与学生。
- 希望基于 MetaGPT 二次开发自己的多角色 Agent 应用的工程团队。
- 需要把 LLM 接入数据分析、代码生成流程的产品与数据团队。
— 本文由 AI 根据公开来源辅助整理,命令、版本与许可证请在使用前到原始页面复核。
安装 / 开始使用
- 检查 Python 版本:确保系统安装 Python 3.9 或更高版本,但必须低于 3.12。可用
python --version检查。
- 创建并激活 conda 环境(可选但推荐):
conda create -n metagpt python=3.9 && conda activate metagpt。
- 安装 MetaGPT,任选一种:
pip install --upgrade metagptpip install --upgrade git+https://github.com/geekan/MetaGPT.gitgit clone https://github.com/geekan/MetaGPT && cd MetaGPT && pip install --upgrade -e .
- 安装 node 与 pnpm(实际使用前必须完成)。
- 更详细的安装指引参考仓库文档
cli_install或docker_install。
- 初始化配置:运行
metagpt --init-config,会生成~/.metagpt/config2.yaml;也可手动创建该文件,然后按需修改。
- 填写 LLM 配置(示例):
llm:下设置api_type: "openai"(或 azure / ollama / groq 等,更多选项见 LLMType)、model: "gpt-4-turbo"(或gpt-3.5-turbo)、base_url: "https://api.openai.com/v1"(或转发地址 / 其他 LLM 地址)、api_key: "YOUR_API_KEY"。配置细节见官方配置文档。
- 首次运行(CLI):
metagpt "Create a 2048 game",命令会在./workspace下创建一个仓库。
- 首次运行(Python 库):
from metagpt.software_company import generate_repo
from metagpt.utils.project_repo import ProjectRepo
repo: ProjectRepo = generate_repo("Create a 2048 game") # or ProjectRepo("<path>")
print(repo) # it will print the repo structure with files- 使用 Data Interpreter 执行数据分析类代码任务:
import asyncio
from metagpt.roles.di.data_interpreter import DataInterpreter
async def main():
di = DataInterpreter()
await di.run("Run data analysis on sklearn Iris dataset, include a plot")
asyncio.run(main()) # or await main() in a jupyter notebook setting步骤 11 · 常见问题与排错:
Python 版本必须 ≥3.9 且 <3.12;未安装 node 与 pnpm 会影响实际使用;未正确配置 config2.yaml 中的 api_type / model / base_url / api_key 会导致无法调用 LLM;其余问题可查阅官方 FAQs、GitHub Issues,或在 Discord 频道提问,官方称将在 2-3 个工作日内回复问题。