mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
fix(proxy_server): improve error handling
This commit is contained in:
parent
d5c33657d2
commit
541a8b7bc8
5 changed files with 166 additions and 55 deletions
|
@ -3092,14 +3092,31 @@ def exception_type(
|
|||
raise original_exception
|
||||
raise original_exception
|
||||
elif custom_llm_provider == "ollama":
|
||||
error_str = original_exception.get("error", "")
|
||||
if isinstance(original_exception, dict):
|
||||
error_str = original_exception.get("error", "")
|
||||
else:
|
||||
error_str = str(original_exception)
|
||||
if "no such file or directory" in error_str:
|
||||
exception_mapping_worked = True
|
||||
raise InvalidRequestError(
|
||||
message=f"Ollama Exception Invalid Model/Model not loaded - {original_exception}",
|
||||
message=f"OllamaException: Invalid Model/Model not loaded - {original_exception}",
|
||||
model=model,
|
||||
llm_provider="ollama"
|
||||
)
|
||||
elif "Failed to establish a new connection" in error_str:
|
||||
exception_mapping_worked = True
|
||||
raise ServiceUnavailableError(
|
||||
message=f"OllamaException: {original_exception}",
|
||||
llm_provider="ollama",
|
||||
model=model
|
||||
)
|
||||
elif "Invalid response object from API" in error_str:
|
||||
exception_mapping_worked = True
|
||||
raise InvalidRequestError(
|
||||
message=f"OllamaException: {original_exception}",
|
||||
llm_provider="ollama",
|
||||
model=model
|
||||
)
|
||||
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