Merge pull request #2923 from BerriAI/litellm_return_better_error_from_health

fix - return stack trace on failing /health checks - first 1000 chars
This commit is contained in:
Ishaan Jaff 2024-04-10 17:48:13 -07:00 committed by GitHub
commit bc50b0a4a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3816,11 +3816,15 @@ async def ahealth_check(
return response
except Exception as e:
traceback.print_exc()
stack_trace = traceback.format_exc()
if isinstance(stack_trace, str):
stack_trace = stack_trace[:1000]
if model not in litellm.model_cost and mode is None:
raise Exception(
"Missing `mode`. Set the `mode` for the model - https://docs.litellm.ai/docs/proxy/health#embedding-models"
)
return {"error": f"{str(e)}"}
error_to_return = str(e) + " stack trace: " + stack_trace
return {"error": error_to_return}
####### HELPER FUNCTIONS ################