MetaGPT/README.md

121 lines
5.6 KiB
Markdown
Raw Normal View History

2023-07-03 21:47:28 +08:00
# MetaGPT: Multi-Agent Meta Programming 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-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-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
![A software company consists of LLM-based roles](docs/resources/software_company_cd.jpeg)
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
![Jinri Toutiao Recsys Data & API Design](docs/resources/workspace/content_rec_sys/resources/data_api_design.png)
2023-06-30 17:10:48 +08:00
2023-07-03 21:44:50 +08:00
It requires around **$0.2** (GPT-4 api's costs) to generate one example with analysis and design, around **$2.0** to a full project.
2023-06-30 17:10:48 +08:00
2023-07-03 21:44:50 +08:00
## Installation
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-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-03 21:44:50 +08:00
| Variable Name | config/key.yaml | env |
2023-06-30 17:10:48 +08:00
|--------------------------------------------|-------------------------------------------|--------------------------------|
2023-07-03 21:44:50 +08:00
| 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-07 13:03:51 +08:00
## Docker Setup
You can also use docker to setup MetaGPT.
```bash
cd metagpt
docker build --network host -t metagpt:<version> .
```
There are some changes of mirrors in the dockerfile, for users outside mainland China, feel free to modify or delete them :)
To run the docker image, you can use the following command.
```bash
docker run docker run -it -v <MetaGPT-config-dir>:/app/metagpt/config -v <Workspace-dir>:/app/metagpt/workspace metagpt:<version> <command>
```
2023-07-07 13:09:12 +08:00
This command mounts the config folder and workspace folder in the host machine, so the container can use the same comfiguration and store the works in the host machine. You should use absolute directory of these folders. The `command` is what you want to run, you can set it as `/bin/bash -c "cd metagpt && python startup.py "Write helloworld in python""` or just `/bin/bash` for interactive terminal.
2023-07-07 13:03:51 +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-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-06-30 17:10:48 +08:00
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-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