From 64a296a29d321e4d05c1b0473a073dc05ee2bb1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=A3=92=E6=A3=92?= Date: Mon, 22 Jan 2024 16:14:59 +0800 Subject: [PATCH] update logger warning for JSONDecodeError. --- metagpt/provider/openai_api.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/metagpt/provider/openai_api.py b/metagpt/provider/openai_api.py index 72af5f40a..3358b3aad 100644 --- a/metagpt/provider/openai_api.py +++ b/metagpt/provider/openai_api.py @@ -237,9 +237,13 @@ class OpenAILLM(BaseLLM): try: return json.loads(message.tool_calls[0].function.arguments, strict=False) except json.decoder.JSONDecodeError as e: - logger.debug( - f"Got JSONDecodeError for {message.tool_calls[0].function.arguments},\ - we will use RegExp to parse code, \n {e}" + logger.warning( + "\n".join( + [ + (f"Got JSONDecodeError for \n{'--'*40} \n{message.tool_calls[0].function.arguments}"), + (f"{'--'*40}\nwe will use RegExp to parse code. JSONDecodeError is: {e}"), + ] + ) ) return self._parse_arguments(message.tool_calls[0].function.arguments) elif message.tool_calls is None and message.content is not None: