Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

feat: remove UserRequirement

莘权 马49ffb79433ab
diff --git a/metagpt/roles/architect.py b/metagpt/roles/architect.py
index 465beff05..9e1761c85 100644
--- a/metagpt/roles/architect.py
+++ b/metagpt/roles/architect.py
@@ -6,11 +6,9 @@
@File : architect.py
"""
-from metagpt.actions import UserRequirement, WritePRD
+from metagpt.actions import WritePRD
from metagpt.actions.design_api import WriteDesign
-from metagpt.actions.prepare_documents import PrepareDocuments
from metagpt.roles.role import Role
-from metagpt.utils.common import any_to_str
class Architect(Role):
@@ -36,22 +34,7 @@ class Architect(Role):
super().__init__(**kwargs)
self.enable_memory = False
# Initialize actions specific to the Architect role
- self.set_actions([PrepareDocuments(send_to=any_to_str(self), context=self.context), WriteDesign])
+ self.set_actions([WriteDesign])
# Set events or actions the Architect should watch or be aware of
- self._watch({UserRequirement, PrepareDocuments, WritePRD})
-
- async def _think(self) -> bool:
- """Decide what to do"""
- mappings = {
- any_to_str(UserRequirement): 0,
- any_to_str(PrepareDocuments): 1,
- any_to_str(WritePRD): 1,
- }
- for i in self.rc.news:
- idx = mappings.get(i.cause_by, -1)
- if idx < 0:
- continue
- self.rc.todo = self.actions[idx]
- return bool(self.rc.todo)
- return False
+ self._watch({WritePRD})
diff --git a/metagpt/roles/engineer.py b/metagpt/roles/engineer.py
index 111e534a6..919b4bf13 100644
--- a/metagpt/roles/engineer.py
+++ b/metagpt/roles/engineer.py
@@ -26,7 +26,7 @@ from typing import List, Optional, Set
from pydantic import BaseModel, Field
-from metagpt.actions import UserRequirement, WriteCode, WriteCodeReview, WriteTasks
+from metagpt.actions import WriteCode, WriteCodeReview, WriteTasks
from metagpt.actions.fix_bug import FixBug
from metagpt.actions.prepare_documents import PrepareDocuments
from metagpt.actions.project_management_an import REFINED_TASK_LIST, TASK_LIST
@@ -103,18 +103,7 @@ class Engineer(Role):
super().__init__(**kwargs)
self.enable_memory = False
self.set_actions([WriteCode])
- self._watch(
- [
- UserRequirement,
- PrepareDocuments,
- WriteTasks,
- SummarizeCode,
- WriteCode,
- WriteCodeReview,
- FixBug,
- WriteCodePlanAndChange,
- ]
- )
+ self._watch([WriteTasks, SummarizeCode, WriteCode, WriteCodeReview, FixBug, WriteCodePlanAndChange])
self.code_todos = []
self.summarize_todos = []
self.next_todo_action = any_to_name(WriteCode)
@@ -275,19 +264,7 @@ class Engineer(Role):
return False
msg = self.rc.news[0]
input_args = msg.instruct_content
- if msg.cause_by == any_to_str(UserRequirement):
- self.rc.todo = PrepareDocuments(
- key_descriptions={
- "project_path": 'the project path if exists in "Original Requirement"',
- "src_filename": 'the file name of the source code file explicitly requested for modification if exists in "Original Requirement"',
- },
- context=self.context,
- send_to=any_to_str(self),
- )
- self.repo = ProjectRepo(input_args.project_path)
- self.input_args = input_args
- return bool(self.rc.todo)
- elif msg.cause_by in {any_to_str(WriteTasks), any_to_str(FixBug)}:
+ if msg.cause_by in {any_to_str(WriteTasks), any_to_str(FixBug)}:
self.input_args = input_args
self.repo = ProjectRepo(input_args.project_path)
if self.repo.src_relative_path is None:
diff --git a/metagpt/roles/project_manager.py b/metagpt/roles/project_manager.py
index 70bd3bf8b..d6374e673 100644
--- a/metagpt/roles/project_manager.py
+++ b/metagpt/roles/project_manager.py
@@ -6,11 +6,9 @@
@File : project_manager.py
"""
-from metagpt.actions import UserRequirement, WriteTasks
+from metagpt.actions import WriteTasks
from metagpt.actions.design_api import WriteDesign
-from metagpt.actions.prepare_documents import PrepareDocuments
from metagpt.roles.role import Role
-from metagpt.utils.common import any_to_str
class ProjectManager(Role):
@@ -35,20 +33,5 @@ class ProjectManager(Role):
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
self.enable_memory = False
- self.set_actions([PrepareDocuments(send_to=any_to_str(self), context=self.context), WriteTasks])
- self._watch([UserRequirement, PrepareDocuments, WriteDesign])
-
- async def _think(self) -> bool:
- """Decide what to do"""
- mappings = {
- any_to_str(UserRequirement): 0,
- any_to_str(PrepareDocuments): 1,
- any_to_str(WriteDesign): 1,
- }
- for i in self.rc.news:
- idx = mappings.get(i.cause_by, -1)
- if idx < 0:
- continue
- self.rc.todo = self.actions[idx]
- return bool(self.rc.todo)
- return False
+ self.set_actions([WriteTasks])
+ self._watch([WriteDesign])
diff --git a/metagpt/roles/qa_engineer.py b/metagpt/roles/qa_engineer.py
index 48ed24c2c..4cc9eb9e2 100644
--- a/metagpt/roles/qa_engineer.py
+++ b/metagpt/roles/qa_engineer.py
@@ -55,12 +55,8 @@ class QaEngineer(Role):
# FIXME: a bit hack here, only init one action to circumvent _think() logic,
# will overwrite _think() in future updates
- self.set_actions(
- [
- WriteTest,
- ]
- )
- self._watch([UserRequirement, PrepareDocuments, SummarizeCode, WriteTest, RunCode, DebugError])
+ self.set_actions([WriteTest])
+ self._watch([SummarizeCode, WriteTest, RunCode, DebugError])
self.test_round = 0
async def _write_test(self, message: Message) -> None: