MetaGPT:多智能体框架 为 GPT 分配不同的角色,以形成复杂任务的协作实体。-开源码库社区-开源分享-6协议-村兔网

MetaGPT:多智能体框架 为 GPT 分配不同的角色,以形成复杂任务的协作实体。

开始使用

安装

确保您的系统上安装了 Python 3.9 或更高版本,但低于 3.12。您可以使用以下命令来检查这一点: 。
您可以像这样使用 conda:python --versionconda create -n metagpt python=3.9 && conda activate metagpt

pip install --upgrade metagpt
# or `pip install --upgrade git+https://github.com/geekan/MetaGPT.git`
# or `git clone https://github.com/geekan/MetaGPT && cd MetaGPT && pip install --upgrade -e .`

实际使用前安装 node 和 pnpm。

详细安装指南,请参阅cli_install或docker_install

配置

您可以通过运行以下命令来初始化 MetaGPT 的配置,或手动创建文件:~/.metagpt/config2.yaml

# Check https://docs.deepwisdom.ai/main/en/guide/get_started/configuration.html for more details
metagpt --init-config  # it will create ~/.metagpt/config2.yaml, just modify it to your needs

您可以根据示例和文档进行配置:~/.metagpt/config2.yaml

llm:
  api_type: "openai"  # or azure / ollama / groq etc. Check LLMType for more options
  model: "gpt-4-turbo"  # or gpt-3.5-turbo
  base_url: "https://api.openai.com/v1"  # or forward url / other llm url
  api_key: "YOUR_API_KEY"

用法

安装后,您可以在 CLI 使用 MetaGPT

metagpt "Create a 2048 game"  # this will create a repo in ./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 files

您还可以使用数据解释器编写代码:

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
请登录后发表评论

    没有回复内容