forked from phoenix/litellm-mirror
(feat) alerts proxy budgets
This commit is contained in:
parent
565531fe9e
commit
55115a75b0
1 changed files with 16 additions and 0 deletions
|
@ -186,7 +186,23 @@ class ProxyLogging:
|
||||||
type: Literal["token_budget", "user_budget", "user_and_proxy_budget"],
|
type: Literal["token_budget", "user_budget", "user_and_proxy_budget"],
|
||||||
user_max_budget: float,
|
user_max_budget: float,
|
||||||
user_current_spend: 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
|
pass
|
||||||
|
|
||||||
async def alerting_handler(
|
async def alerting_handler(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue