From 42565c39e3f51682dc0521a0a122dd1f1c978feb Mon Sep 17 00:00:00 2001 From: mannaandpoem <1580466765@qq.com> Date: Fri, 19 Jan 2024 09:08:29 +0800 Subject: [PATCH] 1. rename and modify guideline to plan 2. update prompt in ActionNode 3. add code comment 4. refactor Guideline code structure --- metagpt/actions/write_code.py | 4 ++-- metagpt/actions/write_code_review.py | 4 ++-- metagpt/const.py | 1 - metagpt/roles/engineer.py | 6 +++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/metagpt/actions/write_code.py b/metagpt/actions/write_code.py index 93c7a2f65..093633a8b 100644 --- a/metagpt/actions/write_code.py +++ b/metagpt/actions/write_code.py @@ -29,8 +29,8 @@ from metagpt.const import ( BUGFIX_FILENAME, CODE_SUMMARIES_FILE_REPO, DOCS_FILE_REPO, + PLAN_FILE_REPO, PLAN_FILENAME, - PLAN_PDF_FILE_REPO, REQUIREMENT_FILENAME, TASK_FILE_REPO, TEST_OUTPUTS_FILE_REPO, @@ -107,7 +107,7 @@ class WriteCode(Action): test_doc = await FileRepository.get_file( filename="test_" + coding_context.filename + ".json", relative_path=TEST_OUTPUTS_FILE_REPO ) - plan_doc = await FileRepository.get_file(filename=PLAN_FILENAME, relative_path=PLAN_PDF_FILE_REPO) + plan_doc = await FileRepository.get_file(filename=PLAN_FILENAME, relative_path=PLAN_FILE_REPO) plan = plan_doc.content if plan_doc else "" requirement_doc = await FileRepository.get_file(filename=REQUIREMENT_FILENAME, relative_path=DOCS_FILE_REPO) summary_doc = None diff --git a/metagpt/actions/write_code_review.py b/metagpt/actions/write_code_review.py index 72424c037..2b9c7bd10 100644 --- a/metagpt/actions/write_code_review.py +++ b/metagpt/actions/write_code_review.py @@ -16,8 +16,8 @@ from metagpt.actions.action import Action from metagpt.config import CONFIG from metagpt.const import ( DOCS_FILE_REPO, + PLAN_FILE_REPO, PLAN_FILENAME, - PLAN_PDF_FILE_REPO, REQUIREMENT_FILENAME, ) from metagpt.logs import logger @@ -145,7 +145,7 @@ class WriteCodeReview(Action): async def run(self, *args, **kwargs) -> CodingContext: iterative_code = self.context.code_doc.content k = CONFIG.code_review_k_times or 1 - plan_doc = await FileRepository.get_file(filename=PLAN_FILENAME, relative_path=PLAN_PDF_FILE_REPO) + plan_doc = await FileRepository.get_file(filename=PLAN_FILENAME, relative_path=PLAN_FILE_REPO) plan = plan_doc.content if plan_doc else "" mode = "plan" if plan else "normal" diff --git a/metagpt/const.py b/metagpt/const.py index 014193b59..8f0eeef23 100644 --- a/metagpt/const.py +++ b/metagpt/const.py @@ -100,7 +100,6 @@ SEQ_FLOW_FILE_REPO = "resources/seq_flow" SYSTEM_DESIGN_PDF_FILE_REPO = "resources/system_design" PRD_PDF_FILE_REPO = "resources/prd" TASK_PDF_FILE_REPO = "resources/api_spec_and_tasks" -PLAN_PDF_FILE_REPO = "resources/plan" TEST_CODES_FILE_REPO = "tests" TEST_OUTPUTS_FILE_REPO = "test_outputs" CODE_SUMMARIES_FILE_REPO = "docs/code_summaries" diff --git a/metagpt/roles/engineer.py b/metagpt/roles/engineer.py index 695e9dd2a..2803c8668 100644 --- a/metagpt/roles/engineer.py +++ b/metagpt/roles/engineer.py @@ -37,7 +37,7 @@ from metagpt.const import ( CODE_SUMMARIES_PDF_FILE_REPO, PLAN_FILE_REPO, PLAN_FILENAME, - PLAN_PDF_FILE_REPO, + PRDS_FILE_REPO, SYSTEM_DESIGN_FILE_REPO, TASK_FILE_REPO, ) @@ -123,7 +123,7 @@ class Engineer(Role): dependencies = {coding_context.design_doc.root_relative_path, coding_context.task_doc.root_relative_path} if mode == "plan": - dependencies.add(os.path.join(PLAN_PDF_FILE_REPO, PLAN_FILENAME)) + dependencies.add(os.path.join(PLAN_FILE_REPO, PLAN_FILENAME)) await src_file_repo.save( coding_context.filename, dependencies=dependencies, @@ -340,7 +340,7 @@ class Engineer(Role): user_requirement = str(self.rc.memory.get_by_role("Human")[0]) pool_contents = [] - prd = await FileRepository.get_all_files(relative_path=PLAN_PDF_FILE_REPO) + prd = await FileRepository.get_all_files(relative_path=PRDS_FILE_REPO) for doc in prd: prd_json = json.loads(doc.content) product_requirement_pool = prd_json.get(REFINED_REQUIREMENT_POOL.key) or prd_json.get(REQUIREMENT_POOL.key)