The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
ui fix rendering budget duration settings on ui
Ishaan Jaffba7891d33224
diff --git a/ui/litellm-dashboard/src/components/SSOSettings.tsx b/ui/litellm-dashboard/src/components/SSOSettings.tsxindex 21c10b7cec7..7b8470538a2 100644--- a/ui/litellm-dashboard/src/components/SSOSettings.tsx+++ b/ui/litellm-dashboard/src/components/SSOSettings.tsx@@ -2,12 +2,14 @@ import React, { useState, useEffect } from "react";import { Card, Title, Text, Divider, Button, TextInput } from "@tremor/react";import { Typography, Spin, message, Switch, Select, Form } from "antd";import { getInternalUserSettings, updateInternalUserSettings } from "./networking";+import BudgetDurationDropdown, { getBudgetDurationLabel } from "./common_components/budget_duration_dropdown";interface SSOSettingsProps {accessToken: string | null;+ possibleUIRoles?: Record<string, Record<string, string>> | null;}-const SSOSettings: React.FC<SSOSettingsProps> = ({ accessToken }) => {+const SSOSettings: React.FC<SSOSettingsProps> = ({ accessToken, possibleUIRoles }) => {const [loading, setLoading] = useState<boolean>(true);const [settings, setSettings] = useState<any>(null);const [isEditing, setIsEditing] = useState<boolean>(false);@@ -64,7 +66,35 @@ const SSOSettings: React.FC<SSOSettingsProps> = ({ accessToken }) => {const renderEditableField = (key: string, property: any, value: any) => {const type = property.type;- if (type === "boolean") {+ if (key === "user_role" && possibleUIRoles) {+ return (+ <Select+ style={{ width: '100%' }}+ value={editedValues[key] || ""}+ onChange={(value) => handleTextInputChange(key, value)}+ className="mt-2"+ >+ {Object.entries(possibleUIRoles)+ .filter(([role]) => role.includes("internal_user"))+ .map(([role, { ui_label, description }]) => (+ <Option key={role} value={role}>+ <div className="flex items-center">+ <span>{ui_label}</span>+ <span className="ml-2 text-xs text-gray-500">{description}</span>+ </div>+ </Option>+ ))}+ </Select>+ );+ } else if (key === "budget_duration") {+ return (+ <BudgetDurationDropdown+ value={editedValues[key] || null}+ onChange={(value) => handleTextInputChange(key, value)}+ className="mt-2"+ />+ );+ } else if (type === "boolean") {return (<div className="mt-2"><Switch@@ -112,9 +142,23 @@ const SSOSettings: React.FC<SSOSettingsProps> = ({ accessToken }) => {}};- const renderValue = (value: any): JSX.Element => {+ const renderValue = (key: string, value: any): JSX.Element => {if (value === null || value === undefined) return <span className="text-gray-400">Not set</span>;+ if (key === "user_role" && possibleUIRoles && possibleUIRoles[value]) {+ const { ui_label, description } = possibleUIRoles[value];+ return (+ <div>+ <span className="font-medium">{ui_label}</span>+ {description && <p className="text-xs text-gray-500 mt-1">{description}</p>}+ </div>+ );+ }++ if (key === "budget_duration") {+ return <span>{getBudgetDurationLabel(value)}</span>;+ }+if (typeof value === "boolean") {return <span>{value ? "Enabled" : "Disabled"}</span>;}@@ -186,7 +230,7 @@ const SSOSettings: React.FC<SSOSettingsProps> = ({ accessToken }) => {</div>) : (<div className="mt-1 p-2 bg-gray-50 rounded">- {renderValue(value)}+ {renderValue(key, value)}</div>)}</div>diff --git a/ui/litellm-dashboard/src/components/common_components/budget_duration_dropdown.tsx b/ui/litellm-dashboard/src/components/common_components/budget_duration_dropdown.tsxnew file mode 100644index 00000000000..9171e13381c--- /dev/null+++ b/ui/litellm-dashboard/src/components/common_components/budget_duration_dropdown.tsx@@ -0,0 +1,46 @@+import React from "react";+import { Select } from "antd";++const { Option } = Select;++interface BudgetDurationDropdownProps {+ value?: string | null;+ onChange: (value: string) => void;+ className?: string;+ style?: React.CSSProperties;+}++const BudgetDurationDropdown: React.FC<BudgetDurationDropdownProps> = ({+ value,+ onChange,+ className = "",+ style = {}+}) => {+ return (+ <Select+ style={{ width: '100%', ...style }}+ value={value || undefined}+ onChange={onChange}+ className={className}+ placeholder="n/a"+ >+ <Option value="24h">daily</Option>+ <Option value="7d">weekly</Option>+ <Option value="30d">monthly</Option>+ </Select>+ );+};++export const getBudgetDurationLabel = (value: string | null | undefined): string => {+ if (!value) return "Not set";++ const budgetDurationMap: Record<string, string> = {+ "24h": "daily",+ "7d": "weekly",+ "30d": "monthly"+ };++ return budgetDurationMap[value] || value;+};++export default BudgetDurationDropdown;\ No newline at end of filediff --git a/ui/litellm-dashboard/src/components/create_key_button.tsx b/ui/litellm-dashboard/src/components/create_key_button.tsxindex 0f93f61ff77..cc0a3899289 100644--- a/ui/litellm-dashboard/src/components/create_key_button.tsx+++ b/ui/litellm-dashboard/src/components/create_key_button.tsx@@ -40,6 +40,7 @@ import { Tooltip } from 'antd';import Createuser from "./create_user_button";import debounce from 'lodash/debounce';import { rolesWithWriteAccess } from '../utils/roles';+import BudgetDurationDropdown from "./common_components/budget_duration_dropdown";@@ -572,11 +573,7 @@ const CreateKey: React.FC<CreateKeyProps> = ({name="budget_duration"help={`Team Reset Budget: ${team?.budget_duration !== null && team?.budget_duration !== undefined ? team?.budget_duration : "None"}`}>- <Select defaultValue={null} placeholder="n/a">- <Select.Option value="24h">daily</Select.Option>- <Select.Option value="7d">weekly</Select.Option>- <Select.Option value="30d">monthly</Select.Option>- </Select>+ <BudgetDurationDropdown onChange={(value) => form.setFieldValue('budget_duration', value)} /></Form.Item><Form.ItemclassName="mt-4"diff --git a/ui/litellm-dashboard/src/components/view_users.tsx b/ui/litellm-dashboard/src/components/view_users.tsxindex 6c2db92d1c2..e728c481cdb 100644--- a/ui/litellm-dashboard/src/components/view_users.tsx+++ b/ui/litellm-dashboard/src/components/view_users.tsx@@ -290,7 +290,7 @@ const ViewUserDashboard: React.FC<ViewUserDashboardProps> = ({<TabGroup defaultIndex={0} onIndexChange={(index) => setActiveTab(index === 0 ? "users" : "settings")}><TabList className="mb-4"><Tab>Users</Tab>- <Tab>Personal Key Settings</Tab>+ <Tab>Default User Settings</Tab></TabList><TabPanels>@@ -348,7 +348,7 @@ const ViewUserDashboard: React.FC<ViewUserDashboardProps> = ({</TabPanel><TabPanel>- <SSOSettings accessToken={accessToken} />+ <SSOSettings accessToken={accessToken} possibleUIRoles={possibleUIRoles} /></TabPanel></TabPanels></TabGroup>