🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
recover code
lidanyang08c4af29b5cc
diff --git a/metagpt/actions/di/execute_nb_code.py b/metagpt/actions/di/execute_nb_code.pyindex dfeea7e67..f3dfd1601 100644--- a/metagpt/actions/di/execute_nb_code.py+++ b/metagpt/actions/di/execute_nb_code.py@@ -158,7 +158,7 @@ class ExecuteNbCode(Action):else:cell["outputs"].append(new_output(output_type="stream", name="stdout", text=str(output)))- def parse_outputs(self, outputs: list[str], keep_len: int = 20000) -> Tuple[bool, str]:+ def parse_outputs(self, outputs: list[str], keep_len: int = 5000) -> Tuple[bool, str]:"""Parses the outputs received from notebook execution."""assert isinstance(outputs, list)parsed_output, is_success = [], True@@ -191,8 +191,8 @@ class ExecuteNbCode(Action):output_text = remove_log_and_warning_lines(output_text)# The useful information of the exception is at the end,# the useful information of normal output is at the begining.- # if '<!DOCTYPE html>' not in output_text:- output_text = output_text[:keep_len] if is_success else output_text[-keep_len:]+ if '<!DOCTYPE html>' not in output_text:+ output_text = output_text[:keep_len] if is_success else output_text[-keep_len:]parsed_output.append(output_text)return is_success, ",".join(parsed_output)diff --git a/metagpt/tools/libs/browser.py b/metagpt/tools/libs/browser.pyindex 4fd6127b3..a458109e6 100644--- a/metagpt/tools/libs/browser.py+++ b/metagpt/tools/libs/browser.py@@ -197,9 +197,9 @@ class Browser:async def _on_frame_change(self, frame: Frame):await self._update_page_last_busy_time(frame.page)- async def view(self, keep_len: int = 10000):+ async def view(self):observation = parse_accessibility_tree(self.accessibility_tree)- return f"Current Browser Viewer\n URL: {self.page.url}\nOBSERVATION:\n{observation[0][:keep_len]}\n"+ return f"Current Browser Viewer\n URL: {self.page.url}\nOBSERVATION:\n{observation[0]}\n"async def __aenter__(self):await self.start()