From 3486b9d1d3e248bda33fee0a73629d4e92f1476c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Fri, 19 Jan 2024 11:20:05 +0800 Subject: [PATCH 1/3] feat: Maintain the original exceptions of OpenAI and HTTPX during exception handling. --- metagpt/utils/common.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/metagpt/utils/common.py b/metagpt/utils/common.py index c7751c2af..3295603b4 100644 --- a/metagpt/utils/common.py +++ b/metagpt/utils/common.py @@ -501,7 +501,7 @@ async def wrapper(self, *args, **kwargs): self.rc.memory.delete(self.latest_observed_msg) # raise again to make it captured outside raise Exception(format_trackback_info(limit=None)) - except Exception: + except Exception as e: if self.latest_observed_msg: logger.warning( "There is a exception in role's execution, in order to resume, " @@ -510,6 +510,11 @@ async def wrapper(self, *args, **kwargs): # remove role newest observed msg to make it observed again self.rc.memory.delete(self.latest_observed_msg) # raise again to make it captured outside + last_error = e.last_attempt._exception + name = any_to_str(last_error) + if re.match(r"^openai\.", name) or re.match(r"^httpx\.", name): + raise last_error + raise Exception(format_trackback_info(limit=None)) return wrapper From b78cc3c1cab491a81bc59ddeff2f2ba96d3bc650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Fri, 19 Jan 2024 11:49:35 +0800 Subject: [PATCH 2/3] feat: Maintain the original exceptions of OpenAI and HTTPX during exception handling. --- metagpt/utils/common.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/metagpt/utils/common.py b/metagpt/utils/common.py index 3295603b4..3102158c2 100644 --- a/metagpt/utils/common.py +++ b/metagpt/utils/common.py @@ -28,7 +28,7 @@ import aiofiles import loguru from pydantic_core import to_jsonable_python -from tenacity import RetryCallState, _utils +from tenacity import RetryCallState, RetryError, _utils from metagpt.const import MESSAGE_ROUTE_TO_ALL from metagpt.logs import logger @@ -510,10 +510,11 @@ async def wrapper(self, *args, **kwargs): # remove role newest observed msg to make it observed again self.rc.memory.delete(self.latest_observed_msg) # raise again to make it captured outside - last_error = e.last_attempt._exception - name = any_to_str(last_error) - if re.match(r"^openai\.", name) or re.match(r"^httpx\.", name): - raise last_error + if isinstance(e, RetryError): + last_error = e.last_attempt._exception + name = any_to_str(last_error) + if re.match(r"^openai\.", name) or re.match(r"^httpx\.", name): + raise last_error raise Exception(format_trackback_info(limit=None)) From cd919aa71bf9e1305edd9515025931acef6a9dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Fri, 19 Jan 2024 11:51:02 +0800 Subject: [PATCH 3/3] feat: +ver --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ca8bb3980..cc8112ba9 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ def run(self): setup( name="metagpt", - version="0.6.5", + version="0.6.6", description="The Multi-Agent Framework", long_description=long_description, long_description_content_type="text/markdown",