MetaGPT: multi-agent framework git home page

MetaGPT: Multi-Agent Framework

MetaGPT logo: Make GPT work as a software company to collaborate on more complex tasks

Make GPTs form software companies to collaborate on more complex tasks

CN doc IN doc I doc Discord Follow License: MIT roadmap roadmap Twitter Follow

  1. MetaGPT inputs a one-sentence boss requirement , and outputs user stories/competitive product analysis/requirements/data structure/APIs/documents, etc.
  2. MetaGPT includes product managers/architects/project managers/engineers , which provides a software company 's entire process and well-adjusted SOP
    1. Code = SOP(Team) is the core philosophy. We visualize the SOP and use it in the team formed by LLM

A software company made entirely of big language model roles

Schematic diagram of multiple roles in a software company (being gradually implemented)

Examples (both generated by GPT-4)

For example, type and press Enter, you will get a series of outputs, one of which is the data structure and API designpython startup.py "写个类似今日头条的推荐系统"

Toutiao Recsys Data & API Design

This costs about $0.2 (the cost of the GPT-4 API) to generate an example with analysis and design, and about $2.0 for a full project

Install

traditional installation

# Step 1: Make sure NPM is installed on your system. And install mermaid-js with npm 
npm --version 
sudo npm install -g @mermaid-js/mermaid-cli 

# Step 2: Make sure you have Python 3.9+ installed on your system. You can check with the following command: 
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

Docker installation

# Step 1: Download the official metagpt image and prepare config.yaml 
docker pull metagpt/metagpt:v0.3 
mkdir -p /opt/metagpt/{config,workspace} 
docker run --rm metagpt/metagpt:v0.3 cat / app/metagpt/config/config.yaml > /opt/metagpt/config/config.yaml 
vim /opt/metagpt/config/config.yaml # Modify config 

# Step 2: Use container to run metagpt demo 
docker run --rm \ 
    - -privileged \ 
    -v /opt/metagpt/config:/app/metagpt/config \ 
    -v /opt/metagpt/workspace:/app/metagpt/workspace \ 
    metagpt/metagpt:v0.3 \ 
    python startup.py "Write a cli snake game" 

# You can also start a container and execute the command 
docker run --name metagpt -d \ 
    --privileged \ 
    -v /opt/metagpt/config:/app/metagpt/config \ 
    -v /opt/metagpt/workspace:/app/metagpt/workspace \
    metagpt/metagpt:v0.3

docker exec -it metagpt /bin/bash
$ python startup.py "Write a cli snake game"

docker run ...did the following:

  • Run in privileged mode, with permission to run the browser
  • Map host directory  /opt/metagpt/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 the mirror yourself

# You can also build the metagpt image yourself 
git clone https://github.com/geekan/MetaGPT.git 
cd MetaGPT && docker build -t metagpt:v0.3 .

configuration

  • Configure  config/key.yaml / config/config.yaml / env your OPENAI_API_KEY
  • Priority order:config/key.yaml > config/config.yaml > env
# Copy the configuration file and make necessary changes 
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://<YOUR_SITE>/v1" export OPENAI_API_BASE="https://<YOUR_SITE>/v1"

Example: Launching a Startup

python startup.py "write a command line snake" 
# Turning on the code review mode will cost more money, but it will improve code quality and success rate 
python startup.py "write a command line snake" --code_review True

After running the script, you can  workspace/ find your new project in the directory.

Platform or tool preference

You can specify the platform or tool you want to use when stating the requirements. For example:

python startup.py "Write a command line snake based on pygame"

use

名称
    startup.py - 我们是一家AI软件创业公司。通过投资我们,您将赋能一个充满无限可能的未来。

概要
    startup.py IDEA <flags>

描述
    我们是一家AI软件创业公司。通过投资我们,您将赋能一个充满无限可能的未来。

位置参数
    IDEA
        类型: str
        您的创新想法,例如"写一个命令行贪吃蛇。"

标志
    --investment=INVESTMENT
        类型: float
        默认值: 3.0
        作为投资者,您有机会向这家AI公司投入一定的美元金额。
    --n_round=N_ROUND
        类型: int
        默认值: 5

备注
    您也可以用`标志`的语法,来处理`位置参数`

Code

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 company. 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 take a look examples, there are single-role (with knowledge base) usage examples and LLM-only usage examples.

Quick experience

For some users, it is difficult to install and configure the local environment. The following tutorials will allow you to quickly experience the charm of MetaGPT.

contact information

If you have any questions or feedback about this project, please contact us. We very much welcome your suggestions!

We respond to all questions within 2-3 business days.

Guess you like

Origin blog.csdn.net/sinat_37574187/article/details/132222315