fix(utils.py): correctly exception map 'request too large' as rate limit error

This commit is contained in:
Krrish Dholakia 2024-05-11 20:18:23 -07:00
parent beac60ed12
commit 15ba244e46

View file

@ -8220,10 +8220,7 @@ def exception_type(
+ "Exception" + "Exception"
) )
if ( if "This model's maximum context length is" in error_str:
"This model's maximum context length is" in error_str
or "Request too large" in error_str
):
exception_mapping_worked = True exception_mapping_worked = True
raise ContextWindowExceededError( raise ContextWindowExceededError(
message=f"{exception_provider} - {message} {extra_information}", message=f"{exception_provider} - {message} {extra_information}",
@ -8264,6 +8261,13 @@ def exception_type(
model=model, model=model,
response=original_exception.response, 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 ( 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" "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 in error_str