From b987d99486059b1b2b090ac66e5aeee25cfe0145 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 21 Sep 2024 18:00:18 -0700 Subject: [PATCH] handle hf rate limit error --- litellm/tests/test_text_completion.py | 3 +++ litellm/utils.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/litellm/tests/test_text_completion.py b/litellm/tests/test_text_completion.py index e6a4a0499cc..7e599012eb4 100644 --- a/litellm/tests/test_text_completion.py +++ b/litellm/tests/test_text_completion.py @@ -3951,6 +3951,9 @@ def test_completion_hf_prompt_array(): print(response.choices) assert len(response.choices) == 2 # response_str = response["choices"][0]["text"] + except litellm.RateLimitError: + print("got rate limit error from hugging face... passsing") + return except Exception as e: print(str(e)) if "is currently loading" in str(e): diff --git a/litellm/utils.py b/litellm/utils.py index 2bb5e15296d..2b97e9d71aa 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -7455,6 +7455,14 @@ def exception_type( model=model, response=original_exception.response, ) + elif "Rate limit reached" in error_str: + exception_mapping_worked = True + raise RateLimitError( + message=error_str, + llm_provider="huggingface", + model=model, + response=original_exception.response, + ) if hasattr(original_exception, "status_code"): if original_exception.status_code == 401: exception_mapping_worked = True