fixbug: ToolLogItem

This commit is contained in:
莘权 马 2024-04-03 14:06:02 +08:00
parent 4a395d44c2
commit 6426483a67

View file

@ -6,7 +6,7 @@ from pathlib import Path
from typing import Optional
from metagpt.const import BUGFIX_FILENAME, REQUIREMENT_FILENAME
from metagpt.logs import log_tool_output
from metagpt.logs import ToolLogItem, log_tool_output
from metagpt.schema import BugFixContext, Message
from metagpt.tools.tool_registry import register_tool
from metagpt.utils.common import any_to_str
@ -51,12 +51,12 @@ async def write_prd(idea: str, project_path: Optional[str | Path] = None) -> Pat
await role.run(with_message=msg)
outputs = [
ToolOutputItem(name="PRD File", value=str(ctx.repo.docs.prd.workdir / i))
ToolLogItem(name="PRD File", value=str(ctx.repo.docs.prd.workdir / i))
for i in ctx.repo.docs.prd.changed_files.keys()
]
for i in ctx.repo.resources.competitive_analysis.changed_files.keys():
outputs.append(
ToolOutputItem(name="Competitive Analysis", value=str(ctx.repo.resources.competitive_analysis.workdir / i))
ToolLogItem(name="Competitive Analysis", value=str(ctx.repo.resources.competitive_analysis.workdir / i))
)
log_tool_output(output=outputs, tool_name=write_prd.__name__)
@ -94,17 +94,17 @@ async def write_design(prd_path: str | Path) -> Path:
await role.run(with_message=Message(content="", cause_by=WritePRD))
outputs = [
ToolOutputItem(name="Intermedia Design File", value=str(ctx.repo.docs.system_design.workdir / i))
ToolLogItem(name="Intermedia Design File", value=str(ctx.repo.docs.system_design.workdir / i))
for i in ctx.repo.docs.system_design.changed_files.keys()
]
for i in ctx.repo.resources.system_design.changed_files.keys():
outputs.append(ToolOutputItem(name="Design File", value=str(ctx.repo.resources.system_design.workdir / i)))
outputs.append(ToolLogItem(name="Design File", value=str(ctx.repo.resources.system_design.workdir / i)))
for i in ctx.repo.resources.data_api_design.changed_files.keys():
outputs.append(
ToolOutputItem(name="Class Diagram File", value=str(ctx.repo.resources.data_api_design.workdir / i))
ToolLogItem(name="Class Diagram File", value=str(ctx.repo.resources.data_api_design.workdir / i))
)
for i in ctx.repo.resources.seq_flow.changed_files.keys():
outputs.append(ToolOutputItem(name="Sequence Diagram File", value=str(ctx.repo.resources.seq_flow.workdir / i)))
outputs.append(ToolLogItem(name="Sequence Diagram File", value=str(ctx.repo.resources.seq_flow.workdir / i)))
log_tool_output(output=outputs, tool_name=write_design.__name__)
return ctx.repo.docs.system_design.workdir
@ -141,7 +141,7 @@ async def write_project_plan(system_design_path: str | Path) -> Path:
await role.run(with_message=Message(content="", cause_by=WriteDesign))
outputs = [
ToolOutputItem(name="Project Plan", value=str(ctx.repo.docs.task.workdir / i))
ToolLogItem(name="Project Plan", value=str(ctx.repo.docs.task.workdir / i))
for i in ctx.repo.docs.task.changed_files.keys()
]
log_tool_output(output=outputs, tool_name=write_project_plan.__name__)
@ -192,7 +192,7 @@ async def write_codes(task_path: str | Path, inc: bool = False) -> Path:
msg = await role.run(with_message=msg)
outputs = [
ToolOutputItem(name="Source File", value=str(ctx.repo.srcs.workdir / i))
ToolLogItem(name="Source File", value=str(ctx.repo.srcs.workdir / i))
for i in ctx.repo.srcs.changed_files.keys()
]
log_tool_output(output=outputs, tool_name=write_codes.__name__)
@ -239,7 +239,7 @@ async def run_qa_test(src_path: str | Path) -> Path:
await env.run()
outputs = [
ToolOutputItem(name="Unit Test File", value=str(ctx.repo.tests.workdir / i))
ToolLogItem(name="Unit Test File", value=str(ctx.repo.tests.workdir / i))
for i in ctx.repo.tests.changed_files.keys()
]
log_tool_output(output=outputs, tool_name=run_qa_test.__name__)
@ -291,7 +291,7 @@ async def fix_bug(project_path: str | Path, issue: str) -> Path:
msg = await role.run(with_message=msg)
outputs = [
ToolOutputItem(name="Changed File", value=str(ctx.repo.srcs.workdir / i))
ToolLogItem(name="Changed File", value=str(ctx.repo.srcs.workdir / i))
for i in ctx.repo.srcs.changed_files.keys()
]
log_tool_output(output=outputs, tool_name=fix_bug.__name__)
@ -329,7 +329,7 @@ async def git_archive(project_path: str | Path) -> str:
ctx.set_repo_dir(project_path)
ctx.git_repo.archive()
outputs = [ToolOutputItem(name="Git Commit", value=str(ctx.repo.workdir))]
outputs = [ToolLogItem(name="Git Commit", value=str(ctx.repo.workdir))]
log_tool_output(output=outputs, tool_name=git_archive.__name__)
return ctx.git_repo.log()
@ -362,7 +362,7 @@ async def import_git_repo(url: str) -> Path:
action = ImportRepo(repo_path=url, context=ctx)
await action.run()
outputs = [ToolOutputItem(name="MetaGPT Project", value=str(ctx.repo.workdir))]
outputs = [ToolLogItem(name="MetaGPT Project", value=str(ctx.repo.workdir))]
log_tool_output(output=outputs, tool_name=import_git_repo.__name__)
return ctx.repo.workdir