From 69e15ee6c057839f674b0d9e0194d701a77f0a35 Mon Sep 17 00:00:00 2001 From: brucemeek <113046530+brucemeek@users.noreply.github.com> Date: Wed, 9 Aug 2023 14:48:44 -0500 Subject: [PATCH] final conflict resolved --- metagpt/actions/debug_error.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/metagpt/actions/debug_error.py b/metagpt/actions/debug_error.py index 114c414e4..22b1be6a4 100644 --- a/metagpt/actions/debug_error.py +++ b/metagpt/actions/debug_error.py @@ -48,6 +48,26 @@ class DebugError(Action): # fixed_code = await self._aask(prompt) # return fixed_code + async def run(self, context): + if "PASS" in context: + return "", "the original code works fine, no need to debug" + + file_name = re.search("## File To Rewrite:\s*(.+\\.py)", context).group(1) + + logger.info(f"Debug and rewrite {file_name}") + + prompt = PROMPT_TEMPLATE.format(context=context) + + rsp = await self._aask(prompt) + + code = CodeParser.parse_code(block="", text=rsp) + + # async def run(self, code, error): + # prompt = f"Here is a piece of Python code:\n\n{code}\n\nThe following error occurred during execution:" \ + # f"\n\n{error}\n\nPlease try to fix the error in this code." + # fixed_code = await self._aask(prompt) + # return fixed_code + async def run(self, context): if "PASS" in context: return "", "the original code works fine, no need to debug"