From 37f2a4100306ffe04801759645a62845144343fc Mon Sep 17 00:00:00 2001 From: garylin2099 Date: Wed, 14 Aug 2024 22:39:15 +0800 Subject: [PATCH] add one arg for write_and_exec_code to avoid llm hallucinate a code arg --- metagpt/roles/di/data_analyst.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/metagpt/roles/di/data_analyst.py b/metagpt/roles/di/data_analyst.py index 457a34d03..d7a42a88f 100644 --- a/metagpt/roles/di/data_analyst.py +++ b/metagpt/roles/di/data_analyst.py @@ -51,8 +51,12 @@ class DataAnalyst(RoleZero): } ) - async def write_and_exec_code(self): - """Write a code block for current task and execute it in an interactive notebook environment. No argument is needed.""" + async def write_and_exec_code(self, instruction: str = ""): + """Write a code block for current task and execute it in an interactive notebook environment. + + Args: + instruction (optional, str): Further hints or notice other than the current task instruction, must be very concise and can be empty. Defaults to "". + """ if self.planner.plan: logger.info(f"Current task {self.planner.plan.current_task}") @@ -64,6 +68,7 @@ class DataAnalyst(RoleZero): if self.planner.current_task: # clear task result from plan to save token, since it has been in memory plan_status = self.planner.get_plan_status(exclude=["task_result"]) + plan_status += f"\nFurther Task Instruction: {instruction}" else: return "No current_task found now. Please use command Plan.append_task to add a task first."