🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
update tools according to intention update TaskTypeDef for software development
stellahsreef0375c6c8e
diff --git a/examples/mgx/run_mgx.py b/examples/mgx/run_mgx.pyindex edfaff3d7..86aa67ad7 100644--- a/examples/mgx/run_mgx.py+++ b/examples/mgx/run_mgx.py@@ -9,13 +9,13 @@ requirement = (# "design a game using Gym (an open source Python library), including a graphical interface and interactive gameplay"# "帮我把pip的源设置成:https://pypi.tuna.tsinghua.edu.cn/simple"# "This is a website url does not require login: https://demosc.chinaz.net/Files/DownLoad//moban/202404/moban7767 please write a similar web page,developed in vue language, The package.json dependency must be generated"- # "I would like to imitate the website available at https://demosc.chinaz.net/Files/DownLoad//moban/202404/moban7767. Could you please browse through it?"- "Create a 2048 Game"+ "I would like to imitate the website available at https://demosc.chinaz.net/Files/DownLoad//moban/202404/moban7767. Could you please browse through it?"+ # "Create a 2048 Game")async def main(requirement: str = ""):- mgx = MGX(use_intent=True, tools=["software development"])+ mgx = MGX(use_intent=True, tools=["<all>"])await mgx.run(requirement)diff --git a/metagpt/actions/di/detect_intent.py b/metagpt/actions/di/detect_intent.pyindex 5d25e9fbe..d7187c4f3 100644--- a/metagpt/actions/di/detect_intent.py+++ b/metagpt/actions/di/detect_intent.py@@ -98,10 +98,12 @@ To meet user requirements, the following standard operating procedure(SOP) must{sop}-### SOP Type-{sop_type}+"""+### SOP Type+# {sop_type}+class DetectIntent(Action):async def run(self, with_message: Message, **kwargs) -> Tuple[str, str]:diff --git a/metagpt/actions/di/write_plan.py b/metagpt/actions/di/write_plan.pyindex 83709bc1a..201280d9b 100644--- a/metagpt/actions/di/write_plan.py+++ b/metagpt/actions/di/write_plan.py@@ -29,15 +29,15 @@ If you are modifying an existing plan, carefully follow the instruction, don't mIf you encounter errors on the current task, revise and output the current single task only.Output a list of jsons following the format:```json-[- {{- "task_id": str = "unique identifier for a task in plan, can be an ordinal",- "dependent_task_ids": list[str] = "ids of tasks prerequisite to this task",- "instruction": "what you should do in this task, one short phrase or sentence. If the SOP description is provided in the `Knowledge` section, the reference to the SOP description should be included intact in the instruction.",- "task_type": "type of this task, should be one of Available Task Types. You can refer to the hints in the `SOP Type` section to make a selection if `SOP Type` section is provided.",- }},- ...-]+ [+ {{+ "task_id": str = "unique identifier for a task in plan, can be an ordinal",+ "dependent_task_ids": list[str] = "ids of tasks prerequisite to this task",+ "instruction": "what you should do in this task, one short phrase or sentence",+ "task_type": "type of this task, should be one of Available Task Types",+ }},+ ...+ ]```"""diff --git a/metagpt/roles/di/mgx.py b/metagpt/roles/di/mgx.pyindex 0fa7c77b6..9d2f182e3 100644--- a/metagpt/roles/di/mgx.py+++ b/metagpt/roles/di/mgx.py@@ -4,10 +4,11 @@import asynciofrom typing import Dict-from metagpt.actions.di.detect_intent import DetectIntent+from metagpt.actions.di.detect_intent import DetectIntent, SOPItemfrom metagpt.logs import loggerfrom metagpt.roles.di.data_interpreter import DataInterpreterfrom metagpt.schema import Message+from metagpt.tools.tool_recommend import BM25ToolRecommenderclass MGX(DataInterpreter):@@ -18,6 +19,10 @@ class MGX(DataInterpreter):todo = DetectIntent(context=self.context)request_with_sop, sop_type = await todo.run(user_msg)logger.info(f"{sop_type} {request_with_sop}")+ if sop_type == SOPItem.SOFTWARE_DEVELOPMENT.type_name:+ self.tool_recommender = BM25ToolRecommender(tools=["software development"])+ else:+ self.tool_recommender = BM25ToolRecommender(tools=["<all>"])return request_with_sopasync def _plan_and_act(self) -> Message: