fix(utils.py): improve coverage for anthropic exception mapping

This commit is contained in:
Krrish Dholakia 2024-06-21 21:15:10 -07:00
parent 3e5641ca77
commit 40c9ecd470
2 changed files with 37 additions and 8 deletions

View file

@ -5948,7 +5948,6 @@ def exception_type(
message=f"AnthropicException - {error_str}",
llm_provider="anthropic",
model=model,
response=original_exception.response,
)
elif (
original_exception.status_code == 400
@ -5959,7 +5958,13 @@ def exception_type(
message=f"AnthropicException - {error_str}",
model=model,
llm_provider="anthropic",
response=original_exception.response,
)
elif original_exception.status_code == 404:
exception_mapping_worked = True
raise NotFoundError(
message=f"AnthropicException - {error_str}",
model=model,
llm_provider="anthropic",
)
elif original_exception.status_code == 408:
exception_mapping_worked = True
@ -5974,16 +5979,20 @@ def exception_type(
message=f"AnthropicException - {error_str}",
llm_provider="anthropic",
model=model,
response=original_exception.response,
)
elif original_exception.status_code == 500:
exception_mapping_worked = True
raise APIError(
status_code=500,
message=f"AnthropicException - {error_str}. Handle with `litellm.APIError`.",
raise litellm.InternalServerError(
message=f"AnthropicException - {error_str}. Handle with `litellm.InternalServerError`.",
llm_provider="anthropic",
model=model,
)
elif original_exception.status_code == 503:
exception_mapping_worked = True
raise litellm.ServiceUnavailableError(
message=f"AnthropicException - {error_str}. Handle with `litellm.ServiceUnavailableError`.",
llm_provider="anthropic",
model=model,
request=original_exception.request,
)
elif custom_llm_provider == "replicate":
if "Incorrect authentication token" in error_str: