From f17b00ed1c16efc81e9e560b1a8a1049a2f45047 Mon Sep 17 00:00:00 2001 From: femto Date: Mon, 11 Sep 2023 13:19:05 +0800 Subject: [PATCH] project management --- metagpt/actions/project_management.py | 8 +++++--- metagpt/roles/qa_engineer.py | 2 +- tests/metagpt/roles/test_product_manager.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/metagpt/actions/project_management.py b/metagpt/actions/project_management.py index cc62425c0..40b3204ab 100644 --- a/metagpt/actions/project_management.py +++ b/metagpt/actions/project_management.py @@ -9,6 +9,7 @@ from typing import List from metagpt.actions.action import Action from metagpt.const import WORKSPACE_ROOT +from metagpt.utils.common import CodeParser from metagpt.utils.json_to_markdown import json_to_markdown PROMPT_TEMPLATE = """ @@ -83,9 +84,10 @@ class WriteTasks(Action): super().__init__(name, context, llm) def _save(self, context, rsp): - ws_name = context[-1].instruct_content.dict()[ - "Python package name" - ] # CodeParser.parse_str(block="Python package name", text=context[-1].content) + if context[-1].instruct_content: + ws_name = context[-1].instruct_content.dict()["Python package name"] + else: + ws_name = CodeParser.parse_str(block="Python package name", text=context[-1].content) file_path = WORKSPACE_ROOT / ws_name / "docs/api_spec_and_tasks.md" file_path.write_text(json_to_markdown(rsp.instruct_content.dict())) diff --git a/metagpt/roles/qa_engineer.py b/metagpt/roles/qa_engineer.py index 65bf2cc5b..543912f3c 100644 --- a/metagpt/roles/qa_engineer.py +++ b/metagpt/roles/qa_engineer.py @@ -36,7 +36,7 @@ class QaEngineer(Role): @classmethod def parse_workspace(cls, system_design_msg: Message) -> str: - if not system_design_msg.instruct_content: + if system_design_msg.instruct_content: return system_design_msg.instruct_content.dict().get("Python package name") return CodeParser.parse_str(block="Python package name", text=system_design_msg.content) diff --git a/tests/metagpt/roles/test_product_manager.py b/tests/metagpt/roles/test_product_manager.py index 34c70efbc..21def787f 100644 --- a/tests/metagpt/roles/test_product_manager.py +++ b/tests/metagpt/roles/test_product_manager.py @@ -18,4 +18,4 @@ async def test_product_manager(): rsp = await product_manager.handle(MockMessages.req) logger.info(rsp) assert len(rsp.content) > 0 - assert "产品目标" in rsp.content + assert "Product Goals" in rsp.content