【新智元编者按】AI智能化间有多火,看一看MetaGPT就晓得了。两个能让你2英镑出头的工程项目,GitHub早已狂揽11.2k星。
近年,又两个AI智能化体工程项目MetaGPT伤风败俗了,短短的三个月在GitHub上狂揽11.2k星。
这是两个半智能化体架构,能饰演相同的配角,一名技师、商品副经理、CTO和部门副经理。
与AutoGPT类似于,但特别针对商品市场需求、结构设计、市场竞争预测、API和文件格式度身订制。
门牌号:https://github.com/geekan/MetaGPT
最重要的是,只输入老板娘一句话的市场需求,它就能输入软件公司的整座业务流程,和精心结构设计的SOP。
其中,Code = SOP(Team)是核心哲学。将SOP具象化,并且用于LLM构成的团队。
比如,输入python startup.py “写个类似于今日头条的推荐系统”,就会获得一系列输入,其一是数据结构与API结构设计:
生成两个包含预测和结构设计的示例大约需要0.2英镑(GPT-4 API的费用),而两个完整的工程项目大约需要2.0英镑。
如下是,MetaGPT与人类团队的软件开发SOP比较图。
MetaGPT的方法展示了,将高层次任务分解为由相同配角,比如商品副经理、CTO、部门副经理、技师,处理的详细可操作组件的能力。
这种方法与人类软件开发团队类似于,但优势在于能提高效率、精确性和一致性。
有网友用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生成一只红色小鸟。
网友表示,虽然有一些小问题,比如顶部的管道没有杀死小鸟。但它还是成功了,而且我没有写一行代码,甚至都不用调试!!!!!
# 步骤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
# 步骤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.3docker exec -it metagpt /bin/bash$ python startup.py “Write a cli snake game”
将主机目录/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: 5NOTES 也可以用FLAGS的语法,来处理POSITIONAL ARGUMENTS。
from metagpt.software_company import SoftwareCompanyfrom metagpt.roles import ProjectManager, ProductManager, Architect, Engineerasync 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://arxiv.org/pdf/2308.00352.pdf
https://github.com/geekan/MetaGPT
https://twitter.com/99aico/status/1684249002437668864