From ca4fd85296f0c04d1cef5a2be5563ab795032c39 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 24 Apr 2024 14:01:32 -0700 Subject: [PATCH 1/2] fix show api_base, model in timeout errors --- litellm/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index 48a962fc8b..91cb855260 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -1765,7 +1765,7 @@ class Logging: "reaches greenscale for streaming logging!" ) result = kwargs["complete_streaming_response"] - + greenscaleLogger.log_event( kwargs=kwargs, response_obj=result, @@ -7415,11 +7415,18 @@ def exception_type( exception_type = type(original_exception).__name__ else: exception_type = "" + _api_base = "" + try: + _api_base = litellm.get_api_base( + model=model, optional_params=extra_kwargs + ) + except: + _api_base = "" if "Request Timeout Error" in error_str or "Request timed out" in error_str: exception_mapping_worked = True raise Timeout( - message=f"APITimeoutError - Request timed out", + message=f"APITimeoutError - Request timed out. \n model: {model} \n api_base: {_api_base} \n error_str: {error_str}", model=model, llm_provider=custom_llm_provider, ) From 7a5c07de220193c60a72a0ed01384dacf8afff4a Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 24 Apr 2024 14:03:48 -0700 Subject: [PATCH 2/2] fix - show api_base, model in exceptions --- litellm/exceptions.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/litellm/exceptions.py b/litellm/exceptions.py index a7bf394f6d..d8b0a7c55a 100644 --- a/litellm/exceptions.py +++ b/litellm/exceptions.py @@ -82,14 +82,18 @@ class UnprocessableEntityError(UnprocessableEntityError): # type: ignore class Timeout(APITimeoutError): # type: ignore def __init__(self, message, model, llm_provider): - self.status_code = 408 - self.message = message - self.model = model - self.llm_provider = llm_provider request = httpx.Request(method="POST", url="https://api.openai.com/v1") super().__init__( request=request ) # Call the base class constructor with the parameters it needs + self.status_code = 408 + self.message = message + self.model = model + self.llm_provider = llm_provider + + # custom function to convert to str + def __str__(self): + return str(self.message) class PermissionDeniedError(PermissionDeniedError): # type:ignore