fix(vertex_ai.py): add exception mapping for acompletion calls

This commit is contained in:
Krrish Dholakia 2023-12-13 16:35:50 -08:00
parent b6b371b051
commit e678009695
5 changed files with 99 additions and 70 deletions

View file

@ -52,7 +52,8 @@ from .exceptions import (
Timeout,
APIConnectionError,
APIError,
BudgetExceededError
BudgetExceededError,
UnprocessableEntityError
)
from typing import cast, List, Dict, Union, Optional, Literal
from .caching import Cache
@ -4432,7 +4433,15 @@ def exception_type(
)
elif "403" in error_str:
exception_mapping_worked = True
raise AuthenticationError(
raise U(
message=f"VertexAIException - {error_str}",
model=model,
llm_provider="vertex_ai",
response=original_exception.response
)
elif "The response was blocked." in error_str:
exception_mapping_worked = True
raise UnprocessableEntityError(
message=f"VertexAIException - {error_str}",
model=model,
llm_provider="vertex_ai",