# MetaGPT **Repository Path**: liunix61/MetaGPT ## Basic Information - **Project Name**: MetaGPT - **Description**:  多智能体框架 MetaGPT 可以使 GPT 以软件公司的形式工作,协作处理更复杂的任务 - **Primary Language**: Python - **License**: MIT - **Default Branch**: main - **Homepage**: https://www.oschina.net/p/metagpt - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 23 - **Created**: 2023-07-19 - **Last Updated**: 2023-07-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MetaGPT: Multi-Agent Meta Programming Framework

MetaGPT logo: Enable GPT to work in software company, collaborating to tackle more complex tasks.

Assign different roles to GPTs to form a collaborative software entity for complex tasks.

CN doc EN doc JA doc Discord Follow License: MIT roadmap roadmap Twitter Follow

1. MetaGPT takes a **one line requirement** as input and outputs **user stories / competitive analysis / requirements / data structures / APIs / documents, etc.** 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. ![A software company consists of LLM-based roles](docs/resources/software_company_cd.jpeg)

Software Company Multi-Role Schematic (Gradually Implementing)

## Examples (fully generated by GPT-4) 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 ![Jinri Toutiao Recsys Data & API Design](docs/resources/workspace/content_rec_sys/resources/data_api_design.png) 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. ## Installation ### Traditional Installation ```bash # Step 1: Ensure that NPM is installed on your system. Then install mermaid-js. npm --version sudo npm install -g @mermaid-js/mermaid-cli # Step 2: Ensure that Python 3.9+ is installed on your system. You can check this by using: python --version # Step 3: Clone the repository to your local machine, and install it. git clone https://github.com/geekan/metagpt cd metagpt python setup.py install ``` ### Installation by Docker ```bash # Step 1: Download metagpt official image and prepare config.yaml docker pull metagpt/metagpt:v0.2 mkdir -p /opt/metagpt/{config,workspace} && chmod 777 -R /opt/metagpt docker run --rm metagpt/metagpt:v0.2 cat /app/metagpt/config/config.yaml > /opt/metagpt/config/config.yaml vim /opt/metagpt/config/config.yaml # Change the config # Step 2: Run metagpt demo with container docker run --rm \ --privileged \ -v /opt/metagpt/config:/app/metagpt/config \ -v /opt/metagpt/workspace:/app/metagpt/workspace \ metagpt/metagpt:v0.2 \ python startup.py "Write a cli snake game" # You can also start a container and execute commands in it docker run --name metagpt -d \ --privileged \ -v /opt/metagpt/config:/app/metagpt/config \ -v /opt/metagpt/workspace:/app/metagpt/workspace \ metagpt/metagpt:v0.2 docker exec -it metagpt /bin/bash $ python startup.py "Write a cli snake game" ``` The command `docker run ...` do the following things: - Run in privileged mode to have permission to run the browser - Map host directory `/opt/metagtp/config` to container directory `/app/metagpt/config` - Map host directory `/opt/metagpt/workspace` to container directory `/app/metagpt/workspace` - Execute the demo command `python startup.py "Write a cli snake game"` ### Build image by yourself ```bash # You can also build metagpt image by yourself. cd metagpt && docker build --network host -t metagpt:v0.1 . ``` ## Configuration - Configure your `OPENAI_API_KEY` in any of `config/key.yaml / config/config.yaml / env` - Priority order: `config/key.yaml > config/config.yaml > env` ```bash # Copy the configuration file and make the necessary modifications. cp config/config.yaml config/key.yaml ``` | 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:///v1" | export OPENAI_API_BASE="https:///v1" | ## Tutorial: Initiating a startup ```shell python startup.py "Write a cli snake game" ``` After running the script, you can find your new project in the `workspace/` directory. ### 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 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 ``` ### Code walkthrough ```python from metagpt.software_company import SoftwareCompany from metagpt.roles import ProjectManager, ProductManager, Architect, Engineer async def startup(idea: str, investment: float = 3.0, n_round: int = 5): """Run a startup. Be a boss.""" company = SoftwareCompany() company.hire([ProductManager(), Architect(), ProjectManager(), Engineer()]) company.invest(investment) company.start_project(idea) await company.run(n_round=n_round) ``` You can check `examples` for more details on single role (with knowledge base) and LLM only examples. ## Contact Information If you have any questions or feedback about this project, please feel free to contact us. We highly appreciate your suggestions! - **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). We will respond to all questions within 2-3 business days. ## Demo https://github.com/geekan/MetaGPT/assets/2707039/5e8c1062-8c35-440f-bb20-2b0320f8d27d