From 09b6d2df8377883335696c50f21d8956518f75ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Wed, 29 Nov 2023 20:26:26 +0800 Subject: [PATCH] feat: merge geekan:cli-etc --- metagpt/actions/design_api.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/metagpt/actions/design_api.py b/metagpt/actions/design_api.py index 431879c25..2b9c20047 100644 --- a/metagpt/actions/design_api.py +++ b/metagpt/actions/design_api.py @@ -281,11 +281,7 @@ class WriteDesign(Action): # fix project_name, we can't system_design.instruct_content.python_package_name = "xxx" since "project_name" # contain space, have to use setattr - setattr( - system_design.instruct_content, - "project_name", - system_design.instruct_content.dict()["project_name"].strip().strip("'").strip('"'), - ) + self._rename_project_name(system_design=system_design) await self._rename_workspace(system_design) # ======= # # fix project_name, we can't system_design.instruct_content.python_package_name = "xxx" since "project_name" contain space, have to use setattr @@ -303,17 +299,29 @@ class WriteDesign(Action): system_design = await self._aask_v1(prompt, "system_design", OUTPUT_MAPPING, format=format) # fix Python package name, we can't system_design.instruct_content.python_package_name = "xxx" since "Python # package name" contain space, have to use setattr + self._rename_project_name(system_design=system_design) + system_design_doc.content = system_design.instruct_content.json(ensure_ascii=False) + return system_design_doc + + @staticmethod + def _rename_project_name(system_design): + if CONFIG.project_name: + setattr( + system_design.instruct_content, + "project_name", + CONFIG.project_name, + ) + return setattr( system_design.instruct_content, "project_name", system_design.instruct_content.dict()["project_name"].strip().strip("'").strip('"'), ) - system_design_doc.content = system_design.instruct_content.json(ensure_ascii=False) - return system_design_doc @staticmethod async def _rename_workspace(system_design): - if CONFIG.WORKDIR: # Updating on the old version has already been specified if it's valid. + if CONFIG.project_path: # Updating on the old version has already been specified if it's valid. According to + # Section 2.2.3.10 of RFC 135 return if isinstance(system_design, ActionOutput):