From c619b29d12cdb57ad17becf594a9d2388352c398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Fri, 14 Jun 2024 18:08:04 +0800 Subject: [PATCH] feat: +mgx --- examples/mgx_write_project_framework.py | 14 +++++++++++--- .../requirement_analysis/framework/__init__.py | 2 ++ metagpt/prompts/di/team_leader.py | 3 ++- metagpt/strategy/experience_retriever.py | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/examples/mgx_write_project_framework.py b/examples/mgx_write_project_framework.py index b5d982b72..dca684478 100644 --- a/examples/mgx_write_project_framework.py +++ b/examples/mgx_write_project_framework.py @@ -40,6 +40,16 @@ class EnvBuilder(BaseModel): env = Environment(context=self.context) team_leader = TeamLeader() architect = Architect() + architect.tools.extend( + [ + "CompressExternalInterfaces", + "DetectInteraction", + "EvaluateTRD", + "WriteTRD", + "WriteFramework", + "EvaluateFramework", + ] + ) # Prepare context use_case_actors = "".join([f"- {v}: {k}\n" for k, v in self.actors.items()]) @@ -98,12 +108,10 @@ async def develop( msg = """ 根据"User Requirements"中的用户需求,写TRD ## User Requirements -```json {user_requirements} -``` """ env.publish_message( - UserMessage(content=msg.format(user_requirements=f"{user_requirements}"), send_to=any_to_str(TeamLeader)) + UserMessage(content=msg.format(user_requirements="\n".join(user_requirements)), send_to=any_to_str(TeamLeader)) ) while not env.is_idle: diff --git a/metagpt/actions/requirement_analysis/framework/__init__.py b/metagpt/actions/requirement_analysis/framework/__init__.py index d863cf352..0f6022444 100644 --- a/metagpt/actions/requirement_analysis/framework/__init__.py +++ b/metagpt/actions/requirement_analysis/framework/__init__.py @@ -16,9 +16,11 @@ from pydantic import BaseModel from metagpt.actions.requirement_analysis.framework.evaluate_framework import EvaluateFramework from metagpt.actions.requirement_analysis.framework.write_framework import WriteFramework from metagpt.const import DEFAULT_WORKSPACE_ROOT +from metagpt.tools.tool_registry import register_tool from metagpt.utils.common import CodeParser, awrite +@register_tool(tags=["software framework"]) async def save_framework(dir_data: str, output_dir: Optional[Union[str, Path]] = None) -> List[str]: output_dir = Path(output_dir) if output_dir else DEFAULT_WORKSPACE_ROOT / uuid.uuid4().hex output_dir.mkdir(parents=True, exist_ok=True) diff --git a/metagpt/prompts/di/team_leader.py b/metagpt/prompts/di/team_leader.py index 2e4a17932..5f2f6b27d 100644 --- a/metagpt/prompts/di/team_leader.py +++ b/metagpt/prompts/di/team_leader.py @@ -18,7 +18,8 @@ Note: 1. If the requirement is a pure DATA-RELATED requirement, such as bug fixes, issue reporting, environment setup, terminal operations, pip install, web browsing, web scraping, web searching, web imitation, data science, data analysis, machine learning, deep learning, text-to-image etc. DON'T decompose it, assign a single task with the original user requirement as instruction directly to Data Analyst. 2. If the requirement is developing a software, game, app, or website, excluding the above data-related tasks, you should decompose the requirement into multiple tasks and assign them to different team members based on their expertise, usually the sequence of Product Manager -> Architect -> Project Manager -> Engineer -> (optional: QaEngine if present) -> (optional: DataAnalyst if user requests deployment), each assigned ONE task. When publishing message to Product Manager, you should directly copy the full original user requirement. 3. If the requirement contains both DATA-RELATED part mentioned in 1 and software development part mentioned in 2, you should decompose the software development part and assign them to different team members based on their expertise, and assign the DATA-RELATED part to Data Analyst David directly. -4. It it helpful for Engineer to have both the system design and the project schedule for writing the code, so include paths of both files (if available) when publishing message to Engineer. +4. It is helpful for Engineer to have both the system design and the project schedule for writing the code, so include paths of both files (if available) when publishing message to Engineer. +5. If the requirement is writing a TRD, you should assign it to Architect. When publishing message to Architect, you should directly copy the full original user requirement. """ FINISH_CURRENT_TASK_CMD = """ diff --git a/metagpt/strategy/experience_retriever.py b/metagpt/strategy/experience_retriever.py index c122affb5..97fb9a9b0 100644 --- a/metagpt/strategy/experience_retriever.py +++ b/metagpt/strategy/experience_retriever.py @@ -162,7 +162,7 @@ class SimpleExpRetriever(ExpRetriever): """ def retrieve(self, context: str = "") -> str: - return self.EXAMPLE + return "" # byRFC243 self.EXAMPLE class KeywordExpRetriever(ExpRetriever):