分享

MetaGPT爆火出圈!2美元就能当老板,GitHub狂揽11.2k星,AI智能体「多面手」诞生

 天承办公室 2023-08-08 发布于江苏

图片


  新智元报道  

编辑:桃子 好困
【新智元导读】AI智能体有多火,看看MetaGPT就知道了。一个能够让你2美元当老板的项目,GitHub已经狂揽11.2k星。
智能体,就是未来!
近来,又一个AI智能体项目MetaGPT爆火了,短短一个月在GitHub上狂揽11.2k星。
这是一个多智能体框架,能够扮演不同的角色,一位工程师、产品经理、架构师和项目经理。
与AutoGPT类似,但针对产品需求、设计、竞争分析、API和文档量身定制。

图片

地址:https://github.com/geekan/MetaGPT
最重要的是,只输入老板一句话的需求,它就能输出软件公司的整个流程,以及精心安排的SOP。
其中,Code = SOP(Team)是核心哲学。将SOP具象化,并且用于LLM构成的团队。

图片

软件公司多角色示意图(正在逐步实现)

MetaGPT


图片
示例(均由GPT-4生成)
比如,输入python startup.py '写个类似今日头条的推荐系统',就会获得一系列输出,其一是数据结构与API设计:
图片
生成一个包含分析和设计的示例大约需要0.2美元(GPT-4 API的费用),而一个完整的项目大约需要2.0美元。
如下是,MetaGPT与人类团队的软件开发SOP比较图。
MetaGPT的方法展示了,将高层次任务分解为由不同角色,比如产品经理、架构师、项目经理、工程师,处理的详细可操作组件的能力。
这种方法与人类软件开发团队类似,但优势在于能够提高效率、精确性和一致性。
图片
MetaGPT核心组成部分如下:
图片

网友实现


有网友用MetaGPT十分钟,就做出了一个小游戏Flappy Bird。
图片
她表示,MetaGPT功能过于强大,也许真的可以取代软件公司!
图片
以下是这位网友制作游戏的全过程。
首先,在电脑上通过「传统安装」过程安装MetaGPT,并输入OpenAI API密钥。
把自己的需求通过prompt的形式告诉系统后,就可以看着MetaGPT给你写代码了。
python startup.py 'write p5.js code for Flappy Bird where you control a yellow bird continuously flying between a series of green pipes. The bird flaps every time you left click the mouse. If the bird falls to the ground or hits a pipe, you lose. This game goes on infinitely until you lose and you get points the further you go' --code_review True
图片
接着,运行python main.py。然而,此时程序却报出了一堆bug。
图片
问题不大,把这堆代码直接扔给Code Interpreter,让GPT-4来debug。
图片
代码改完之后,再用Midjourney生成一只红色小鸟。
图片
顺便问一下GPT-4图片的格式和尺寸。
图片
再用canva调整小鸟和管道的大小。
图片
最后,运行游戏。
网友表示,虽然有一些小问题,比如顶部的管道没有杀死小鸟。但它还是成功了,而且我没有写一行代码,甚至都不用调试!!!!!
只要别让小鸟碰到底部的管道就行。
图片
也有网友做了同样的游戏,效果如下:
图片
另外,还有日本网友还用其制作了「二十一点」。
图片
图片

安装


传统安装
# 步骤1:确保已经安装了NPM。并使用npm安装mermaid-jsnpm --versionsudo npm install -g @mermaid-js/mermaid-cli
# 步骤2:确保已经安装了Python 3.9+。可以使用以下命令进行检查:python --version
# 步骤3:克隆仓库到本机,并进行安装。git clone https://github.com/geekan/metagptcd metagptpython setup.py install
Docker安装
# 步骤1: 下载metagpt官方镜像并准备好config.yamldocker pull metagpt/metagpt:v0.3mkdir -p /opt/metagpt/{config,workspace}docker run --rm metagpt/metagpt:v0.3 cat /app/metagpt/config/config.yaml > /opt/metagpt/config/config.yamlvim /opt/metagpt/config/config.yaml # 修改config
# 步骤2: 使用容器运行metagpt演示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'
# 也可以启动一个容器并在其中执行命令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 ...做了以下事情:

以特权模式运行,有权限运行浏览器

将主机目录/opt/metagpt/config映射到容器目录/app/metagpt/config

将主机目录/opt/metagpt/workspace映射到容器目录/app/metagpt/workspace

执行演示命令python startup.py 'Write a cli snake game'
自己构建镜像
# 也可以自己构建metagpt镜像git clone https://github.com/geekan/MetaGPT.gitcd MetaGPT && docker build -t metagpt:custom .
配置
在config/key.yaml / config/config.yaml / env中配置你的OPENAI_API_KEY
优先级顺序:config/key.yaml > config/config.yaml > env
# 复制配置文件并进行必要的修改cp config/config.yaml config/key.yaml
图片

演示:启动一个创业公司


python startup.py 'Write a cli snake game'# 使用code review模式会增加开销,但同时也会提升代码质量和成功率python startup.py 'Write a cli snake game' --code_review True
运行脚本后,就可以在workspace/目录中找到你的新项目了。
平台或工具的偏好
你可以在陈述需求时,说明自己想要使用的平台或工具。
python startup.py 'Write a cli snake game based on pygame'
使用
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. # 我们是一家AI软件创业公司。通过投资我们,您将赋能一个充满无限可能的未来。
POSITIONAL ARGUMENTS IDEA Type: str 你的创新想法,例如'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. # 作为投资者,您有机会向这家AI公司投入一定的美元金额。 --n_round=N_ROUND Type: int Default: 5
NOTES 也可以用FLAGS的语法,来处理POSITIONAL ARGUMENTS。
代码实现
from metagpt.software_company import SoftwareCompanyfrom 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)
你可以查看examples,其中有单角色(带知识库)的使用例子与仅LLM的使用例子。

参考资料:

https:///pdf/2308.00352.pdf

https://github.com/geekan/MetaGPT

https://twitter.com/99aico/status/1684249002437668864

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多