Merge pull request #1802 from BerriAI/litellm_vertex_ai_high_traffic_fix

fix(vertex_ai.py): treat vertex ai high-traffic error as a rate limit error - allows user-controlled backoff logic to work here
This commit is contained in:
Krish Dholakia 2024-02-03 15:37:05 -08:00 committed by GitHub
commit 1d241b4001
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 3 deletions

View file

@ -6468,6 +6468,23 @@ def exception_type(
llm_provider="vertex_ai",
response=original_exception.response,
)
elif (
"429 Quota exceeded" in error_str
or "IndexError: list index out of range"
):
exception_mapping_worked = True
raise RateLimitError(
message=f"VertexAIException - {error_str}",
model=model,
llm_provider="vertex_ai",
response=httpx.Response(
status_code=429,
request=httpx.Request(
method="POST",
url=" https://cloud.google.com/vertex-ai/",
),
),
)
if hasattr(original_exception, "status_code"):
if original_exception.status_code == 400:
exception_mapping_worked = True