-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Description
Might now be a good time to include updated error messages, so that VertexAIException
is not the hard-coded error for Gemini API calls (which confused many of us who were initially trying to figure out what broke over the past 24 hr)?
litellm/litellm/litellm_core_utils/exception_mapping_utils.py
Lines 1170 to 1363 in 30c3e7b
elif ( | |
custom_llm_provider == "vertex_ai" | |
or custom_llm_provider == "vertex_ai_beta" | |
or custom_llm_provider == "gemini" | |
): | |
if ( | |
"Vertex AI API has not been used in project" in error_str | |
or "Unable to find your project" in error_str | |
): | |
exception_mapping_worked = True | |
raise BadRequestError( | |
message=f"litellm.BadRequestError: VertexAIException - {error_str}", | |
model=model, | |
llm_provider="vertex_ai", | |
response=httpx.Response( | |
status_code=400, | |
request=httpx.Request( | |
method="POST", | |
url=" https://cloud.google.com/vertex-ai/", | |
), | |
), | |
litellm_debug_info=extra_information, | |
) | |
if "400 Request payload size exceeds" in error_str: | |
exception_mapping_worked = True | |
raise ContextWindowExceededError( | |
message=f"VertexException - {error_str}", | |
model=model, | |
llm_provider=custom_llm_provider, | |
) | |
elif ( | |
"None Unknown Error." in error_str | |
or "Content has no parts." in error_str | |
): | |
exception_mapping_worked = True | |
raise litellm.InternalServerError( | |
message=f"litellm.InternalServerError: VertexAIException - {error_str}", | |
model=model, | |
llm_provider="vertex_ai", | |
response=httpx.Response( | |
status_code=500, | |
content=str(original_exception), | |
request=httpx.Request(method="completion", url="https://github.com/BerriAI/litellm"), # type: ignore | |
), | |
litellm_debug_info=extra_information, | |
) | |
elif "API key not valid." in error_str: | |
exception_mapping_worked = True | |
raise AuthenticationError( | |
message=f"{custom_llm_provider}Exception - {error_str}", | |
model=model, | |
llm_provider=custom_llm_provider, | |
litellm_debug_info=extra_information, | |
) | |
elif "403" in error_str: | |
exception_mapping_worked = True | |
raise BadRequestError( | |
message=f"VertexAIException BadRequestError - {error_str}", | |
model=model, | |
llm_provider="vertex_ai", | |
response=httpx.Response( | |
status_code=403, | |
request=httpx.Request( | |
method="POST", | |
url=" https://cloud.google.com/vertex-ai/", | |
), | |
), | |
litellm_debug_info=extra_information, | |
) | |
elif ( | |
"The response was blocked." in error_str | |
or "Output blocked by content filtering policy" | |
in error_str # anthropic on vertex ai | |
): | |
exception_mapping_worked = True | |
raise ContentPolicyViolationError( | |
message=f"VertexAIException ContentPolicyViolationError - {error_str}", | |
model=model, | |
llm_provider="vertex_ai", | |
litellm_debug_info=extra_information, | |
response=httpx.Response( | |
status_code=400, | |
request=httpx.Request( | |
method="POST", | |
url=" https://cloud.google.com/vertex-ai/", | |
), | |
), | |
) | |
elif ( | |
"429 Quota exceeded" in error_str | |
or "Quota exceeded for" in error_str | |
or "IndexError: list index out of range" in error_str | |
or "429 Unable to submit request because the service is temporarily out of capacity." | |
in error_str | |
): | |
exception_mapping_worked = True | |
raise RateLimitError( | |
message=f"litellm.RateLimitError: VertexAIException - {error_str}", | |
model=model, | |
llm_provider="vertex_ai", | |
litellm_debug_info=extra_information, | |
response=httpx.Response( | |
status_code=429, | |
request=httpx.Request( | |
method="POST", | |
url=" https://cloud.google.com/vertex-ai/", | |
), | |
), | |
) | |
elif ( | |
"500 Internal Server Error" in error_str | |
or "The model is overloaded." in error_str | |
): | |
exception_mapping_worked = True | |
raise litellm.InternalServerError( | |
message=f"litellm.InternalServerError: VertexAIException - {error_str}", | |
model=model, | |
llm_provider="vertex_ai", | |
litellm_debug_info=extra_information, | |
) | |
if hasattr(original_exception, "status_code"): | |
if original_exception.status_code == 400: | |
exception_mapping_worked = True | |
raise BadRequestError( | |
message=f"VertexAIException BadRequestError - {error_str}", | |
model=model, | |
llm_provider="vertex_ai", | |
litellm_debug_info=extra_information, | |
response=httpx.Response( | |
status_code=400, | |
request=httpx.Request( | |
method="POST", | |
url="https://cloud.google.com/vertex-ai/", | |
), | |
), | |
) | |
if original_exception.status_code == 401: | |
exception_mapping_worked = True | |
raise AuthenticationError( | |
message=f"VertexAIException - {original_exception.message}", | |
llm_provider=custom_llm_provider, | |
model=model, | |
) | |
if original_exception.status_code == 404: | |
exception_mapping_worked = True | |
raise NotFoundError( | |
message=f"VertexAIException - {original_exception.message}", | |
llm_provider=custom_llm_provider, | |
model=model, | |
) | |
if original_exception.status_code == 408: | |
exception_mapping_worked = True | |
raise Timeout( | |
message=f"VertexAIException - {original_exception.message}", | |
llm_provider=custom_llm_provider, | |
model=model, | |
) | |
if original_exception.status_code == 429: | |
exception_mapping_worked = True | |
raise RateLimitError( | |
message=f"litellm.RateLimitError: VertexAIException - {error_str}", | |
model=model, | |
llm_provider="vertex_ai", | |
litellm_debug_info=extra_information, | |
response=httpx.Response( | |
status_code=429, | |
request=httpx.Request( | |
method="POST", | |
url=" https://cloud.google.com/vertex-ai/", | |
), | |
), | |
) | |
if original_exception.status_code == 500: | |
exception_mapping_worked = True | |
raise litellm.InternalServerError( | |
message=f"VertexAIException InternalServerError - {error_str}", | |
model=model, | |
llm_provider="vertex_ai", | |
litellm_debug_info=extra_information, | |
response=httpx.Response( | |
status_code=500, | |
content=str(original_exception), | |
request=httpx.Request(method="completion", url="https://github.com/BerriAI/litellm"), # type: ignore | |
), | |
) | |
if original_exception.status_code == 503: | |
exception_mapping_worked = True | |
raise ServiceUnavailableError( | |
message=f"VertexAIException - {original_exception.message}", | |
llm_provider=custom_llm_provider, | |
model=model, | |
) | |
elif custom_llm_provider == "palm" or custom_llm_provider == "gemini": |
Originally posted by @noahkiss in #14563 (comment)