From 3847e672b1ad8ad4f6ca5c8a149f570c445b2e09 Mon Sep 17 00:00:00 2001 From: yzlin Date: Tue, 12 Dec 2023 14:20:15 +0800 Subject: [PATCH] rm redundant --- metagpt/actions/execute_code.py | 2 -- metagpt/actions/ml_da_action.py | 13 ------------- 2 files changed, 15 deletions(-) diff --git a/metagpt/actions/execute_code.py b/metagpt/actions/execute_code.py index 9c2b8d96c..1d20bf3f6 100644 --- a/metagpt/actions/execute_code.py +++ b/metagpt/actions/execute_code.py @@ -175,8 +175,6 @@ class ExecutePyCode(ExecuteCode, Action): outputs = self.parse_outputs(self.nb.cells[-1].outputs) success = True except Exception as e: - # FIXME: CellExecutionError is hard to read. for example `1\0` raise ZeroDivisionError: - # CellExecutionError('An error occurred while executing the following cell:\n------------------\nz=1/0\n------------------\n\n\n\x1b[0;31m---------------------------------------------------------------------------\x1b[0m\n\x1b[0;31mZeroDivisionError\x1b[0m Traceback (most recent call last)\nCell \x1b[0;32mIn[1], line 1\x1b[0m\n\x1b[0;32m----> 1\x1b[0m z\x1b[38;5;241m=\x1b[39m\x1b[38;5;241;43m1\x1b[39;49m\x1b[38;5;241;43m/\x1b[39;49m\x1b[38;5;241;43m0\x1b[39;49m\n\n\x1b[0;31mZeroDivisionError\x1b[0m: division by zero\n') outputs = traceback.format_exc() success = False return truncate(remove_escape_and_color_codes(outputs)), success diff --git a/metagpt/actions/ml_da_action.py b/metagpt/actions/ml_da_action.py index 6be4b3040..5e4580b17 100644 --- a/metagpt/actions/ml_da_action.py +++ b/metagpt/actions/ml_da_action.py @@ -7,19 +7,6 @@ from metagpt.utils.common import CodeParser from metagpt.logs import logger -def truncate(result: str, keep_len: int = 2000) -> str: - desc = "Truncated to show only the last keep_len characters\n" - if result.startswith(desc): - result = result[-len(desc) :] - - if len(result) > keep_len: - result = result[-keep_len:] - - if not result.startswith(desc): - return desc + result - return desc - - class ReviewConst: TASK_REVIEW_TRIGGER = "task" CODE_REVIEW_TRIGGER = "code"