With Large Language Models (LLMs) like ChatGPT, OpenAI has witnessed a surge in enterprise and user adoption, currently raking in around $80 million in monthly revenue. In keeping with a recent report by The Information, the San Francisco-based company is reportedly on pace to hit $1 billion in annual revenue.
Last time we delved into AutoGPT and GPT-Engineering, the early mainstream open-source LLM-based AI agents designed to automate complex tasks. While promising, these systems had their justifiable share of issues: inconsistent results, performance bottlenecks, and limitations in handling multifaceted demands. They show proficiency in code generation, but their capabilities often stop there. They lack critical project management functionalities like PRD generation, technical design generation, and API interface prototyping.
Enter MetaGPT— a Multi-agent system that utilizes Large Language models by Sirui Hong fuses Standardized Operating Procedures (SOPs) with LLM-based multi-agent systems. This emerging paradigm disrupts the prevailing limitations of LLMs in fostering effective collaboration and task decomposition in complex, real-world applications.
The great thing about MetaGPT lies in its structuring. It capitalizes on meta-programming techniques to govern, analyze, and transform code in real-time. The aim? To actualize an agile, flexible software architecture that may adapt to dynamic programming tasks.
SOPs act as a meta-function here, coordinating agents to auto-generate code based on defined inputs. In easy terms, it’s as in the event you’ve turned a highly coordinated team of software engineers into an adaptable, intelligent software system.
Understanding MetaGPT Framework
Foundational & Collaboration Layers
MetaGPT’s architecture is split into two layers: the Foundational Components Layer and the Collaboration Layer.
- Foundational Components Layer: This layer focuses on individual agent operations and facilitates system-wide information exchange. It introduces core constructing blocks similar to Environment, Memory, Roles, Actions, and Tools. The Environment sets the stage for shared workspaces and communication pathways, while Memory serves because the historical data archive. Roles encapsulate domain-specific expertise, Actions execute modular tasks, and Tools offer common services. This layer essentially serves because the operating system for the agents. More details on how these work together can be found within the article ‘Beyond ChatGPT; AI Agent: A Latest World of Staff‘
- Collaboration Layer: Built on top of foundational components, this layer manages and streamlines the collaborative efforts of individual agents. It introduces two mechanisms: Knowledge Sharing and Encapsulating Workflows.
- Knowledge Sharing: This acts because the collaborative glue that binds agents together. Agents can store, retrieve, and share information at various levels, due to this fact reducing redundancy and enhancing operational efficiency.
- Encapsulating Workflows: That is where Standardized Operating Procedures (SOPs) come into play. SOPs act as blueprints that break down tasks into manageable components. Agents are assigned these sub-tasks, and their performance is aligned with standardized outputs.
MetaGPT also uses “Role Definitions” to initiate various specialized agents similar to Product Managers, Architects, etc. as we discussed above. These roles are characterised by key attributes like name, profile, goal, constraints, and outline.
Moreover, “Anchor Agents” provides role-specific guidance to those agents. For instance, a Product Manager’s role may be initialized with the constraint of “efficiently making a successful product.” Anchor agents be certain that agents’ behaviors align with the overarching goals, thereby optimizing performance.
Cognitive Processes in MetaGPT Agents
MetaGPT can observe, think, reflect, and act. They operate through specific behavioral functions like _think()
, _observe()
, _publish_message()
, etc. This cognitive modeling equips the agents to be energetic learners that may adapt and evolve.
- Observe: Agents scan their environment and incorporate key data into their Memory.
- Think & Reflect: Through the
_think()
function, roles deliberate before undertaking actions. - Broadcast Messages: Agents used
_publish_message()
to share current task statuses and related motion records. - Knowledge Precipitation & Act: Agents assess incoming messages and update their internal repositories before deciding on the subsequent plan of action.
- State Management: With features like task locking and standing updating, roles can process multiple actions sequentially without interruption, mirroring real-world human collaboration.
Code-Review Mechanisms for MetaGPT
Code review is a critical component within the software development life cycle, yet it’s absent in several popular frameworks. Each MetaGPT and AgentVerse support code review capabilities, but MetaGPT goes a step further. It also incorporates precompilation execution, which aids in early error detection and subsequently elevates code quality. Given the iterative nature of coding, this feature isn’t just an add-on but a requirement for any mature development framework.
Quantitative experiments conducted across several tasks revealed that MetaGPT outperformed its counterparts in almost every scenario. Pass@1 is a measure of the framework’s ability to generate accurate code in a single iteration. This metric offers a more realistic reflection of a framework’s utility in a practical setting. The next Pass@1 rate means less debugging and more efficiency, directly impacting development cycles and costs. When stacked against other advanced code generation tools similar to CodeX, CodeT, and even GPT-4, MetaGPT outperforms all of them. The framework’s ability to realize an 81.7% to 82.3% Pass@1 rate on HumanEval and MBPP benchmarks.
The framework also uses fewer tokens and computational resources, achieving a high success rate at a fraction of traditional software engineering costs. The info indicated a median cost of just $1.09 per project with MetaGPT which is only a fraction of what a developer would charge for a similar task.
Steps to Locally Installing MetaGPT on Your System
NPM, Python Installation
- Check & Install NPM: First things first, ensure NPM is installed in your system. If it isn’t, you’ll have to install node.js. To ascertain if you’ve npm, run this command in your terminal:
npm --version
. In the event you see a version number, you are good to go. - To put in
mermaid-js
, a dependency for MetaGPT, run:sudo npm install -g @mermaid-js/mermaid-cli
ornpm install -g @mermaid-js/mermaid-cli
- Confirm Python Version: Make sure that you’ve Python 3.9 or above. To ascertain your Python version, open your terminal and kind:
python --version
. In the event you’re not up-to-date, download the newest version from the Python official website. - Clone MetaGPT Repository: Start by cloning the MetaGPT GitHub repository using the command
git clone https://github.com/geekan/metagpt
. Make certain you’ve Git installed in your system for this. If not, visit here. - Navigate to Directory: Once cloned, navigate to the MetaGPT directory using the command
cd metagpt
. - Installation: Execute the Python setup script to put in MetaGPT with the command
python setup.py install
. - Create an Application: Run
python startup.py "ENTER-PROMPT" --code_review True
Note:
- Your recent project should now be within the
workspace/
directory. --code_review True
will allow the GPT model to do extra operations which is able to make sure the code runs accurately but note that it should cost more.- In the event you encounter a permission error during installation, try running
python setup.py install --user
in its place. - For access to specific releases and further details, visit the official MetaGPT GitHub releases page: MetaGPT Releases.
Docker Installation
For many who prefer containerization, Docker simplifies the method:
- Pull the Docker Image: Download the MetaGPT official image and prepare the configuration file:
docker pull metagpt/metagpt:v0.3.1
mkdir -p /opt/metagpt/{config,workspace}
docker run --rm metagpt/metagpt:v0.3.1 cat /app/metagpt/config/config.yaml > /opt/metagpt/config/key.yaml
vim /opt/metagpt/config/key.yaml
- Run the MetaGPT Container: Execute the container with the next command:
docker run --rm --privileged
-v /opt/metagpt/config/key.yaml:/app/metagpt/config/key.yaml
-v /opt/metagpt/workspace:/app/metagpt/workspace
metagpt/metagpt:v0.3.1
python startup.py "Create a straightforward and interactive CLI based rock, paper and scissors game" --code_review True
Configuring MetaGPT with Your OpenAI API Key
After the initial setup, you’ll have to integrate MetaGPT along with your OpenAI API Key. Listed below are the steps to accomplish that:
- Locate or Generate Your OpenAI Key: You could find this key in your OpenAI Dashboard under API settings.
- Set the API Key: You may have the choice to put the API key in either
config/key.yaml
,config/config.yaml
, or set it as an environment variable (env
). The precedence order isconfig/key.yaml > config/config.yaml > env
. - To set the important thing, navigate to
config/key.yaml
and replace the placeholder text along with your OpenAI key:OPENAI_API_KEY: "sk-..."
Remember to safeguard your OpenAI API Key. Never commit it to a public repository or share it with unauthorized individuals.
Use-Case Illustration
I gave the target to develop a CLI-based rock, paper, and scissors game, and MetaGPT successfully executed the duty.
Below is a video that showcases the actual run of the generated game code.
MetaGPT provided a system design document in Markdown—a commonly used lightweight markup language. This Markdown file was replete with UML diagrams, thereby offering a granular view of the architectural blueprint. Furthermore, API specifications were detailed with HTTP methods, endpoints, request/response objects, and standing codes
The category diagram details the attributes and methods of our Game
class, providing an abstraction that is simple to know. It even visualizes the decision flow of this system, effectively turning abstract ideas into tangible steps.
Not only does this significantly reduce the manual overhead in planning, nevertheless it also accelerates the decision-making process, ensuring that your development pipeline stays agile. With MetaGPT, you are not just automating code generation, you are automating intelligent project planning, thus providing a competitive edge in rapid application development.
Conclusion: MetaGPT—Revolutionizing Software Development
MetaGPT redefines the landscape of generative AI and software development, offering a seamless mix of intelligent automation and agile project management. Far surpassing the capabilities of ChatGPT, AutoGPT, and traditional LangChain models it excels in task decomposition, efficient code generation, and project planning. Learn more on
Listed below are the important thing takeaways from this text:
- The Power of Meta-Programming: By employing meta-programming, MetaGPT provides an agile and adaptive software framework. It transcends the narrow functionality of legacy tools and introduces a transformative approach that handles not only coding, but project management and decision-making elements as well.
- Two-Layered Architecture: With its foundational and collaborative layers, MetaGPT effectively creates a synergistic ecosystem where agents can work cohesively, akin to an expertly managed software team.
- Optimized Code Review: Beyond just generating code, MetaGPT offers precompilation execution features, which is basically an early-warning system for errors. This not only saves debugging time but additionally assures code quality.
- Cognitive Agents: MetaGPT’s intelligent agents, replete with cognitive functions like _observe(), _think(), and _publish_message(), evolve and adapt, ensuring your software solution is not only coded but is ‘intelligent.’
- Installation & Deployment: We have illustrated that MetaGPT will be easily arrange, whether you favor a neighborhood installation via npm and Python, or containerization via Docker.