From 55115a75b02f79b978976fdf26084d8844b4bf1c Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Thu, 25 Jan 2024 10:01:32 -0800 Subject: [PATCH] (feat) alerts proxy budgets --- litellm/proxy/utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 9f7dd1c870..ab14411bb6 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -186,7 +186,23 @@ class ProxyLogging: type: Literal["token_budget", "user_budget", "user_and_proxy_budget"], user_max_budget: float, user_current_spend: float, + user_info=None, ): + # percent of max_budget left to spend + percent_left = (user_max_budget - user_current_spend) / user_max_budget + + # check if 15% of max budget is left + if percent_left <= 0.15: + pass + + # check if 5% of max budget is left + if percent_left <= 0.05: + pass + + # check if crossed budget + if user_current_spend >= user_max_budget: + pass + pass async def alerting_handler(