From bcea28e2e440320bad62be335eb99a3e5c846e10 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Wed, 15 Nov 2023 15:51:17 -0800 Subject: [PATCH] fix(utils): fixing exception mapping --- litellm/llms/huggingface_restapi.py | 3 ++- litellm/utils.py | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/litellm/llms/huggingface_restapi.py b/litellm/llms/huggingface_restapi.py index 412c6887c..8b9d906f2 100644 --- a/litellm/llms/huggingface_restapi.py +++ b/litellm/llms/huggingface_restapi.py @@ -451,6 +451,7 @@ class Huggingface(BaseLLM): if self._aclient_session is None: self._aclient_session = self.create_aclient_session() client = self._aclient_session + response = None try: response = await client.post(url=api_base, json=data, headers=headers) response_json = response.json() @@ -468,7 +469,7 @@ class Huggingface(BaseLLM): except Exception as e: if isinstance(e,httpx.TimeoutException): raise HuggingfaceError(status_code=500, message="Request Timeout Error") - elif response and hasattr(response, "text"): + elif response is not None and hasattr(response, "text"): raise HuggingfaceError(status_code=500, message=f"{str(e)}\n\nOriginal Response: {response.text}") else: raise HuggingfaceError(status_code=500, message=f"{str(e)}") diff --git a/litellm/utils.py b/litellm/utils.py index 31581253b..3f1002155 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -3742,8 +3742,6 @@ def exception_type( model=model, request=original_exception.request ) - exception_mapping_worked = True - raise APIError(status_code=500, message=error_str, model=model, llm_provider=custom_llm_provider) elif custom_llm_provider == "ai21": if hasattr(original_exception, "message"): if "Prompt has too many tokens" in original_exception.message: