mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
Shorter success callbacks from /health/readiness
Before: ```shell $ curl -sSL http://0.0.0.0:4000/health/readiness | jq '.success_callbacks' [ "langfuse", "<function _PROXY_track_cost_callback at 0x12fc14b80>", "<bound method SlackAlerting.response_taking_too_long_callback of <litellm.integrations.slack_alerting.SlackAlerting object at 0x12cedb740>>", "<litellm.proxy.hooks.parallel_request_limiter._PROXY_MaxParallelRequestsHandler object at 0x12cedb8f0>", "<litellm.proxy.hooks.max_budget_limiter._PROXY_MaxBudgetLimiter object at 0x12cedb830>", "<litellm.proxy.hooks.cache_control_check._PROXY_CacheControlCheck object at 0x12ca101d0>", "<litellm._service_logger.ServiceLogging object at 0x13a6d8c50>" ] ``` After: ```shell $ curl -sSL http://0.0.0.0:4000/health/readiness | jq '.success_callbacks' [ "langfuse", "_PROXY_track_cost_callback", "response_taking_too_long_callback", "_PROXY_MaxParallelRequestsHandler", "_PROXY_MaxBudgetLimiter", "_PROXY_CacheControlCheck", "ServiceLogging" ] ```
This commit is contained in:
parent
265ec00d0f
commit
3d86c4f515
1 changed files with 15 additions and 2 deletions
|
|
@ -406,6 +406,19 @@ async def active_callbacks():
|
|||
}
|
||||
|
||||
|
||||
def callback_name(callback):
|
||||
if isinstance(callback, str):
|
||||
return callback
|
||||
|
||||
try:
|
||||
return callback.__name__
|
||||
except AttributeError:
|
||||
try:
|
||||
return callback.__class__.__name__
|
||||
except AttributeError:
|
||||
return str(callback)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/health/readiness",
|
||||
tags=["health"],
|
||||
|
|
@ -424,8 +437,8 @@ async def health_readiness():
|
|||
try:
|
||||
# this was returning a JSON of the values in some of the callbacks
|
||||
# all we need is the callback name, hence we do str(callback)
|
||||
success_callback_names = [str(x) for x in litellm.success_callback]
|
||||
except:
|
||||
success_callback_names = [callback_name(x) for x in litellm.success_callback]
|
||||
except AttributeError:
|
||||
# don't let this block the /health/readiness response, if we can't convert to str -> return litellm.success_callback
|
||||
success_callback_names = litellm.success_callback
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue