From 3d86c4f515b5c50f4a4045ad30bd1d99441fa9d3 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Wed, 10 Jul 2024 18:40:08 -0700 Subject: [PATCH 1/3] Shorter success callbacks from /health/readiness Before: ```shell $ curl -sSL http://0.0.0.0:4000/health/readiness | jq '.success_callbacks' [ "langfuse", "", ">", "", "", "", "" ] ``` 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" ] ``` --- .../proxy/health_endpoints/_health_endpoints.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/health_endpoints/_health_endpoints.py b/litellm/proxy/health_endpoints/_health_endpoints.py index 29ad6bae7..e5ba03aac 100644 --- a/litellm/proxy/health_endpoints/_health_endpoints.py +++ b/litellm/proxy/health_endpoints/_health_endpoints.py @@ -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 From 6ccd6352167dfee2517966a1ce7e6b954dc1e331 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Wed, 10 Jul 2024 19:02:48 -0700 Subject: [PATCH 2/3] Update doc: health.md --- docs/my-website/docs/proxy/health.md | 34 +++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/docs/my-website/docs/proxy/health.md b/docs/my-website/docs/proxy/health.md index c67302e0d..5a8926576 100644 --- a/docs/my-website/docs/proxy/health.md +++ b/docs/my-website/docs/proxy/health.md @@ -128,9 +128,20 @@ Example Response: ```json { - "status": "healthy", - "db": "connected", - "litellm_version":"1.19.2", + "status": "connected", + "db": "connected", + "cache": null, + "litellm_version": "1.40.21", + "success_callbacks": [ + "langfuse", + "_PROXY_track_cost_callback", + "response_taking_too_long_callback", + "_PROXY_MaxParallelRequestsHandler", + "_PROXY_MaxBudgetLimiter", + "_PROXY_CacheControlCheck", + "ServiceLogging" + ], + "last_updated": "2024-07-10T18:59:10.616968" } ``` @@ -138,9 +149,20 @@ Example Response: ```json { - "status": "healthy", - "db": "Not connected", - "litellm_version":"1.19.2", + "status": "connected", + "db": "Not connected", + "cache": null, + "litellm_version": "1.40.21", + "success_callbacks": [ + "langfuse", + "_PROXY_track_cost_callback", + "response_taking_too_long_callback", + "_PROXY_MaxParallelRequestsHandler", + "_PROXY_MaxBudgetLimiter", + "_PROXY_CacheControlCheck", + "ServiceLogging" + ], + "last_updated": "2024-07-10T18:59:10.616968" } ``` From 434953b38c6ce92c1987f27d606e4d36a7f3f1b1 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Wed, 10 Jul 2024 19:08:48 -0700 Subject: [PATCH 3/3] More updates to health.md docs --- docs/my-website/docs/proxy/health.md | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/docs/my-website/docs/proxy/health.md b/docs/my-website/docs/proxy/health.md index 5a8926576..0f3926113 100644 --- a/docs/my-website/docs/proxy/health.md +++ b/docs/my-website/docs/proxy/health.md @@ -118,14 +118,12 @@ Unprotected endpoint for checking if proxy is ready to accept requests Example Request: -```bash -curl --location 'http://0.0.0.0:4000/health/readiness' +```bash +curl http://0.0.0.0:4000/health/readiness ``` Example Response: -*If proxy connected to a database* - ```json { "status": "connected", @@ -145,26 +143,8 @@ Example Response: } ``` -*If proxy not connected to a database* - -```json -{ - "status": "connected", - "db": "Not connected", - "cache": null, - "litellm_version": "1.40.21", - "success_callbacks": [ - "langfuse", - "_PROXY_track_cost_callback", - "response_taking_too_long_callback", - "_PROXY_MaxParallelRequestsHandler", - "_PROXY_MaxBudgetLimiter", - "_PROXY_CacheControlCheck", - "ServiceLogging" - ], - "last_updated": "2024-07-10T18:59:10.616968" -} -``` +If the proxy is not connected to a database, then the `"db"` field will be `"Not +connected"` instead of `"connected"` and the `"last_updated"` field will not be present. ## `/health/liveliness`