From 50f5184c69c97ee1f701935a652bc8f16faec703 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 25 May 2024 13:13:02 -0700 Subject: [PATCH] ui - enforce premium features behind a license --- ui/litellm-dashboard/src/app/page.tsx | 1 + ui/litellm-dashboard/src/components/usage.tsx | 93 ++++++++++++++++++- 2 files changed, 89 insertions(+), 5 deletions(-) diff --git a/ui/litellm-dashboard/src/app/page.tsx b/ui/litellm-dashboard/src/app/page.tsx index 845e7d957..ed24020e9 100644 --- a/ui/litellm-dashboard/src/app/page.tsx +++ b/ui/litellm-dashboard/src/app/page.tsx @@ -199,6 +199,7 @@ const CreateKeyPage = () => { token={token} accessToken={accessToken} keys={keys} + premiumUser={premiumUser} /> )} diff --git a/ui/litellm-dashboard/src/components/usage.tsx b/ui/litellm-dashboard/src/components/usage.tsx index b236ae702..dc77692b6 100644 --- a/ui/litellm-dashboard/src/components/usage.tsx +++ b/ui/litellm-dashboard/src/components/usage.tsx @@ -10,6 +10,8 @@ import { DateRangePicker, DateRangePickerValue, DonutChart, AreaChart, + Callout, + Button, } from "@tremor/react"; import { userSpendLogsCall, @@ -35,6 +37,7 @@ interface UsagePageProps { userRole: string | null; userID: string | null; keys: any[] | null; + premiumUser: boolean; } interface GlobalActivityData { @@ -122,6 +125,7 @@ const UsagePage: React.FC = ({ userRole, userID, keys, + premiumUser, }) => { const currentDate = new Date(); const [keySpendData, setKeySpendData] = useState([]); @@ -156,6 +160,7 @@ const UsagePage: React.FC = ({ let endTime = formatDate(lastDay); console.log("keys in usage", keys); + console.log("premium user in usage", premiumUser); const updateEndUserData = async (startTime: Date | undefined, endTime: Date | undefined, uiSelectedKey: string | null) => { if (!startTime || !endTime || !accessToken) { @@ -362,7 +367,7 @@ const UsagePage: React.FC = ({ - + Monthly Spend @@ -418,7 +423,10 @@ const UsagePage: React.FC = ({ ✨ Spend by Provider - + { + premiumUser ? ( + <> + = ({ + + ) : ( +
+

Upgrade to use this feature

+ +
+ ) + } +
@@ -488,7 +509,10 @@ const UsagePage: React.FC = ({ - {globalActivityPerModel.map((globalActivity, index) => ( + { + premiumUser ? ( + <> + {globalActivityPerModel.map((globalActivity, index) => ( {globalActivity.model} @@ -517,8 +541,67 @@ const UsagePage: React.FC = ({ ))} - - + + ) : + <> + {globalActivityPerModel && globalActivityPerModel.length > 0 && + globalActivityPerModel.slice(0, 1).map((globalActivity, index) => ( + + ✨ Activity by Model +

Upgrade to see analytics for all models

+ + + {globalActivity.model} + + + + API Requests {globalActivity.sum_api_requests} + + console.log(v)} + /> + + + + Tokens {globalActivity.sum_total_tokens} + + console.log(v)} + /> + + + + +
+ ))} + + }