From 31e600c4fe18a5aac4dae0ddae4bb35c4e0f9941 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 20 Apr 2024 15:50:01 -0700 Subject: [PATCH 1/4] (ui) - simplify user flow --- .../src/components/create_key_button.tsx | 62 +++++++++++++++++-- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/ui/litellm-dashboard/src/components/create_key_button.tsx b/ui/litellm-dashboard/src/components/create_key_button.tsx index d7fb9c5eb..6edc90dfc 100644 --- a/ui/litellm-dashboard/src/components/create_key_button.tsx +++ b/ui/litellm-dashboard/src/components/create_key_button.tsx @@ -116,7 +116,7 @@ const CreateKey: React.FC = ({ wrapperCol={{ span: 16 }} labelAlign="left" > - {userRole === "App Owner" || userRole === "Admin" || userRole === "App User" ? ( + {userRole === "App Owner" || userRole === "Admin" ? ( <> = ({ ) : ( <> - + - - + - - + + + )}
From a71d4fc17244b92ef0ffd3e51df5ddae1b57ea84 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 20 Apr 2024 15:55:18 -0700 Subject: [PATCH 2/4] (ui) hide default team for non admins --- .../src/components/dashboard_default_team.tsx | 11 +++++++++-- .../src/components/user_dashboard.tsx | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ui/litellm-dashboard/src/components/dashboard_default_team.tsx b/ui/litellm-dashboard/src/components/dashboard_default_team.tsx index b3976912b..0abfd1a56 100644 --- a/ui/litellm-dashboard/src/components/dashboard_default_team.tsx +++ b/ui/litellm-dashboard/src/components/dashboard_default_team.tsx @@ -4,6 +4,7 @@ import { Select, SelectItem, Text, Title } from "@tremor/react"; interface DashboardTeamProps { teams: Object[] | null; setSelectedTeam: React.Dispatch>; + userRole: string | null; } type TeamInterface = { @@ -15,6 +16,7 @@ type TeamInterface = { const DashboardTeam: React.FC = ({ teams, setSelectedTeam, + userRole, }) => { const defaultTeam: TeamInterface = { models: [], @@ -25,8 +27,13 @@ const DashboardTeam: React.FC = ({ const [value, setValue] = useState(defaultTeam); - const updatedTeams = teams ? [...teams, defaultTeam] : [defaultTeam]; - + let updatedTeams; + if (userRole === "App User") { + // Non-Admin SSO users should only see their own team - they should not see "Default Team" + updatedTeams = teams; + } else { + updatedTeams = teams ? [...teams, defaultTeam] : [defaultTeam]; + } return (
diff --git a/ui/litellm-dashboard/src/components/user_dashboard.tsx b/ui/litellm-dashboard/src/components/user_dashboard.tsx index 3f6a988b3..c06b72883 100644 --- a/ui/litellm-dashboard/src/components/user_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/user_dashboard.tsx @@ -257,7 +257,7 @@ const UserDashboard: React.FC = ({ data={keys} setData={setKeys} /> - +
From aad827e40f292332ec7a615756cc8112d55c5a8e Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 20 Apr 2024 16:25:44 -0700 Subject: [PATCH 3/4] ui - see extra optional params in accordion --- .../src/components/create_key_button.tsx | 79 ++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/ui/litellm-dashboard/src/components/create_key_button.tsx b/ui/litellm-dashboard/src/components/create_key_button.tsx index 6edc90dfc..d8716d304 100644 --- a/ui/litellm-dashboard/src/components/create_key_button.tsx +++ b/ui/litellm-dashboard/src/components/create_key_button.tsx @@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef } from "react"; import { Button, TextInput, Grid, Col } from "@tremor/react"; -import { Card, Metric, Text, Title, Subtitle } from "@tremor/react"; +import { Card, Metric, Text, Title, Subtitle, Accordion, AccordionHeader, AccordionBody, } from "@tremor/react"; import { CopyToClipboard } from 'react-copy-to-clipboard'; import { Button as Button2, @@ -308,6 +308,83 @@ const CreateKey: React.FC = ({ + + + Optional Settings + + + { + if (value && team && team.max_budget !== null && value > team.max_budget) { + throw new Error(`Budget cannot exceed team max budget: $${team.max_budget}`); + } + }, + }, + ]} + > + + + + + + { + if (value && team && team.tpm_limit !== null && value > team.tpm_limit) { + throw new Error(`TPM limit cannot exceed team TPM limit: ${team.tpm_limit}`); + } + }, + }, + ]} + > + + + { + if (value && team && team.rpm_limit !== null && value > team.rpm_limit) { + throw new Error(`RPM limit cannot exceed team RPM limit: ${team.rpm_limit}`); + } + }, + }, + ]} + > + + + + + + + + + + + + )}
From 41d3a17f1d6e435fb571f7463289d9f509c6b30a Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 20 Apr 2024 16:30:17 -0700 Subject: [PATCH 4/4] ui - non admin flow --- .../src/components/dashboard_default_team.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ui/litellm-dashboard/src/components/dashboard_default_team.tsx b/ui/litellm-dashboard/src/components/dashboard_default_team.tsx index 0abfd1a56..c845ef150 100644 --- a/ui/litellm-dashboard/src/components/dashboard_default_team.tsx +++ b/ui/litellm-dashboard/src/components/dashboard_default_team.tsx @@ -38,13 +38,16 @@ const DashboardTeam: React.FC = ({ return (
Select Team - - If you belong to multiple teams, this setting controls which team is - used by default when creating new API Keys. - - - Default Team: If no team_id is set for a key, it will be grouped under here. - + {userRole !== "App User" && ( + <> + + If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys. + + + Default Team: If no team_id is set for a key, it will be grouped under here. + + + )} {updatedTeams && updatedTeams.length > 0 ? (