Skip to content

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]

refactor(ui): move the add model and credential forms off tremor (#37325)

ryan-crabbe-berri2059033352de
diff --git a/ui/litellm-dashboard/eslint-suppressions.json b/ui/litellm-dashboard/eslint-suppressions.json
index 5e285467284..9c475500b15 100644
--- a/ui/litellm-dashboard/eslint-suppressions.json
+++ b/ui/litellm-dashboard/eslint-suppressions.json
@@ -1848,7 +1848,7 @@
"count": 1
},
"no-restricted-imports": {
- "count": 4
+ "count": 3
}
},
"src/components/add_model/ClassificationMethodConfig.tsx": {
@@ -1899,7 +1899,7 @@
"count": 1
},
"no-restricted-imports": {
- "count": 4
+ "count": 3
},
"prefer-const": {
"count": 2
@@ -1934,7 +1934,7 @@
"count": 1
},
"no-restricted-imports": {
- "count": 2
+ "count": 1
},
"react-hooks/set-state-in-effect": {
"count": 2
@@ -1963,7 +1963,7 @@
"count": 1
},
"no-restricted-imports": {
- "count": 3
+ "count": 2
}
},
"src/components/add_model/model_connection_test.tsx": {
@@ -1984,10 +1984,10 @@
"count": 1
},
"no-nested-ternary": {
- "count": 5
+ "count": 3
},
"no-restricted-imports": {
- "count": 2
+ "count": 1
},
"react-hooks/immutability": {
"count": 3
@@ -2372,7 +2372,7 @@
},
"src/components/model_add/CredentialModal.tsx": {
"no-restricted-imports": {
- "count": 3
+ "count": 2
}
},
"src/components/model_add/reuse_credentials.tsx": {
diff --git a/ui/litellm-dashboard/src/components/add_model/AddModelForm.tsx b/ui/litellm-dashboard/src/components/add_model/AddModelForm.tsx
index 307f3665e83..de159207078 100644
--- a/ui/litellm-dashboard/src/components/add_model/AddModelForm.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/AddModelForm.tsx
@@ -3,7 +3,7 @@ import { useGuardrails } from "@/app/(dashboard)/hooks/guardrails/useGuardrails"
import { useTags } from "@/app/(dashboard)/hooks/tags/useTags";
import { all_admin_roles, isUserTeamAdminForAnyTeam } from "@/utils/roles";
import { modelCreationScope } from "@/utils/modelPermissions";
-import { Switch, Text } from "@tremor/react";
+import { Switch } from "@/components/ui/switch";
import type { FormInstance } from "antd";
import { Select as AntdSelect, Button, Card, Col, Form, Modal, Row, Tooltip, Typography, Alert } from "antd";
import type { UploadProps } from "antd/es/upload";
@@ -219,12 +219,12 @@ const AddModelForm: React.FC<AddModelFormProps> = ({
<Row>
<Col span={10}></Col>
<Col span={10}>
- <Text className="mb-5 mt-1">
+ <p className="text-sm mb-5 mt-1">
<strong>Optional</strong> - LiteLLM endpoint to use when health checking this model{" "}
<Link href="https://docs.litellm.ai/docs/proxy/health#health" target="_blank">
Learn more
</Link>
- </Text>
+ </p>
</Col>
</Row>
@@ -297,16 +297,19 @@ const AddModelForm: React.FC<AddModelFormProps> = ({
}
placement="top"
>
- <Switch
- checked={isTeamOnly}
- onChange={(checked) => {
- setIsTeamOnly(checked);
- if (!checked) {
- form.setFieldValue("team_id", undefined);
- }
- }}
- disabled={!premiumUser}
- />
+ <span className="inline-flex">
+ <Switch
+ checked={isTeamOnly}
+ onCheckedChange={(checked) => {
+ setIsTeamOnly(checked);
+ if (!checked) {
+ form.setFieldValue("team_id", undefined);
+ }
+ }}
+ disabled={!premiumUser}
+ aria-label="Team-BYOK Model"
+ />
+ </span>
</Tooltip>
</Form.Item>
)}
diff --git a/ui/litellm-dashboard/src/components/add_model/advanced_settings.tsx b/ui/litellm-dashboard/src/components/add_model/advanced_settings.tsx
index df20924d321..00b4c000a43 100644
--- a/ui/litellm-dashboard/src/components/add_model/advanced_settings.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/advanced_settings.tsx
@@ -1,6 +1,8 @@
import React from "react";
import { Form, Switch, Select, Tooltip, DatePicker } from "antd";
-import { Text, Accordion, AccordionHeader, AccordionBody, TextInput } from "@tremor/react";
+import { ChevronDown } from "lucide-react";
+import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
+import { Input } from "@/components/ui/input";
import { Row, Col, Typography } from "antd";
import TextArea from "antd/es/input/TextArea";
import { InfoCircleOutlined } from "@ant-design/icons";
@@ -118,11 +120,12 @@ const AdvancedSettings: React.FC<AdvancedSettingsProps> = ({
return (
<>
- <Accordion className="mt-2 mb-4">
- <AccordionHeader>
+ <Collapsible className="mt-2 mb-4 overflow-hidden rounded-lg border">
+ <CollapsibleTrigger className="group/section flex w-full items-center justify-between px-4 py-3 text-left">
<b>Advanced Settings</b>
- </AccordionHeader>
- <AccordionBody>
+ <ChevronDown className="size-5 shrink-0 text-gray-500 transition-transform group-data-[panel-open]/section:rotate-180" />
+ </CollapsibleTrigger>
+ <CollapsibleContent className="px-4 pb-3">
<div className="bg-white rounded-lg">
<Form.Item label="Custom Pricing" name="custom_pricing" valuePropName="checked" className="mb-4">
<Switch onChange={handleCustomPricingChange} className="bg-gray-600" />
@@ -206,7 +209,7 @@ const AdvancedSettings: React.FC<AdvancedSettingsProps> = ({
tooltip="Provisioned throughput units for this deployment. Set together with Cost per PTU / Hour and a Team to attribute a flat daily cost."
className="mb-4"
>
- <TextInput placeholder="e.g. 15" />
+ <Input placeholder="e.g. 15" />
</Form.Item>
<Form.Item
@@ -217,7 +220,7 @@ const AdvancedSettings: React.FC<AdvancedSettingsProps> = ({
tooltip="Flat cost = PTU count * this rate * active hours, attributed to the deployment's team."
className="mb-4"
>
- <TextInput placeholder="e.g. 2.00" />
+ <Input placeholder="e.g. 2.00" />
</Form.Item>
<Form.Item
@@ -266,7 +269,7 @@ const AdvancedSettings: React.FC<AdvancedSettingsProps> = ({
rules={[{ validator: validateNumber }, ptuNoUsageCostRule(PTU_COUNT_FIELD)]}
className="mb-4"
>
- <TextInput />
+ <Input />
</Form.Item>
<Form.Item
label="Output Cost (per 1M tokens)"
@@ -275,7 +278,7 @@ const AdvancedSettings: React.FC<AdvancedSettingsProps> = ({
rules={[{ validator: validateNumber }, ptuNoUsageCostRule(PTU_COUNT_FIELD)]}
className="mb-4"
>
- <TextInput />
+ <Input />
</Form.Item>
<Form.Item
label="Cache Read Cost (per 1M tokens)"
@@ -285,7 +288,7 @@ const AdvancedSettings: React.FC<AdvancedSettingsProps> = ({
tooltip="If left blank, defaults to Input Cost."
className="mb-4"
>
- <TextInput placeholder="Defaults to Input Cost if blank" />
+ <Input placeholder="Defaults to Input Cost if blank" />
</Form.Item>
<Form.Item
label="Cache Write Cost (per 1M tokens)"
@@ -295,7 +298,7 @@ const AdvancedSettings: React.FC<AdvancedSettingsProps> = ({
tooltip="If left blank, defaults to Input Cost (the backend falls back to input_cost_per_token when no cache-write rate is set)."
className="mb-4"
>
- <TextInput placeholder="Defaults to Input Cost if blank" />
+ <Input placeholder="Defaults to Input Cost if blank" />
</Form.Item>
</>
) : (
@@ -306,7 +309,7 @@ const AdvancedSettings: React.FC<AdvancedSettingsProps> = ({
rules={[{ validator: validateNumber }, ptuNoUsageCostRule(PTU_COUNT_FIELD)]}
className="mb-4"
>
- <TextInput />
+ <Input />
</Form.Item>
)}
</div>
@@ -353,12 +356,12 @@ const AdvancedSettings: React.FC<AdvancedSettingsProps> = ({
<Row className="mb-4">
<Col span={10}></Col>
<Col span={10}>
- <Text className="text-gray-600 text-sm">
+ <p className="text-gray-600 text-sm">
Pass JSON of litellm supported params{" "}
<Link href="https://docs.litellm.ai/docs/completion/input" target="_blank">
litellm.completion() call
</Link>
- </Text>
+ </p>
</Col>
</Row>
<Form.Item
@@ -376,8 +379,8 @@ const AdvancedSettings: React.FC<AdvancedSettingsProps> = ({
/>
</Form.Item>
</div>
- </AccordionBody>
- </Accordion>
+ </CollapsibleContent>
+ </Collapsible>
</>
);
};
diff --git a/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.tsx b/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.tsx
index f819ec5977b..8f95973b558 100644
--- a/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.tsx
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from "react";
import { Form, Table } from "antd";
-import { TextInput } from "@tremor/react";
+import { Input } from "@/components/ui/input";
import { Tooltip } from "../atoms/index";
import { Providers } from "../provider_info_helpers";
@@ -126,7 +126,7 @@ const ConditionalPublicModelName: React.FC = () => {
key: "public_name",
render: (text: string, record: any, index: number) => {
return (
- <TextInput
+ <Input
value={text}
onChange={(e) => {
const newValue = e.target.value;
diff --git a/ui/litellm-dashboard/src/components/add_model/litellm_model_name.tsx b/ui/litellm-dashboard/src/components/add_model/litellm_model_name.tsx
index 56ecfcd3d76..86167a8902e 100644
--- a/ui/litellm-dashboard/src/components/add_model/litellm_model_name.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/litellm_model_name.tsx
@@ -1,6 +1,6 @@
import React from "react";
import { Form, Select as AntSelect } from "antd";
-import { TextInput, Text } from "@tremor/react";
+import { Input } from "@/components/ui/input";
import { Row, Col } from "antd";
import { Providers } from "../provider_info_helpers";
@@ -119,7 +119,7 @@ const LiteLLMModelNameField: React.FC<LiteLLMModelNameFieldProps> = ({
selectedProvider === Providers.OpenAI_Compatible ||
selectedProvider === Providers.Ollama ? (
<>
- <TextInput
+ <Input
placeholder={getPlaceholder(selectedProvider)}
onChange={selectedProvider === Providers.Azure ? handleAzureDeploymentNameChange : undefined}
/>
@@ -151,7 +151,7 @@ const LiteLLMModelNameField: React.FC<LiteLLMModelNameFieldProps> = ({
style={{ width: "100%" }}
/>
) : (
- <TextInput placeholder={getPlaceholder(selectedProvider)} />
+ <Input placeholder={getPlaceholder(selectedProvider)} />
)}
</Form.Item>
@@ -167,7 +167,7 @@ const LiteLLMModelNameField: React.FC<LiteLLMModelNameFieldProps> = ({
rules={[{ required: true, message: "Please enter a custom model name." }]}
className="mt-2"
>
- <TextInput
+ <Input
placeholder={
selectedProvider === Providers.Azure ? "Enter Azure deployment name" : "Enter custom model name"
}
@@ -182,11 +182,11 @@ const LiteLLMModelNameField: React.FC<LiteLLMModelNameFieldProps> = ({
<Row>
<Col span={10}></Col>
<Col span={14}>
- <Text className="mb-3 mt-1">
+ <p className="text-sm mb-3 mt-1">
{selectedProvider === Providers.Azure
? "Your deployment name will be saved as the public model name, and LiteLLM will use 'azure/deployment-name' internally"
: "The model name LiteLLM will send to the LLM API"}
- </Text>
+ </p>
</Col>
</Row>
</>
diff --git a/ui/litellm-dashboard/src/components/add_model/provider_specific_fields.test.tsx b/ui/litellm-dashboard/src/components/add_model/provider_specific_fields.test.tsx
index bf62b4873b7..351b0db0b4b 100644
--- a/ui/litellm-dashboard/src/components/add_model/provider_specific_fields.test.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/provider_specific_fields.test.tsx
@@ -161,6 +161,23 @@ describe("ProviderSpecificFields", () => {
expect(orgInput).toBeInTheDocument();
});
+ it("should let the user reveal a secret field", async () => {
+ const queryClient = createQueryClient();
+ render(
+ <QueryClientProvider client={queryClient}>
+ <Form>
+ <ProviderSpecificFields selectedProvider={Providers.OpenAI} />
+ </Form>
+ </QueryClientProvider>,
+ );
+
+ const apiKeyInput = await screen.findByLabelText("OpenAI API Key");
+ expect(apiKeyInput).toHaveAttribute("type", "password");
+
+ fireEvent.click(screen.getByLabelText("eye-invisible"));
+ expect(await screen.findByLabelText("OpenAI API Key")).toHaveAttribute("type", "text");
+ });
+
it("should render the provider specific fields for vLLM", async () => {
const queryClient = createQueryClient();
render(
diff --git a/ui/litellm-dashboard/src/components/add_model/provider_specific_fields.tsx b/ui/litellm-dashboard/src/components/add_model/provider_specific_fields.tsx
index 92badeb0ff9..2bbf2b0cfa5 100644
--- a/ui/litellm-dashboard/src/components/add_model/provider_specific_fields.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/provider_specific_fields.tsx
@@ -1,7 +1,7 @@
import { useProviderFields } from "@/app/(dashboard)/hooks/providers/useProviderFields";
import { UploadOutlined } from "@ant-design/icons";
-import { Text, TextInput } from "@tremor/react";
-import { Button as Button2, Col, Form, Input, Row, Select, Typography, Upload, UploadProps } from "antd";
+import { Input } from "@/components/ui/input";
+import { Button as Button2, Col, Form, Input as AntdInput, Row, Select, Typography, Upload, UploadProps } from "antd";
import React from "react";
import { CredentialItem, ProviderCredentialFieldMetadata } from "../networking";
import { provider_map, Providers } from "../provider_info_helpers";
@@ -216,21 +216,74 @@ const ProviderSpecificFields: React.FC<ProviderSpecificFieldsProps> = ({ selecte
},
};
+ const renderFieldControl = (field: ProviderCredentialField) => {
+ if (field.type === "select") {
+ return (
+ <Select placeholder={field.placeholder} defaultValue={field.defaultValue}>
+ {field.options?.map((option) => (
+ <Select.Option key={option} value={option}>
+ {option}
+ </Select.Option>
+ ))}
+ </Select>
+ );
+ }
+
+ if (field.type === "upload") {
+ return (
+ <Upload
+ {...handleUpload}
+ onChange={(info) => {
+ if (uploadProps?.onChange) {
+ uploadProps.onChange(info);
+ }
+ }}
+ >
+ <Button2 icon={<UploadOutlined />}>Click to Upload</Button2>
+ </Upload>
+ );
+ }
+
+ if (field.type === "textarea") {
+ return (
+ <AntdInput.TextArea
+ placeholder={field.placeholder}
+ defaultValue={field.defaultValue}
+ rows={6}
+ style={{ fontFamily: "monospace", fontSize: "12px" }}
+ />
+ );
+ }
+
+ if (field.type === "password") {
+ return <AntdInput.Password placeholder={field.placeholder} defaultValue={field.defaultValue} />;
+ }
+
+ return (
+ <Input
+ placeholder={field.placeholder}
+ type="text"
+ defaultValue={field.defaultValue}
+ onChange={field.key === "api_base" ? handleApiBaseChange : undefined}
+ />
+ );
+ };
+
return (
<>
{isLoading && allFields.length === 0 && (
<Row>
<Col span={24}>
- <Text className="mb-2">Loading provider fields...</Text>
+ <p className="text-sm mb-2">Loading provider fields...</p>
</Col>
</Row>
)}
{loadError && allFields.length === 0 && (
<Row>
<Col span={24}>
- <Text className="mb-2 text-red-500">
+ <p className="text-sm mb-2 text-red-500">
{loadError instanceof Error ? loadError.message : "Failed to load provider credential fields"}
- </Text>
+ </p>
</Col>
</Row>
)}
@@ -243,47 +296,14 @@ const ProviderSpecificFields: React.FC<ProviderSpecificFieldsProps> = ({ selecte
tooltip={field.tooltip}
className={field.key === "vertex_credentials" ? "mb-0" : undefined}
>
- {field.type === "select" ? (
- <Select placeholder={field.placeholder} defaultValue={field.defaultValue}>
- {field.options?.map((option) => (
- <Select.Option key={option} value={option}>
- {option}
- </Select.Option>
- ))}
- </Select>
- ) : field.type === "upload" ? (
- <Upload
- {...handleUpload}
- onChange={(info) => {
- if (uploadProps?.onChange) {
- uploadProps.onChange(info);
- }
- }}
- >
- <Button2 icon={<UploadOutlined />}>Click to Upload</Button2>
- </Upload>
- ) : field.type === "textarea" ? (
- <Input.TextArea
- placeholder={field.placeholder}
- defaultValue={field.defaultValue}
- rows={6}
- style={{ fontFamily: "monospace", fontSize: "12px" }}
- />
- ) : (
- <TextInput
- placeholder={field.placeholder}
- type={field.type === "password" ? "password" : "text"}
- defaultValue={field.defaultValue}
- onChange={field.key === "api_base" ? handleApiBaseChange : undefined}
- />
- )}
+ {renderFieldControl(field)}
</Form.Item>
{/* Special case for Vertex Credentials help text */}
{field.key === "vertex_credentials" && (
<Row>
<Col>
- <Text className="mb-3 mt-1">Give a gcp service account(.json file)</Text>
+ <p className="text-sm mb-3 mt-1">Give a gcp service account(.json file)</p>
</Col>
</Row>
)}
@@ -293,7 +313,7 @@ const ProviderSpecificFields: React.FC<ProviderSpecificFieldsProps> = ({ selecte
<Row>
<Col span={10}></Col>
<Col span={10}>
- <Text className="mb-2">
+ <p className="text-sm mb-2">
The actual model your azure deployment uses. Used for accurate cost tracking. Select name from{" "}
<Link
href="https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json"
@@ -301,7 +321,7 @@ const ProviderSpecificFields: React.FC<ProviderSpecificFieldsProps> = ({ selecte
>
here
</Link>
- </Text>
+ </p>
</Col>
</Row>
)}
diff --git a/ui/litellm-dashboard/src/components/model_add/CredentialModal.tsx b/ui/litellm-dashboard/src/components/model_add/CredentialModal.tsx
index 534e06dfe52..fca75853973 100644
--- a/ui/litellm-dashboard/src/components/model_add/CredentialModal.tsx
+++ b/ui/litellm-dashboard/src/components/model_add/CredentialModal.tsx
@@ -1,4 +1,4 @@
-import { TextInput } from "@tremor/react";
+import { Input } from "@/components/ui/input";
import { Select as AntdSelect, Button, Form, Modal, Tooltip, Typography } from "antd";
import type { UploadProps } from "antd/es/upload";
import { useState } from "react";
@@ -74,7 +74,7 @@ export default function CredentialModal({
name="credential_name"
rules={[{ required: true, message: "Credential name is required" }]}
>
- <TextInput placeholder="Enter a friendly name for these credentials" disabled={isEdit} />
+ <Input placeholder="Enter a friendly name for these credentials" disabled={isEdit} />
</Form.Item>
<Form.Item