🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
formatting
garylin2099705a3e962b2d
diff --git a/examples/build_customized_agent.py b/examples/build_customized_agent.pyindex ed00e8320..be34e5e5e 100644--- a/examples/build_customized_agent.py+++ b/examples/build_customized_agent.py@@ -9,6 +9,7 @@ import asyncioimport fire+from metagpt.llm import LLMfrom metagpt.actions import Actionfrom metagpt.roles import Rolefrom metagpt.schema import Message@@ -22,7 +23,7 @@ class SimpleWriteCode(Action):your code:"""- def __init__(self, name="SimpleWriteCode", context=None, llm=None):+ def __init__(self, name: str = "SimpleWriteCode", context=None, llm: LLM = None):super().__init__(name, context, llm)async def run(self, instruction: str):@@ -42,8 +43,9 @@ class SimpleWriteCode(Action):code_text = match.group(1) if match else rspreturn code_text+class SimpleRunCode(Action):- def __init__(self, name="SimpleRunCode", context=None, llm=None):+ def __init__(self, name: str = "SimpleRunCode", context=None, llm: LLM = None):super().__init__(name, context, llm)async def run(self, code_text: str):@@ -52,6 +54,7 @@ class SimpleRunCode(Action):logger.info(f"{code_result=}")return code_result+class SimpleCoder(Role):def __init__(self,@@ -73,6 +76,7 @@ class SimpleCoder(Role):return msg+class RunnableCoder(Role):def __init__(self,@@ -97,6 +101,7 @@ class RunnableCoder(Role):self._rc.memory.add(msg)return msg+def main(msg="write a function that calculates the product of a list and run it"):# role = SimpleCoder()role = RunnableCoder()diff --git a/examples/build_customized_multi_agents.py b/examples/build_customized_multi_agents.pyindex 02221e8e9..0df927e32 100644--- a/examples/build_customized_multi_agents.py+++ b/examples/build_customized_multi_agents.py@@ -6,6 +6,8 @@ Author: garylin2099import reimport asyncioimport fire++from metagpt.llm import LLMfrom metagpt.actions import Action, BossRequirementfrom metagpt.roles import Rolefrom metagpt.team import Team@@ -26,7 +28,7 @@ class SimpleWriteCode(Action):your code:"""- def __init__(self, name="SimpleWriteCode", context=None, llm=None):+ def __init__(self, name: str = "SimpleWriteCode", context=None, llm: LLM = None):super().__init__(name, context, llm)async def run(self, instruction: str):@@ -39,6 +41,7 @@ class SimpleWriteCode(Action):return code_text+class SimpleCoder(Role):def __init__(self,@@ -50,6 +53,7 @@ class SimpleCoder(Role):self._watch([BossRequirement])self._init_actions([SimpleWriteCode])+class SimpleWriteTest(Action):PROMPT_TEMPLATE = """@@ -59,7 +63,7 @@ class SimpleWriteTest(Action):your code:"""- def __init__(self, name="SimpleWriteTest", context=None, llm=None):+ def __init__(self, name: str = "SimpleWriteTest", context=None, llm: LLM = None):super().__init__(name, context, llm)async def run(self, context: str, k: int = 3):@@ -72,6 +76,7 @@ class SimpleWriteTest(Action):return code_text+class SimpleTester(Role):def __init__(self,@@ -96,6 +101,7 @@ class SimpleTester(Role):return msg+class SimpleWriteReview(Action):PROMPT_TEMPLATE = """@@ -103,7 +109,7 @@ class SimpleWriteReview(Action):Review the test cases and provide one critical comments:"""- def __init__(self, name="SimpleWriteReview", context=None, llm=None):+ def __init__(self, name: str = "SimpleWriteReview", context=None, llm: LLM = None):super().__init__(name, context, llm)async def run(self, context: str):@@ -114,6 +120,7 @@ class SimpleWriteReview(Action):return rsp+class SimpleReviewer(Role):def __init__(self,@@ -125,6 +132,7 @@ class SimpleReviewer(Role):self._init_actions([SimpleWriteReview])self._watch([SimpleWriteTest])+async def main(idea: str = "write a function that calculates the product of a list",investment: float = 3.0,