🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
feat: Maintain the original exceptions of OpenAI and HTTPX during exception handling.
莘权 马b78cc3c1cab4
diff --git a/metagpt/utils/common.py b/metagpt/utils/common.pyindex 3295603b4..3102158c2 100644--- a/metagpt/utils/common.py+++ b/metagpt/utils/common.py@@ -28,7 +28,7 @@ from typing import Any, List, Tuple, Unionimport aiofilesimport logurufrom pydantic_core import to_jsonable_python-from tenacity import RetryCallState, _utils+from tenacity import RetryCallState, RetryError, _utilsfrom metagpt.const import MESSAGE_ROUTE_TO_ALLfrom metagpt.logs import logger@@ -510,10 +510,11 @@ def role_raise_decorator(func):# remove role newest observed msg to make it observed againself.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_errorraise Exception(format_trackback_info(limit=None))