🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
action reporter
shenchuchengb73024510ba9
diff --git a/metagpt/actions/design_api.py b/metagpt/actions/design_api.pyindex cc88171ff..7fac6710b 100644--- a/metagpt/actions/design_api.py+++ b/metagpt/actions/design_api.py@@ -254,25 +254,29 @@ class WriteDesign(Action):extra_info=to_markdown_code_block(extra_info),prd=to_markdown_code_block(prd_content),)- if not legacy_design_filename:- node = await self._new_system_design(context=context)- design = Document(content=node.instruct_content.model_dump_json())- else:- old_design_content = await aread(filename=legacy_design_filename)- design = await self._merge(- prd_doc=Document(content=context), system_design_doc=Document(content=old_design_content)- )+ async with DocsReporter(enable_llm_stream=True) as reporter:+ await reporter.async_report({"type": "design"}, "meta")+ if not legacy_design_filename:+ node = await self._new_system_design(context=context)+ design = Document(content=node.instruct_content.model_dump_json())+ else:+ old_design_content = await aread(filename=legacy_design_filename)+ design = await self._merge(+ prd_doc=Document(content=context), system_design_doc=Document(content=old_design_content)+ )- if not output_pathname:- output_pathname = Path(output_pathname) / "docs" / "sytem_design.json"- output_pathname.mkdir(parents=True, exist_ok=True)- elif not Path(output_pathname).is_absolute():- output_pathname = DEFAULT_WORKSPACE_ROOT / output_pathname- output_pathname = Path(output_pathname)- await awrite(filename=output_pathname, data=design.content)- output_filename = output_pathname.parent / f"{output_pathname.stem}-class-diagram"- await self._save_data_api_design(design_doc=design, output_filename=output_filename)- output_filename = output_pathname.parent / f"{output_pathname.stem}-sequence-diagram"- await self._save_seq_flow(design_doc=design, output_filename=output_filename)- await save_json_to_markdown(content=design.content, output_filename=output_pathname.with_suffix(".md"))+ if not output_pathname:+ output_pathname = Path(output_pathname) / "docs" / "sytem_design.json"+ output_pathname.mkdir(parents=True, exist_ok=True)+ elif not Path(output_pathname).is_absolute():+ output_pathname = DEFAULT_WORKSPACE_ROOT / output_pathname+ output_pathname = Path(output_pathname)+ await awrite(filename=output_pathname, data=design.content)+ output_filename = output_pathname.parent / f"{output_pathname.stem}-class-diagram"+ await self._save_data_api_design(design_doc=design, output_filename=output_filename)+ output_filename = output_pathname.parent / f"{output_pathname.stem}-sequence-diagram"+ await self._save_seq_flow(design_doc=design, output_filename=output_filename)+ md_output_filename = output_pathname.with_suffix(".md")+ await save_json_to_markdown(content=design.content, output_filename=md_output_filename)+ await reporter.async_report(md_output_filename, "path")return f'System Design filename: "{str(output_pathname)}"'diff --git a/metagpt/actions/project_management.py b/metagpt/actions/project_management.pyindex a39840bf1..e810a5dbe 100644--- a/metagpt/actions/project_management.py+++ b/metagpt/actions/project_management.py@@ -180,16 +180,20 @@ class WriteTasks(Action):if design_filename:content = await aread(filename=design_filename)context += to_markdown_code_block(content)- node = await self._run_new_tasks(context)- file_content = node.instruct_content.model_dump_json()-- if not output_pathname:- output_pathname = Path(output_pathname) / "docs" / "project_schedule.json"- output_pathname.mkdir(parents=True, exist_ok=True)- elif not Path(output_pathname).is_absolute():- output_pathname = DEFAULT_WORKSPACE_ROOT / output_pathname- output_pathname = Path(output_pathname)- await awrite(filename=output_pathname, data=file_content)- await save_json_to_markdown(content=file_content, output_filename=output_pathname.with_suffix(".md"))+ async with DocsReporter(enable_llm_stream=True) as reporter:+ await reporter.async_report({"type": "task"}, "meta")+ node = await self._run_new_tasks(context)+ file_content = node.instruct_content.model_dump_json()++ if not output_pathname:+ output_pathname = Path(output_pathname) / "docs" / "project_schedule.json"+ output_pathname.mkdir(parents=True, exist_ok=True)+ elif not Path(output_pathname).is_absolute():+ output_pathname = DEFAULT_WORKSPACE_ROOT / output_pathname+ output_pathname = Path(output_pathname)+ await awrite(filename=output_pathname, data=file_content)+ md_output_filename = output_pathname.with_suffix(".md")+ await save_json_to_markdown(content=file_content, output_filename=md_output_filename)+ await reporter.async_report(md_output_filename, "path")return f'Project Schedule filename: "{str(output_pathname)}"'diff --git a/metagpt/actions/write_prd.py b/metagpt/actions/write_prd.pyindex 7199ec415..4d29d8c6f 100644--- a/metagpt/actions/write_prd.py+++ b/metagpt/actions/write_prd.py@@ -300,23 +300,27 @@ class WritePRD(Action):user_requirement=to_markdown_code_block(val=user_requirement),extra_info=to_markdown_code_block(val=extra_info),)- req = Document(content=content)- if not legacy_prd_filename:- node = await self._new_prd(requirement=req.content)- new_prd = Document(content=node.instruct_content.model_dump_json())- else:- content = await aread(filename=legacy_prd_filename)- old_prd = Document(content=content)- new_prd = await self._merge(req=req, related_doc=old_prd)-- if not output_pathname:- output_pathname = DEFAULT_WORKSPACE_ROOT / "docs" / "prd.json"- output_pathname.mkdir(parents=True, exist_ok=True)- elif not Path(output_pathname).is_absolute():- output_pathname = DEFAULT_WORKSPACE_ROOT / output_pathname- output_pathname = Path(output_pathname)- await awrite(filename=output_pathname, data=new_prd.content)- competitive_analysis_filename = output_pathname.parent / f"{output_pathname.stem}-competitive-analysis"- await self._save_competitive_analysis(prd_doc=new_prd, output_filename=Path(competitive_analysis_filename))- await save_json_to_markdown(content=new_prd.content, output_filename=output_pathname.with_suffix(".md"))+ async with DocsReporter(enable_llm_stream=True) as reporter:+ await reporter.async_report({"type": "prd"}, "meta")+ req = Document(content=content)+ if not legacy_prd_filename:+ node = await self._new_prd(requirement=req.content)+ new_prd = Document(content=node.instruct_content.model_dump_json())+ else:+ content = await aread(filename=legacy_prd_filename)+ old_prd = Document(content=content)+ new_prd = await self._merge(req=req, related_doc=old_prd)++ if not output_pathname:+ output_pathname = DEFAULT_WORKSPACE_ROOT / "docs" / "prd.json"+ output_pathname.mkdir(parents=True, exist_ok=True)+ elif not Path(output_pathname).is_absolute():+ output_pathname = DEFAULT_WORKSPACE_ROOT / output_pathname+ output_pathname = Path(output_pathname)+ await awrite(filename=output_pathname, data=new_prd.content)+ competitive_analysis_filename = output_pathname.parent / f"{output_pathname.stem}-competitive-analysis"+ await self._save_competitive_analysis(prd_doc=new_prd, output_filename=Path(competitive_analysis_filename))+ md_output_filename = output_pathname.with_suffix(".md")+ await save_json_to_markdown(content=new_prd.content, output_filename=md_output_filename)+ await reporter.async_report(md_output_filename, "path")return f'PRD filename: "{str(output_pathname)}"'