diff --git a/metagpt/actions/design_api.py b/metagpt/actions/design_api.py index e23fcdb2e..055365421 100644 --- a/metagpt/actions/design_api.py +++ b/metagpt/actions/design_api.py @@ -51,7 +51,7 @@ class WriteDesign(Action): "clearly and in detail." ) - async def run(self, with_messages: Message, schema: str = CONFIG.prompt_format): + async def run(self, with_messages: Message, schema: str = CONFIG.prompt_schema): # Use `git diff` to identify which PRD documents have been modified in the `docs/prds` directory. prds_file_repo = CONFIG.git_repo.new_file_repository(PRDS_FILE_REPO) changed_prds = prds_file_repo.changed_files @@ -81,11 +81,11 @@ class WriteDesign(Action): # leaving room for global optimization in subsequent steps. return ActionOutput(content=changed_files.json(), instruct_content=changed_files) - async def _new_system_design(self, context, schema=CONFIG.prompt_format): + async def _new_system_design(self, context, schema=CONFIG.prompt_schema): node = await DESIGN_API_NODE.fill(context=context, llm=self.llm, schema=schema) return node - async def _merge(self, prd_doc, system_design_doc, schema=CONFIG.prompt_format): + async def _merge(self, prd_doc, system_design_doc, schema=CONFIG.prompt_schema): context = NEW_REQ_TEMPLATE.format(old_design=system_design_doc.content, context=prd_doc.content) node = await DESIGN_API_NODE.fill(context=context, llm=self.llm, schema=schema) system_design_doc.content = node.instruct_content.json(ensure_ascii=False) diff --git a/metagpt/actions/project_management.py b/metagpt/actions/project_management.py index 3086c4d96..095881e60 100644 --- a/metagpt/actions/project_management.py +++ b/metagpt/actions/project_management.py @@ -45,7 +45,7 @@ class WriteTasks(Action): context: Optional[str] = None llm: BaseGPTAPI = Field(default_factory=LLM) - async def run(self, with_messages, schema=CONFIG.prompt_format): + async def run(self, with_messages, schema=CONFIG.prompt_schema): system_design_file_repo = CONFIG.git_repo.new_file_repository(SYSTEM_DESIGN_FILE_REPO) changed_system_designs = system_design_file_repo.changed_files @@ -92,14 +92,14 @@ class WriteTasks(Action): await self._save_pdf(task_doc=task_doc) return task_doc - async def _run_new_tasks(self, context, schema=CONFIG.prompt_format): + async def _run_new_tasks(self, context, schema=CONFIG.prompt_schema): node = await PM_NODE.fill(context, self.llm, schema) # prompt_template, format_example = get_template(templates, format) # prompt = prompt_template.format(context=context, format_example=format_example) # rsp = await self._aask_v1(prompt, "task", OUTPUT_MAPPING, format=format) return node - async def _merge(self, system_design_doc, task_doc, schema=CONFIG.prompt_format) -> Document: + async def _merge(self, system_design_doc, task_doc, schema=CONFIG.prompt_schema) -> Document: context = NEW_REQ_TEMPLATE.format(context=system_design_doc.content, old_tasks=task_doc.content) node = await PM_NODE.fill(context, self.llm, schema) task_doc.content = node.instruct_content.json(ensure_ascii=False) diff --git a/metagpt/actions/rebuild_class_view.py b/metagpt/actions/rebuild_class_view.py index 6da3e2989..2a6a6a6d9 100644 --- a/metagpt/actions/rebuild_class_view.py +++ b/metagpt/actions/rebuild_class_view.py @@ -21,7 +21,7 @@ class RebuildClassView(Action): def __init__(self, name="", context=None, llm=None): super().__init__(name=name, context=context, llm=llm) - async def run(self, with_messages=None, format=CONFIG.prompt_format): + async def run(self, with_messages=None, format=CONFIG.prompt_schema): graph_repo_pathname = CONFIG.git_repo.workdir / GRAPH_REPO_FILE_REPO / CONFIG.git_repo.workdir.name graph_db = await DiGraphRepository.load_from(str(graph_repo_pathname.with_suffix(".json"))) repo_parser = RepoParser(base_directory=self.context) diff --git a/metagpt/actions/write_prd.py b/metagpt/actions/write_prd.py index 071eacd29..47e02b699 100644 --- a/metagpt/actions/write_prd.py +++ b/metagpt/actions/write_prd.py @@ -69,7 +69,7 @@ class WritePRD(Action): content: Optional[str] = None llm: BaseGPTAPI = Field(default_factory=LLM) - async def run(self, with_messages, schema=CONFIG.prompt_format, *args, **kwargs) -> ActionOutput | Message: + async def run(self, with_messages, schema=CONFIG.prompt_schema, *args, **kwargs) -> ActionOutput | Message: # Determine which requirement documents need to be rewritten: Use LLM to assess whether new requirements are # related to the PRD. If they are related, rewrite the PRD. docs_file_repo = CONFIG.git_repo.new_file_repository(relative_path=DOCS_FILE_REPO) @@ -113,7 +113,7 @@ class WritePRD(Action): # optimization in subsequent steps. return ActionOutput(content=change_files.json(), instruct_content=change_files) - async def _run_new_requirement(self, requirements, schema=CONFIG.prompt_format) -> ActionOutput: + async def _run_new_requirement(self, requirements, schema=CONFIG.prompt_schema) -> ActionOutput: # sas = SearchAndSummarize() # # rsp = await sas.run(context=requirements, system_text=SEARCH_AND_SUMMARIZE_SYSTEM_EN_US) # rsp = "" @@ -132,7 +132,7 @@ class WritePRD(Action): node = await WP_IS_RELATIVE_NODE.fill(context, self.llm) return node.get("is_relative") == "YES" - async def _merge(self, new_requirement_doc, prd_doc, schema=CONFIG.prompt_format) -> Document: + async def _merge(self, new_requirement_doc, prd_doc, schema=CONFIG.prompt_schema) -> Document: if not CONFIG.project_name: CONFIG.project_name = Path(CONFIG.project_path).name prompt = NEW_REQ_TEMPLATE.format(requirements=new_requirement_doc.content, old_prd=prd_doc.content) diff --git a/metagpt/config.py b/metagpt/config.py index 45bdb9bdc..9a452cab0 100644 --- a/metagpt/config.py +++ b/metagpt/config.py @@ -185,7 +185,7 @@ class Config(metaclass=Singleton): self._get("WORKSPACE_UID") or f"{datetime.datetime.now().strftime('%Y%m%d%H%M%S')}-{uuid4().hex[-8:]}" ) self.repair_llm_output = self._get("REPAIR_LLM_OUTPUT", False) - self.prompt_format = self._get("PROMPT_FORMAT", "json") + self.prompt_schema = self._get("PROMPT_FORMAT", "json") self.workspace_path = Path(self._get("WORKSPACE_PATH", DEFAULT_WORKSPACE_ROOT)) val = self._get("WORKSPACE_PATH_WITH_UID") if val and val.lower() == "true": # for agent diff --git a/metagpt/utils/get_template.py b/metagpt/utils/get_template.py index b6dea00ae..7e05e5d5e 100644 --- a/metagpt/utils/get_template.py +++ b/metagpt/utils/get_template.py @@ -8,7 +8,7 @@ from metagpt.config import CONFIG -def get_template(templates, schema=CONFIG.prompt_format): +def get_template(templates, schema=CONFIG.prompt_schema): selected_templates = templates.get(schema) if selected_templates is None: raise ValueError(f"Can't find {schema} in passed in templates")