From 23a18d4be37c794e66bbc6182fa6c39e9b7f09f7 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 30 Mar 2024 14:02:43 -0700 Subject: [PATCH] (ui) show proxy spend --- litellm/proxy/proxy_server.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 629b6eaf725..ea6adb99ae5 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -5065,7 +5065,14 @@ async def global_spend_per_tea(): total_spend_per_team[team_alias] = spend total_spend_per_team_ui = [] + # order the elements in total_spend_per_team by spend + total_spend_per_team = dict( + sorted(total_spend_per_team.items(), key=lambda item: item[1], reverse=True) + ) for team_id in total_spend_per_team: + # only add first 10 elements to total_spend_per_team_ui + if len(total_spend_per_team_ui) >= 10: + break total_spend_per_team_ui.append( {"team_id": team_id, "total_spend": total_spend_per_team[team_id]} )