Merge branch 'main' into litellm_dynamic_tpm_limits

This commit is contained in:
Krish Dholakia 2024-06-22 19:14:59 -07:00 committed by GitHub
commit 961e7ac95d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
65 changed files with 689 additions and 1186 deletions

View file

@ -5927,21 +5927,28 @@ def exception_type(
if "prompt is too long" in error_str or "prompt: length" in error_str:
exception_mapping_worked = True
raise ContextWindowExceededError(
message=error_str,
message="AnthropicError - {}".format(error_str),
model=model,
llm_provider="anthropic",
)
if "Invalid API Key" in error_str:
exception_mapping_worked = True
raise AuthenticationError(
message=error_str,
message="AnthropicError - {}".format(error_str),
model=model,
llm_provider="anthropic",
)
if "content filtering policy" in error_str:
exception_mapping_worked = True
raise ContentPolicyViolationError(
message=error_str,
message="AnthropicError - {}".format(error_str),
model=model,
llm_provider="anthropic",
)
if "Client error '400 Bad Request'" in error_str:
exception_mapping_worked = True
raise BadRequestError(
message="AnthropicError - {}".format(error_str),
model=model,
llm_provider="anthropic",
)
@ -5953,7 +5960,6 @@ def exception_type(
message=f"AnthropicException - {error_str}",
llm_provider="anthropic",
model=model,
response=original_exception.response,
)
elif (
original_exception.status_code == 400
@ -5964,7 +5970,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
@ -5979,16 +5991,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: