fix(utils.py): anthropic error handling

This commit is contained in:
Krrish Dholakia 2024-05-06 07:25:12 -07:00
parent d83f0b02da
commit b5f3f198f2
3 changed files with 69 additions and 20 deletions

View file

@ -8154,27 +8154,9 @@ def exception_type(
response=original_exception.response,
)
elif original_exception.status_code == 500:
exception_mapping_worked = True
raise ServiceUnavailableError(
message=f"AnthropicException - {original_exception.message}",
llm_provider="anthropic",
model=model,
response=(
original_exception.response
if hasattr(original_exception, "response")
else httpx.Response(
status_code=500,
request=httpx.Request(
method="POST",
url="https://docs.anthropic.com/claude/reference/messages_post",
),
)
),
)
else:
exception_mapping_worked = True
raise APIError(
status_code=original_exception.status_code,
status_code=500,
message=f"AnthropicException - {original_exception.message}. Handle with `litellm.APIError`.",
llm_provider="anthropic",
model=model,