From 15ba244e463a41ddd3c45f87b914ae522a577454 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sat, 11 May 2024 20:18:23 -0700 Subject: [PATCH] fix(utils.py): correctly exception map 'request too large' as rate limit error --- litellm/utils.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index 7a1b70f0004..9ba19b5e965 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -8220,10 +8220,7 @@ def exception_type( + "Exception" ) - if ( - "This model's maximum context length is" in error_str - or "Request too large" in error_str - ): + if "This model's maximum context length is" in error_str: exception_mapping_worked = True raise ContextWindowExceededError( message=f"{exception_provider} - {message} {extra_information}", @@ -8264,6 +8261,13 @@ def exception_type( model=model, response=original_exception.response, ) + elif "Request too large" in error_str: + raise RateLimitError( + message=f"{exception_provider} - {message} {extra_information}", + model=model, + llm_provider=custom_llm_provider, + response=original_exception.response, + ) elif ( "The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable" in error_str