From acdf9b64d9cb9d06325ed7fc5ba4f9fba6200c0e Mon Sep 17 00:00:00 2001 From: Shubham Pathak Date: Mon, 29 Sep 2025 12:04:44 +0530 Subject: [PATCH] Update request handling for original exceptions --- .../exception_mapping_utils.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/litellm/litellm_core_utils/exception_mapping_utils.py b/litellm/litellm_core_utils/exception_mapping_utils.py index 409f5ebe0bc..f9cebeb1765 100644 --- a/litellm/litellm_core_utils/exception_mapping_utils.py +++ b/litellm/litellm_core_utils/exception_mapping_utils.py @@ -1498,7 +1498,7 @@ def exception_type( # type: ignore # noqa: PLR0915 message=f"CohereException - {original_exception.message}", llm_provider="cohere", model=model, - request=original_exception.request, + request=getattr(original_exception, "request", None),, ) raise original_exception elif custom_llm_provider == "huggingface": @@ -1573,7 +1573,7 @@ def exception_type( # type: ignore # noqa: PLR0915 message=f"HuggingfaceException - {original_exception.message}", llm_provider="huggingface", model=model, - request=original_exception.request, + request=getattr(original_exception, "request", None),, ) elif custom_llm_provider == "ai21": if hasattr(original_exception, "message"): @@ -1632,7 +1632,7 @@ def exception_type( # type: ignore # noqa: PLR0915 message=f"AI21Exception - {original_exception.message}", llm_provider="ai21", model=model, - request=original_exception.request, + request=getattr(original_exception, "request", None),, ) elif custom_llm_provider == "nlp_cloud": if "detail" in error_str: @@ -1659,7 +1659,7 @@ def exception_type( # type: ignore # noqa: PLR0915 message=f"NLPCloudException - {error_str}", model=model, llm_provider="nlp_cloud", - request=original_exception.request, + request=getattr(original_exception, "request", None),, ) if hasattr( original_exception, "status_code" @@ -1719,7 +1719,7 @@ def exception_type( # type: ignore # noqa: PLR0915 message=f"NLPCloudException - {original_exception.message}", llm_provider="nlp_cloud", model=model, - request=original_exception.request, + request=getattr(original_exception, "request", None),, ) elif ( original_exception.status_code == 504 @@ -1739,7 +1739,7 @@ def exception_type( # type: ignore # noqa: PLR0915 message=f"NLPCloudException - {original_exception.message}", llm_provider="nlp_cloud", model=model, - request=original_exception.request, + request=getattr(original_exception, "request", None),, ) elif custom_llm_provider == "together_ai": try: @@ -1848,7 +1848,7 @@ def exception_type( # type: ignore # noqa: PLR0915 message=f"TogetherAIException - {original_exception.message}", llm_provider="together_ai", model=model, - request=original_exception.request, + request=getattr(original_exception, "request", None),, ) elif custom_llm_provider == "aleph_alpha": if ( @@ -1953,7 +1953,7 @@ def exception_type( # type: ignore # noqa: PLR0915 message=f"VLLMException - {original_exception.message}", llm_provider="vllm", model=model, - request=original_exception.request, + request=getattr(original_exception, "request", None),, ) elif custom_llm_provider == "azure" or custom_llm_provider == "azure_text": message = get_error_message(error_obj=original_exception) @@ -2208,7 +2208,7 @@ def exception_type( # type: ignore # noqa: PLR0915 message=f"APIError: {exception_provider} - {error_str}", llm_provider=custom_llm_provider, model=model, - request=original_exception.request, + request=getattr(original_exception, "request", None),, litellm_debug_info=extra_information, ) else: @@ -2243,7 +2243,7 @@ def exception_type( # type: ignore # noqa: PLR0915 message="{} - {}".format(exception_provider, error_str), llm_provider=custom_llm_provider, model=model, - request=original_exception.request, + request=getattr(original_exception, "request", None),, ) else: raise APIConnectionError(