From 4067127525bd9100582881f1b88c88c762748fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BC=9F=E9=9F=AC?= Date: Mon, 21 Oct 2024 14:25:08 +0800 Subject: [PATCH] Generate mermaid files after completing the system design. --- metagpt/prompts/di/architect.py | 7 ++++--- metagpt/roles/di/role_zero.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/metagpt/prompts/di/architect.py b/metagpt/prompts/di/architect.py index e6ea77e2b..6b87d1f93 100644 --- a/metagpt/prompts/di/architect.py +++ b/metagpt/prompts/di/architect.py @@ -60,9 +60,9 @@ ARCHITECT_INSTRUCTION = """ You are an architect. Your task is to design a software system that meets the requirements. Note: -1. If Product Requirement Document is provided, read the document and use it as the requirement. -2. If no programming language is specified, use Vite, React, MUI and Tailwind CSS as the programming language. -3. When use Vite, React, MUI and Tailwind CSS, view the default project structure before start to design. Execute "mkdir -p {{project_name}} && tree /path/of/the/template". This must be a single response WITHOUT other commands. React template is in {react_template_path} and Vue template is in {vue_template_path}. +1. If Product Requirement Document is provided, read the document and use it as the requirement. If the Programming Language in PRD is Vite, React, MUI and Tailwind CSS, use the template. +2. Default programming language is Vite, React, MUI and Tailwind CSS. React template is in {react_template_path} and Vue template is in {vue_template_path}. +3. Execute "mkdir -p {{project_name}} && tree /path/of/the/template" to clear template structure if you want to use template. This must be a single response WITHOUT other commands. 4. The system design must adhere to the following rules: 4.1 Chapter in the system design should include: Implementation approach: Analyze the difficult points of the requirements, select the appropriate open-source framework. @@ -73,6 +73,7 @@ Anything UNCLEAR: Mention unclear project aspects, then try to clarify it. 4.2 System Design Format example: {system_design_example} 5. Use Editor.write to write the system design in markdown format. The file path must be "{{project}}/docs/system_design.md". Use command_name "end" when the system design is finished. +6. If no memtion, always use Editor.write to write "Program call flow" in a new file name "{{project}}/docs/system_design-sequence-diagram.mermaid" and write "Data structures and interfaces" in a new file "{{project}}/docs/system_design-sequence-diagram.mermaid-class-diagram" """.format( system_design_example=SYSTEM_DESIGN_EXAMPLE, vue_template_path=VUE_TEMPLATE_PATH.absolute(), diff --git a/metagpt/roles/di/role_zero.py b/metagpt/roles/di/role_zero.py index 551034f2c..9baafb9b2 100644 --- a/metagpt/roles/di/role_zero.py +++ b/metagpt/roles/di/role_zero.py @@ -537,7 +537,7 @@ class RoleZero(Role): command_output = await self._end() elif cmd["command_name"] == "RoleZero.ask_human": human_response = await self.ask_human(**cmd["args"]) - if human_response.strip().lower() in ["", "stop"]: + if human_response[len("Human response:") :].strip().lower() in ["", "stop"]: human_response += "The user has asked me to stop because I have encountered a problem." self.rc.memory.add(UserMessage(content=human_response, cause_by=RunCommand)) end_output = "\nCommand end executed:"