From 9cef551623717642773b13daf03dad0ef5d4e336 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Mon, 27 Nov 2023 17:33:46 -0800 Subject: [PATCH] (feat) raise APIConnectionError error for Azure +OpenAI --- litellm/utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/litellm/utils.py b/litellm/utils.py index 573ea737cb..323b71a707 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -3719,6 +3719,14 @@ def exception_type( model=model, request=original_exception.request ) + else: + # if no status code then it is an APIConnectionError: https://github.com/openai/openai-python#handling-errors + raise APIConnectionError( + __cause__=original_exception.__cause__, + llm_provider=custom_llm_provider, + model=model, + request=original_exception.request + ) elif custom_llm_provider == "anthropic": # one of the anthropics if hasattr(original_exception, "message"): if "prompt is too long" in original_exception.message or "prompt: length" in original_exception.message: @@ -4505,6 +4513,14 @@ def exception_type( model=model, request=original_exception.request ) + else: + # if no status code then it is an APIConnectionError: https://github.com/openai/openai-python#handling-errors + raise APIConnectionError( + __cause__=original_exception.__cause__, + llm_provider="azure", + model=model, + request=original_exception.request + ) if "BadRequestError.__init__() missing 1 required positional argument: 'param'" in str(original_exception): # deal with edge-case invalid request error bug in openai-python sdk exception_mapping_worked = True raise BadRequestError(