From 95dc1eebf201607ff05ed3568e99dc42525a2eb0 Mon Sep 17 00:00:00 2001 From: yzlin Date: Sat, 30 Mar 2024 21:35:15 +0800 Subject: [PATCH] log plan --- metagpt/logs.py | 2 +- metagpt/schema.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/metagpt/logs.py b/metagpt/logs.py index e134afca3..e547ebb76 100644 --- a/metagpt/logs.py +++ b/metagpt/logs.py @@ -38,7 +38,7 @@ def log_llm_stream(msg): def log_tool_output(output: dict, tool_name: str = ""): """interface for logging tool output, can be set to log tool output in different ways to different places with set_tool_output_logfunc""" - _tool_output_log(output) + _tool_output_log(output, tool_name) def set_llm_stream_logfunc(func): diff --git a/metagpt/schema.py b/metagpt/schema.py index 45c7480f9..d944a4199 100644 --- a/metagpt/schema.py +++ b/metagpt/schema.py @@ -45,7 +45,7 @@ from metagpt.const import ( SYSTEM_DESIGN_FILE_REPO, TASK_FILE_REPO, ) -from metagpt.logs import logger +from metagpt.logs import log_tool_output, logger from metagpt.repo_parser import DotClassInfo from metagpt.utils.common import any_to_str, any_to_str_set, import_class from metagpt.utils.exceptions import handle_exception @@ -433,6 +433,11 @@ class Plan(BaseModel): final_tasks = self.tasks[:prefix_length] + new_tasks[prefix_length:] self.tasks = final_tasks + log_tool_output( + {"output": "\n\n".join([f"Task {task.task_id}: {task.instruction}" for task in self.tasks])}, + tool_name="Plan", + ) + # Update current_task_id to the first unfinished task in the merged list self._update_current_task()