mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
fix exception handling
This commit is contained in:
parent
599be6a374
commit
a9cb373d04
1 changed files with 10 additions and 11 deletions
|
@ -1753,13 +1753,14 @@ def exception_type(model, original_exception, custom_llm_provider):
|
||||||
model=model
|
model=model
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
exception_mapping_worked = True
|
if hasattr(original_exception, "status_code"):
|
||||||
raise APIError(
|
exception_mapping_worked = True
|
||||||
status_code=original_exception.status_code,
|
raise APIError(
|
||||||
message=f"CohereException - {original_exception.message}",
|
status_code=original_exception.status_code,
|
||||||
llm_provider="cohere",
|
message=f"CohereException - {original_exception.message}",
|
||||||
model=model
|
llm_provider="cohere",
|
||||||
)
|
model=model
|
||||||
|
)
|
||||||
elif custom_llm_provider == "huggingface":
|
elif custom_llm_provider == "huggingface":
|
||||||
if "length limit exceeded" in error_str:
|
if "length limit exceeded" in error_str:
|
||||||
exception_mapping_worked = True
|
exception_mapping_worked = True
|
||||||
|
@ -1927,10 +1928,8 @@ def exception_type(model, original_exception, custom_llm_provider):
|
||||||
litellm.email or "LITELLM_EMAIL" in os.environ
|
litellm.email or "LITELLM_EMAIL" in os.environ
|
||||||
):
|
):
|
||||||
threading.Thread(target=get_all_keys, args=(e.llm_provider,)).start()
|
threading.Thread(target=get_all_keys, args=(e.llm_provider,)).start()
|
||||||
if exception_mapping_worked:
|
# don't let an error with mapping interrupt the user from receiving an error from the llm api calls
|
||||||
raise e
|
raise original_exception
|
||||||
else: # don't let an error with mapping interrupt the user from receiving an error from the llm api calls
|
|
||||||
raise original_exception
|
|
||||||
|
|
||||||
|
|
||||||
####### CRASH REPORTING ################
|
####### CRASH REPORTING ################
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue