2023-07-23 11:50:24 +08:00
# MetaGPT: The Multi-Agent Framework
2023-06-30 17:10:48 +08:00
2023-07-03 15:16:37 +08:00
< p align = "center" >
2023-07-03 21:44:50 +08:00
< a href = "" > < img src = "docs/resources/MetaGPT-logo.jpeg" alt = "MetaGPT logo: Enable GPT to work in software company, collaborating to tackle more complex tasks." width = "150px" > < / a >
2023-07-03 15:16:37 +08:00
< / p >
2023-06-30 17:10:48 +08:00
2023-07-03 15:16:37 +08:00
< p align = "center" >
2023-07-04 10:54:32 +08:00
< b > Assign different roles to GPTs to form a collaborative software entity for complex tasks.< / b >
2023-07-03 15:16:37 +08:00
< / p >
2023-07-03 14:28:09 +08:00
2023-07-03 15:16:37 +08:00
< p align = "center" >
2023-07-03 21:44:50 +08:00
< a href = "docs/README_CN.md" > < img src = "https://img.shields.io/badge/文档-中文版-blue.svg" alt = "CN doc" > < / a >
< a href = "README.md" > < img src = "https://img.shields.io/badge/document-English-blue.svg" alt = "EN doc" > < / a >
2023-07-07 00:35:52 +09:00
< a href = "docs/README_JA.md" > < img src = "https://img.shields.io/badge/ドキュメント-日本語-blue.svg" alt = "JA doc" > < / a >
2023-07-03 15:16:37 +08:00
< a href = "https://discord.gg/wCp6Q3fsAk" > < img src = "https://dcbadge.vercel.app/api/server/wCp6Q3fsAk?compact=true&style=flat" alt = "Discord Follow" > < / a >
< a href = "https://opensource.org/licenses/MIT" > < img src = "https://img.shields.io/badge/License-MIT-yellow.svg" alt = "License: MIT" > < / a >
2023-07-04 22:51:05 +08:00
< a href = "docs/ROADMAP.md" > < img src = "https://img.shields.io/badge/ROADMAP-路线图-blue" alt = "roadmap" > < / a >
2023-07-05 15:48:03 +08:00
< a href = "docs/resources/MetaGPT-WeChat-Personal.jpeg" > < img src = "https://img.shields.io/badge/WeChat-微信-blue" alt = "roadmap" > < / a >
2023-07-03 15:16:37 +08:00
< a href = "https://twitter.com/DeepWisdom2019" > < img src = "https://img.shields.io/twitter/follow/MetaGPT?style=social" alt = "Twitter Follow" > < / a >
< / p >
2023-06-30 17:10:48 +08:00
2023-08-09 20:54:53 -04:00
< p align = "center" >
< a href = "https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/geekan/MetaGPT" > < img src = "https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode" alt = "Open in Dev Containers" > < / a >
2023-08-12 00:26:52 -04:00
< a href = "https://codespaces.new/geekan/MetaGPT" > < img src = "https://img.shields.io/badge/Github_Codespace-Open-blue?logo=github" alt = "Open in GitHub Codespaces" > < / a >
2023-08-09 20:54:53 -04:00
< / p >
2023-06-30 17:10:48 +08:00
2023-07-03 23:53:42 +08:00
1. MetaGPT takes a **one line requirement** as input and outputs **user stories / competitive analysis / requirements / data structures / APIs / documents, etc.**
2023-07-03 21:44:50 +08:00
2. Internally, MetaGPT includes **product managers / architects / project managers / engineers.** It provides the entire process of a **software company along with carefully orchestrated SOPs.**
1. `Code = SOP(Team)` is the core philosophy. We materialize SOP and apply it to teams composed of LLMs.
2023-06-30 17:10:48 +08:00
2023-07-03 21:44:50 +08:00

2023-07-01 07:43:09 +08:00
2023-07-03 21:44:50 +08:00
< p align = "center" > Software Company Multi-Role Schematic (Gradually Implementing)< / p >
2023-07-03 15:23:48 +08:00
2023-07-03 21:44:50 +08:00
## Examples (fully generated by GPT-4)
2023-06-30 17:10:48 +08:00
2023-07-03 21:44:50 +08:00
For example, if you type `python startup.py "Design a RecSys like Toutiao"` , you would get many outputs, one of them is data & api design
2023-06-30 17:10:48 +08:00
2023-07-03 21:44:50 +08:00

2023-06-30 17:10:48 +08:00
2023-07-07 13:16:02 +01:00
It costs approximately ** $0.2** (in GPT-4 API fees) to generate one example with analysis and design, and around ** $2.0** for a full project.
2023-06-30 17:10:48 +08:00
2023-07-03 21:44:50 +08:00
## Installation
2023-07-18 23:35:38 +12:00
2023-07-10 16:54:17 +08:00
### Traditional Installation
2023-07-18 23:35:38 +12:00
2023-06-30 17:10:48 +08:00
```bash
2023-07-03 21:44:50 +08:00
# Step 1: Ensure that NPM is installed on your system. Then install mermaid-js.
2023-06-30 17:10:48 +08:00
npm --version
2023-07-03 10:31:38 +08:00
sudo npm install -g @mermaid -js/mermaid-cli
2023-07-03 21:44:50 +08:00
# Step 2: Ensure that Python 3.9+ is installed on your system. You can check this by using:
2023-07-03 10:31:38 +08:00
python --version
2023-06-30 17:10:48 +08:00
2023-07-03 21:44:50 +08:00
# Step 3: Clone the repository to your local machine, and install it.
2023-06-30 17:10:48 +08:00
git clone https://github.com/geekan/metagpt
cd metagpt
python setup.py install
```
2023-07-29 09:40:47 +08:00
**Note:**
- If already have Chrome, Chromium, or MS Edge installed, you can skip downloading Chromium by setting the environment variable
`PUPPETEER_SKIP_CHROMIUM_DOWNLOAD` to `true` .
- Some people are [having issues ](https://github.com/mermaidjs/mermaid.cli/issues/15 ) installing this tool globally. Installing it locally is an alternative solution,
```bash
npm install @mermaid -js/mermaid-cli
```
- don't forget to the configuration for mmdc in config.yml
```yml
2023-07-30 15:45:44 +08:00
PUPPETEER_CONFIG: "./config/puppeteer-config.json"
2023-07-29 09:40:47 +08:00
MMDC: "./node_modules/.bin/mmdc"
```
2023-08-16 21:32:50 +03:00
- if `python setup.py install` fails with error `[Errno 13] Permission denied: '/usr/local/lib/python3.11/dist-packages/test-easy-install-13129.write-test'` , try instead running `python setup.py install --user`
2023-07-18 23:35:38 +12:00
### Installation by Docker
2023-07-10 16:54:17 +08:00
```bash
# Step 1: Download metagpt official image and prepare config.yaml
2023-08-02 23:47:52 +08:00
docker pull metagpt/metagpt:v0.3.1
2023-07-18 23:57:22 +12:00
mkdir -p /opt/metagpt/{config,workspace}
2023-08-02 23:47:52 +08:00
docker run --rm metagpt/metagpt:v0.3.1 cat /app/metagpt/config/config.yaml > /opt/metagpt/config/key.yaml
vim /opt/metagpt/config/key.yaml # Change the config
2023-07-10 16:54:17 +08:00
2023-07-13 13:55:56 +08:00
# Step 2: Run metagpt demo with container
docker run --rm \
--privileged \
2023-08-02 23:47:52 +08:00
-v /opt/metagpt/config/key.yaml:/app/metagpt/config/key.yaml \
2023-07-18 23:57:22 +12:00
-v /opt/metagpt/workspace:/app/metagpt/workspace \
2023-08-02 23:47:52 +08:00
metagpt/metagpt:v0.3.1 \
2023-07-13 13:55:56 +08:00
python startup.py "Write a cli snake game"
# You can also start a container and execute commands in it
2023-07-10 16:54:17 +08:00
docker run --name metagpt -d \
2023-07-13 13:55:56 +08:00
--privileged \
2023-08-02 23:47:52 +08:00
-v /opt/metagpt/config/key.yaml:/app/metagpt/config/key.yaml \
2023-07-18 23:57:22 +12:00
-v /opt/metagpt/workspace:/app/metagpt/workspace \
2023-08-02 23:47:52 +08:00
metagpt/metagpt:v0.3.1
2023-07-10 16:54:17 +08:00
docker exec -it metagpt /bin/bash
2023-07-13 13:55:56 +08:00
$ python startup.py "Write a cli snake game"
2023-07-10 16:54:17 +08:00
```
2023-07-18 23:35:38 +12:00
The command `docker run ...` do the following things:
2023-07-13 13:55:56 +08:00
- Run in privileged mode to have permission to run the browser
2023-07-18 23:57:22 +12:00
- Map host directory `/opt/metagpt/config` to container directory `/app/metagpt/config`
- Map host directory `/opt/metagpt/workspace` to container directory `/app/metagpt/workspace`
2023-07-13 13:55:56 +08:00
- Execute the demo command `python startup.py "Write a cli snake game"`
2023-07-10 16:54:17 +08:00
### Build image by yourself
2023-07-18 23:35:38 +12:00
2023-07-10 16:54:17 +08:00
```bash
# You can also build metagpt image by yourself.
2023-07-19 11:20:18 +08:00
git clone https://github.com/geekan/MetaGPT.git
2023-08-02 23:47:52 +08:00
cd MetaGPT & & docker build -t metagpt:custom .
2023-07-10 16:54:17 +08:00
```
2023-07-03 21:44:50 +08:00
## Configuration
2023-06-30 17:10:48 +08:00
2023-07-03 21:44:50 +08:00
- Configure your `OPENAI_API_KEY` in any of `config/key.yaml / config/config.yaml / env`
- Priority order: `config/key.yaml > config/config.yaml > env`
2023-06-30 17:10:48 +08:00
```bash
2023-07-03 21:44:50 +08:00
# Copy the configuration file and make the necessary modifications.
2023-06-30 17:10:48 +08:00
cp config/config.yaml config/key.yaml
```
2023-07-18 23:35:38 +12:00
| Variable Name | config/key.yaml | env |
| ------------------------------------------ | ----------------------------------------- | ----------------------------------------------- |
| OPENAI_API_KEY # Replace with your own key | OPENAI_API_KEY: "sk-..." | export OPENAI_API_KEY="sk-..." |
| OPENAI_API_BASE # Optional | OPENAI_API_BASE: "https://< YOUR_SITE > /v1" | export OPENAI_API_BASE="https://< YOUR_SITE > /v1" |
2023-06-30 17:10:48 +08:00
2023-07-03 21:44:50 +08:00
## Tutorial: Initiating a startup
2023-06-30 17:10:48 +08:00
```shell
2023-07-03 21:44:50 +08:00
python startup.py "Write a cli snake game"
2023-07-24 14:59:40 +08:00
# Use code review will cost more money, but will opt for better code quality.
python startup.py "Write a cli snake game" --code_review True
2023-06-30 17:10:48 +08:00
```
2023-07-03 21:44:50 +08:00
After running the script, you can find your new project in the `workspace/` directory.
2023-07-29 18:48:47 +08:00
### Preference of Platform or Tool
2023-06-30 17:10:48 +08:00
2023-08-02 23:14:46 +08:00
You can tell which platform or tool you want to use when stating your requirements.
2023-07-29 18:48:47 +08:00
```shell
2023-08-02 23:14:46 +08:00
python startup.py "Write a cli snake game based on pygame"
2023-07-29 18:48:47 +08:00
```
2023-07-13 14:15:55 +08:00
### Usage
```
NAME
startup.py - We are a software startup comprised of AI. By investing in us, you are empowering a future filled with limitless possibilities.
SYNOPSIS
startup.py IDEA < flags >
DESCRIPTION
We are a software startup comprised of AI. By investing in us, you are empowering a future filled with limitless possibilities.
POSITIONAL ARGUMENTS
IDEA
Type: str
Your innovative idea, such as "Creating a snake game."
FLAGS
--investment=INVESTMENT
Type: float
Default: 3.0
As an investor, you have the opportunity to contribute a certain dollar amount to this AI company.
--n_round=N_ROUND
Type: int
Default: 5
NOTES
You can also use flags syntax for POSITIONAL ARGUMENTS
```
2023-07-03 21:44:50 +08:00
### Code walkthrough
2023-06-30 17:10:48 +08:00
```python
from metagpt.software_company import SoftwareCompany
from metagpt.roles import ProjectManager, ProductManager, Architect, Engineer
2023-07-04 12:15:09 +08:00
async def startup(idea: str, investment: float = 3.0, n_round: int = 5):
2023-07-03 21:44:50 +08:00
"""Run a startup. Be a boss."""
2023-06-30 17:10:48 +08:00
company = SoftwareCompany()
company.hire([ProductManager(), Architect(), ProjectManager(), Engineer()])
company.invest(investment)
company.start_project(idea)
await company.run(n_round=n_round)
```
2023-07-03 21:44:50 +08:00
You can check `examples` for more details on single role (with knowledge base) and LLM only examples.
2023-06-30 17:10:48 +08:00
2023-08-07 20:48:07 +08:00
## QuickStart
It is difficult to install and configure the local environment for some users. The following tutorials will allow you to quickly experience the charm of MetaGPT.
2023-08-08 11:36:14 +08:00
- [MetaGPT quickstart ](https://deepwisdom.feishu.cn/wiki/CyY9wdJc4iNqArku3Lncl4v8n2b )
2023-08-07 20:48:07 +08:00
2023-08-09 08:32:28 +08:00
## Citation
For now, cite the [Arxiv paper ](https://arxiv.org/abs/2308.00352 ):
2023-08-09 08:48:28 +08:00
```bibtex
2023-08-09 08:32:28 +08:00
@misc {hong2023metagpt,
title={MetaGPT: Meta Programming for Multi-Agent Collaborative Framework},
author={Sirui Hong and Xiawu Zheng and Jonathan Chen and Yuheng Cheng and Jinlin Wang and Ceyao Zhang and Zili Wang and Steven Ka Shing Yau and Zijuan Lin and Liyang Zhou and Chenyu Ran and Lingfeng Xiao and Chenglin Wu},
year={2023},
eprint={2308.00352},
archivePrefix={arXiv},
primaryClass={cs.AI}
}
```
2023-07-03 21:44:50 +08:00
## Contact Information
2023-07-03 11:31:07 +08:00
2023-07-03 21:44:50 +08:00
If you have any questions or feedback about this project, please feel free to contact us. We highly appreciate your suggestions!
2023-07-03 11:31:07 +08:00
2023-07-03 21:44:50 +08:00
- **Email:** alexanderwu@fuzhi .ai
- **GitHub Issues:** For more technical inquiries, you can also create a new issue in our [GitHub repository ](https://github.com/geekan/metagpt/issues ).
2023-07-03 11:31:07 +08:00
2023-07-03 21:44:50 +08:00
We will respond to all questions within 2-3 business days.
2023-07-03 11:31:07 +08:00
2023-07-03 21:44:50 +08:00
## Demo
2023-06-30 17:54:05 +08:00
https://github.com/geekan/MetaGPT/assets/2707039/5e8c1062-8c35-440f-bb20-2b0320f8d27d