From 7df2d7cb33416f27bb4da80b44bee273b92d01f5 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Fri, 29 Mar 2024 09:41:00 -0700 Subject: [PATCH] (fix) show correct spend on ui --- litellm/proxy/proxy_server.py | 8 +------- .../src/components/create_key_button.tsx | 11 ++--------- ui/litellm-dashboard/src/components/networking.tsx | 3 ++- .../src/components/view_user_spend.tsx | 2 +- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 61cae71bd9..f888ce4316 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -4881,13 +4881,7 @@ async def global_spend(): if user_response is not None: if isinstance(user_response, list) and len(user_response) > 0: total_proxy_budget = user_response[0].get("max_budget", 0.0) - litellm_proxy_budget_spend = user_response[0].get("spend", None) - if ( - litellm_proxy_budget_spend is not None - and litellm_proxy_budget_spend > 0.0 - ): - # if the user has spend on litellm-proxy-budget, use that to show $spend/max budget - total_spend = litellm_proxy_budget_spend + return {"spend": total_spend, "max_budget": total_proxy_budget} diff --git a/ui/litellm-dashboard/src/components/create_key_button.tsx b/ui/litellm-dashboard/src/components/create_key_button.tsx index dcf66cd063..a79144419a 100644 --- a/ui/litellm-dashboard/src/components/create_key_button.tsx +++ b/ui/litellm-dashboard/src/components/create_key_button.tsx @@ -276,17 +276,10 @@ const CreateKey: React.FC = ({ {apiKey != null ? (
API Key: {apiKey} - Budgets - Soft Limit Budget: ${softBudget} + - - (LiteLLM Docs - - - Set Up Slack Alerting) - -
) : ( Key being created, this might take 30s diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx index 23920df106..5fe5ffa2b5 100644 --- a/ui/litellm-dashboard/src/components/networking.tsx +++ b/ui/litellm-dashboard/src/components/networking.tsx @@ -231,7 +231,8 @@ export const getTotalSpendCall = async ( } const data = await response.json(); - //message.info("Received model data"); + message.info("global spend", data); + console.log("global soend", data) return data; // Handle success - you might want to update some state or UI based on the created key } catch (error) { diff --git a/ui/litellm-dashboard/src/components/view_user_spend.tsx b/ui/litellm-dashboard/src/components/view_user_spend.tsx index c0c385308d..45d0913c22 100644 --- a/ui/litellm-dashboard/src/components/view_user_spend.tsx +++ b/ui/litellm-dashboard/src/components/view_user_spend.tsx @@ -55,7 +55,7 @@ const ViewUserSpend: React.FC = ({ userID, userSpendData, us const displayMaxBudget = maxBudget !== null ? `$${maxBudget} limit` : "No limit"; - const roundedSpend = spend !== undefined ? spend.toFixed(4) : null; + const roundedSpend = spend !== undefined ? spend.toFixed(5) : null; return ( <>