mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
improvements to exception mapping
This commit is contained in:
parent
cd6b5b229f
commit
f946f61b4c
5 changed files with 73 additions and 6 deletions
|
@ -1786,6 +1786,20 @@ def exception_type(model, original_exception, custom_llm_provider):
|
|||
llm_provider="cohere",
|
||||
model=model
|
||||
)
|
||||
elif "invalid type:" in error_str:
|
||||
exception_mapping_worked = True
|
||||
raise InvalidRequestError(
|
||||
message=f"CohereException - {original_exception.message}",
|
||||
llm_provider="cohere",
|
||||
model=model
|
||||
)
|
||||
elif "Unexpected server error" in error_str:
|
||||
exception_mapping_worked = True
|
||||
raise ServiceUnavailableError(
|
||||
message=f"CohereException - {original_exception.message}",
|
||||
llm_provider="cohere",
|
||||
model=model
|
||||
)
|
||||
else:
|
||||
if hasattr(original_exception, "status_code"):
|
||||
exception_mapping_worked = True
|
||||
|
@ -1938,6 +1952,46 @@ def exception_type(model, original_exception, custom_llm_provider):
|
|||
llm_provider="together_ai",
|
||||
model=model
|
||||
)
|
||||
elif model in litellm.aleph_alpha_models:
|
||||
if "This is longer than the model's maximum context length" in error_str:
|
||||
exception_mapping_worked = True
|
||||
raise ContextWindowExceededError(
|
||||
message=f"AlephAlphaException - {original_exception.message}",
|
||||
llm_provider="aleph_alpha",
|
||||
model=model
|
||||
)
|
||||
elif hasattr(original_exception, "status_code"):
|
||||
print(f"status code: {original_exception.status_code}")
|
||||
if original_exception.status_code == 401:
|
||||
exception_mapping_worked = True
|
||||
raise AuthenticationError(
|
||||
message=f"AlephAlphaException - {original_exception.message}",
|
||||
llm_provider="aleph_alpha",
|
||||
model=model
|
||||
)
|
||||
elif original_exception.status_code == 400:
|
||||
exception_mapping_worked = True
|
||||
raise InvalidRequestError(
|
||||
message=f"AlephAlphaException - {original_exception.message}",
|
||||
llm_provider="aleph_alpha",
|
||||
model=model
|
||||
)
|
||||
elif original_exception.status_code == 429:
|
||||
exception_mapping_worked = True
|
||||
raise RateLimitError(
|
||||
message=f"AlephAlphaException - {original_exception.message}",
|
||||
llm_provider="aleph_alpha",
|
||||
model=model
|
||||
)
|
||||
elif original_exception.status_code == 500:
|
||||
exception_mapping_worked = True
|
||||
raise ServiceUnavailableError(
|
||||
message=f"AlephAlphaException - {original_exception.message}",
|
||||
llm_provider="aleph_alpha",
|
||||
model=model
|
||||
)
|
||||
raise original_exception
|
||||
raise original_exception
|
||||
elif custom_llm_provider == "vllm":
|
||||
if hasattr(original_exception, "status_code"):
|
||||
if original_exception.status_code == 0:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue