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]

[Fix] UI - Test Key Page Revert Model To Single Select (#16390)

yuneng-jiange26875b8ed36
diff --git a/ui/litellm-dashboard/src/components/chat_ui/ChatUI.test.tsx b/ui/litellm-dashboard/src/components/chat_ui/ChatUI.test.tsx
index 64b6f9c0850..6670395aad5 100644
--- a/ui/litellm-dashboard/src/components/chat_ui/ChatUI.test.tsx
+++ b/ui/litellm-dashboard/src/components/chat_ui/ChatUI.test.tsx
@@ -49,55 +49,10 @@ describe("ChatUI", () => {
disabledPersonalKeyCreation={false}
/>,
);
-
- await waitFor(() => {
- expect(getByText("Test Key")).toBeInTheDocument();
- });
- });
-
- it("should render the chat UI with selected models", async () => {
- const { getByText, container, getAllByText } = render(
- <ChatUI
- accessToken="1234567890"
- token="1234567890"
- userRole="user"
- userID="1234567890"
- disabledPersonalKeyCreation={false}
- />,
- );
-
- await waitFor(() => {
- expect(getByText("Test Key")).toBeInTheDocument();
- });
-
- // Wait for the first model to be auto-selected (default behavior)
- await waitFor(() => {
- expect(getByText("Model 1")).toBeInTheDocument();
- });
-
- // Now click the Select dropdown to open it and check other models
- const selectComponent = container.querySelectorAll(".ant-select-selector")[1]; // Second select is for models
- expect(selectComponent).toBeTruthy();
-
- // Click to open the dropdown
- fireEvent.mouseDown(selectComponent!);
-
- // Wait for dropdown to open and check for all models
- await waitFor(() => {
- const dropdown = document.querySelector(".ant-select-dropdown");
- expect(dropdown).toBeTruthy();
-
- // All three models should be in the dropdown as options
- // Use getAllByTitle since Ant Design Select renders options with title attributes
- const model2Elements = screen.queryAllByText("Model 2");
- const model3Elements = screen.queryAllByText("Model 3");
-
- expect(model2Elements.length).toBeGreaterThan(0);
- expect(model3Elements.length).toBeGreaterThan(0);
- });
+ expect(getByText("Test Key")).toBeInTheDocument();
});
- it("should allow users to pick multiple models and render badges for selected models", async () => {
+ it("should show the voice selector when the endpoint type is audio_speech", async () => {
const { getByText, container } = render(
<ChatUI
accessToken="1234567890"
@@ -108,66 +63,46 @@ describe("ChatUI", () => {
/>,
);
+ // Wait for the component to render
await waitFor(() => {
expect(getByText("Test Key")).toBeInTheDocument();
});
- await waitFor(() => {
- expect(getByText("Model 1")).toBeInTheDocument();
- });
-
- const selectComponent = container.querySelectorAll(".ant-select-selector")[1];
- expect(selectComponent).toBeTruthy();
-
- fireEvent.mouseDown(selectComponent!);
+ // Find the endpoint selector by looking for the "Endpoint Type:" text and its associated Select
+ const endpointTypeText = getByText("Endpoint Type");
+ const selectContainer = endpointTypeText.parentElement;
+ const selectElement = selectContainer?.querySelector(".ant-select-selector");
- let model2Option: HTMLElement | null = null;
- await waitFor(() => {
- const dropdown = document.querySelector(".ant-select-dropdown");
- expect(dropdown).toBeTruthy();
- const options = document.querySelectorAll(".ant-select-item-option-content");
- model2Option = Array.from(options).find((opt) => opt.textContent === "Model 2") as HTMLElement;
- expect(model2Option).toBeTruthy();
- });
+ expect(selectElement).toBeInTheDocument();
- fireEvent.click(model2Option!);
+ // Click on the select to open the dropdown
+ if (selectElement) {
+ fireEvent.mouseDown(selectElement);
+ }
+ // Wait for the dropdown to appear and find the audio_speech option
await waitFor(() => {
- const model1Badges = screen.getAllByText("Model 1");
- const model2Badges = screen.getAllByText("Model 2");
-
- expect(model1Badges.length).toBeGreaterThan(0);
- expect(model2Badges.length).toBeGreaterThan(0);
+ const audioSpeechOption = screen.getByText("/v1/audio/speech");
+ expect(audioSpeechOption).toBeInTheDocument();
});
- fireEvent.mouseDown(selectComponent!);
+ // Click on the audio_speech option
+ const audioSpeechOption = screen.getByText("/v1/audio/speech");
+ fireEvent.click(audioSpeechOption);
- let model3Option: HTMLElement | null = null;
+ // Verify the voice selector appears
await waitFor(() => {
- const dropdown = document.querySelector(".ant-select-dropdown");
- expect(dropdown).toBeTruthy();
- const options = document.querySelectorAll(".ant-select-item-option-content");
- model3Option = Array.from(options).find((opt) => opt.textContent === "Model 3") as HTMLElement;
- expect(model3Option).toBeTruthy();
+ expect(getByText("Voice")).toBeInTheDocument();
});
- fireEvent.click(model3Option!);
-
- // Verify all three models have badges rendered
- await waitFor(() => {
- const model1Badges = screen.getAllByText("Model 1");
- const model2Badges = screen.getAllByText("Model 2");
- const model3Badges = screen.getAllByText("Model 3");
-
- expect(model1Badges.length).toBeGreaterThan(0);
- expect(model2Badges.length).toBeGreaterThan(0);
- expect(model3Badges.length).toBeGreaterThan(0);
- });
- const tags = container.querySelectorAll(".ant-tag");
- expect(tags.length).toBe(3);
+ // Verify the voice select component is present
+ const voiceText = getByText("Voice");
+ const voiceSelectContainer = voiceText.parentElement;
+ const voiceSelectElement = voiceSelectContainer?.querySelector(".ant-select");
+ expect(voiceSelectElement).toBeInTheDocument();
});
- it("should manage selectedModels state and its side effects", async () => {
+ it("should allow the user to select a model", async () => {
const { getByText, container } = render(
<ChatUI
accessToken="1234567890"
@@ -178,6 +113,7 @@ describe("ChatUI", () => {
/>,
);
+ // Wait for the component to render
await waitFor(() => {
expect(getByText("Test Key")).toBeInTheDocument();
});
@@ -186,109 +122,14 @@ describe("ChatUI", () => {
expect(getByText("Model 1")).toBeInTheDocument();
});
- await waitFor(() => {
- const storedModels = sessionStorage.getItem("selectedModels");
- expect(storedModels).toBeTruthy();
- const parsedModels = JSON.parse(storedModels!);
- expect(parsedModels).toContain("Model 1");
- });
-
const selectComponent = container.querySelectorAll(".ant-select-selector")[1];
+ expect(selectComponent).toBeTruthy();
fireEvent.mouseDown(selectComponent!);
- let model2Option: HTMLElement | null = null;
- await waitFor(() => {
- const dropdown = document.querySelector(".ant-select-dropdown");
- expect(dropdown).toBeTruthy();
- const options = document.querySelectorAll(".ant-select-item-option-content");
- model2Option = Array.from(options).find((opt) => opt.textContent === "Model 2") as HTMLElement;
- expect(model2Option).toBeTruthy();
- });
-
- fireEvent.click(model2Option!);
-
- await waitFor(() => {
- const model2Badges = screen.getAllByText("Model 2");
- expect(model2Badges.length).toBeGreaterThan(0);
- });
-
- await waitFor(() => {
- const storedModels = sessionStorage.getItem("selectedModels");
- const parsedModels = JSON.parse(storedModels!);
- expect(parsedModels).toContain("Model 1");
- expect(parsedModels).toContain("Model 2");
- expect(parsedModels.length).toBe(2);
- });
-
- const tags = container.querySelectorAll(".ant-tag");
- expect(tags.length).toBe(2);
-
- const firstTagCloseButton = tags[0].querySelector(".ant-tag-close-icon");
- expect(firstTagCloseButton).toBeTruthy();
- fireEvent.click(firstTagCloseButton!);
-
- await waitFor(() => {
- const storedModels = sessionStorage.getItem("selectedModels");
- const parsedModels = JSON.parse(storedModels!);
- expect(parsedModels).not.toContain("Model 1");
- expect(parsedModels).toContain("Model 2");
- expect(parsedModels.length).toBe(1);
- });
-
- await waitFor(() => {
- const remainingTags = container.querySelectorAll(".ant-tag");
- expect(remainingTags.length).toBe(1);
- });
- });
-
- it("should show the voice selector when the endpoint type is audio_speech", async () => {
- const { getByText, container } = render(
- <ChatUI
- accessToken="1234567890"
- token="1234567890"
- userRole="user"
- userID="1234567890"
- disabledPersonalKeyCreation={false}
- />,
- );
-
- // Wait for the component to render
await waitFor(() => {
- expect(getByText("Test Key")).toBeInTheDocument();
+ const model1Label = screen.getAllByText("Model 1");
+ expect(model1Label.length).toBeGreaterThan(0);
});
-
- // Find the endpoint selector by looking for the "Endpoint Type:" text and its associated Select
- const endpointTypeText = getByText("Endpoint Type");
- const selectContainer = endpointTypeText.parentElement;
- const selectElement = selectContainer?.querySelector(".ant-select-selector");
-
- expect(selectElement).toBeInTheDocument();
-
- // Click on the select to open the dropdown
- if (selectElement) {
- fireEvent.mouseDown(selectElement);
- }
-
- // Wait for the dropdown to appear and find the audio_speech option
- await waitFor(() => {
- const audioSpeechOption = screen.getByText("/v1/audio/speech");
- expect(audioSpeechOption).toBeInTheDocument();
- });
-
- // Click on the audio_speech option
- const audioSpeechOption = screen.getByText("/v1/audio/speech");
- fireEvent.click(audioSpeechOption);
-
- // Verify the voice selector appears
- await waitFor(() => {
- expect(getByText("Voice")).toBeInTheDocument();
- });
-
- // Verify the voice select component is present
- const voiceText = getByText("Voice");
- const voiceSelectContainer = voiceText.parentElement;
- const voiceSelectElement = voiceSelectContainer?.querySelector(".ant-select");
- expect(voiceSelectElement).toBeInTheDocument();
});
});
diff --git a/ui/litellm-dashboard/src/components/chat_ui/ChatUI.tsx b/ui/litellm-dashboard/src/components/chat_ui/ChatUI.tsx
index f0e8bfb1aff..809c7493eb8 100644
--- a/ui/litellm-dashboard/src/components/chat_ui/ChatUI.tsx
+++ b/ui/litellm-dashboard/src/components/chat_ui/ChatUI.tsx
@@ -1,7 +1,3 @@
-import { Card, Text, TextInput, Title, Button as TremorButton } from "@tremor/react";
-import React, { useEffect, useRef, useState } from "react";
-import ReactMarkdown from "react-markdown";
-import { v4 as uuidv4 } from "uuid";
import {
ApiOutlined,
ArrowUpOutlined,
@@ -21,9 +17,13 @@ import {
ToolOutlined,
UserOutlined,
} from "@ant-design/icons";
-import { Button, Input, Modal, Select, Spin, Tag, Tooltip, Typography, Upload } from "antd";
+import { Card, Text, TextInput, Title, Button as TremorButton } from "@tremor/react";
+import { Button, Input, Modal, Select, Spin, Tooltip, Typography, Upload } from "antd";
+import React, { useEffect, useRef, useState } from "react";
+import ReactMarkdown from "react-markdown";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import { coy } from "react-syntax-highlighter/dist/esm/styles/prism";
+import { v4 as uuidv4 } from "uuid";
import GuardrailSelector from "../guardrails/GuardrailSelector";
import NotificationsManager from "../molecules/notifications_manager";
import TagSelector from "../tag_management/TagSelector";
@@ -106,17 +106,10 @@ const ChatUI: React.FC<ChatUIProps> = ({ accessToken, token, userRole, userID, d
return [];
}
});
- const [selectedModels, setSelectedModels] = useState<string[]>(() => {
- const saved = sessionStorage.getItem("selectedModels");
- try {
- return saved ? JSON.parse(saved) : [];
- } catch (error) {
- console.error("Error parsing selectedModels from sessionStorage", error);
- return [];
- }
- });
+ const [selectedModel, setSelectedModel] = useState<string | undefined>(
+ () => sessionStorage.getItem("selectedModel") || undefined,
+ );
const [showCustomModelInput, setShowCustomModelInput] = useState<boolean>(false);
- const [customModelInput, setCustomModelInput] = useState<string>("");
const [modelInfo, setModelInfo] = useState<ModelGroup[]>([]);
const customModelTimeout = useRef<NodeJS.Timeout | null>(null);
const [endpointType, setEndpointType] = useState<string>(
@@ -220,7 +213,7 @@ const ChatUI: React.FC<ChatUIProps> = ({ accessToken, token, userRole, userID, d
selectedGuardrails,
selectedMCPTools,
endpointType,
- selectedModel: selectedModels[0], // Use first model for code snippet
+ selectedModel,
selectedSdk,
selectedVoice,
});
@@ -239,7 +232,7 @@ const ChatUI: React.FC<ChatUIProps> = ({ accessToken, token, userRole, userID, d
selectedGuardrails,
selectedMCPTools,
endpointType,
- selectedModels,
+ selectedModel,
]);
useEffect(() => {
@@ -262,7 +255,11 @@ const ChatUI: React.FC<ChatUIProps> = ({ accessToken, token, userRole, userID, d
sessionStorage.setItem("selectedMCPTools", JSON.stringify(selectedMCPTools));
sessionStorage.setItem("selectedVoice", selectedVoice);
- sessionStorage.setItem("selectedModels", JSON.stringify(selectedModels));
+ if (selectedModel) {
+ sessionStorage.setItem("selectedModel", selectedModel);
+ } else {
+ sessionStorage.removeItem("selectedModel");
+ }
if (messageTraceId) {
sessionStorage.setItem("messageTraceId", messageTraceId);
} else {
@@ -277,7 +274,7 @@ const ChatUI: React.FC<ChatUIProps> = ({ accessToken, token, userRole, userID, d
}, [
apiKeySource,
apiKey,
- selectedModels,
+ selectedModel,
endpointType,
selectedTags,
selectedVectorStores,
@@ -286,6 +283,7 @@ const ChatUI: React.FC<ChatUIProps> = ({ accessToken, token, userRole, userID, d
responsesSessionId,
useApiSessionManagement,
selectedMCPTools,
+ selectedVoice,
]);
useEffect(() => {
@@ -309,11 +307,11 @@ const ChatUI: React.FC<ChatUIProps> = ({ accessToken, token, userRole, userID, d
setModelInfo(uniqueModels);
// check for selection overlap or empty model list
+ const hasSelection = uniqueModels.some((m) => m.model_group === selectedModel);
if (!uniqueModels.length) {
- setSelectedModels([]);
- } else if (selectedModels.length === 0) {
- // If no models selected, auto-select the first one
- setSelectedModels([uniqueModels[0].model_group]);
+ setSelectedModel(undefined);
+ } else if (!hasSelection) {
+ setSelectedModel(uniqueModels[0].model_group);
}
} catch (error) {
console.error("Error fetching model info:", error);
@@ -726,8 +724,7 @@ const ChatUI: React.FC<ChatUIProps> = ({ accessToken, token, userRole, userID, d
setIsLoading(true);
try {
- if (selectedModels.length > 0) {
- const selectedModel = selectedModels[0]; // For now, use first model (will be updated later for multi-model)
+ if (selectedModel) {
if (endpointType === EndpointType.CHAT) {
// Create chat history for API call - strip out model field and isImage field
// For chat completions, we preserve the multimodal content structure
@@ -935,43 +932,11 @@ const ChatUI: React.FC<ChatUIProps> = ({ accessToken, token, userRole, userID, d
);
}
- const onModelsChange = (values: string[]) => {
- console.log(`selected models:`, values);
+ const onModelChange = (value: string) => {
+ console.log(`selected ${value}`);
+ setSelectedModel(value);
- // Check if "custom" was added
- if (values.includes("custom")) {
- setShowCustomModelInput(true);
- // Remove "custom" from the actual selection
- setSelectedModels(values.filter((v) => v !== "custom"));
- } else {
- // Limit to 3 models maximum
- if (values.length > 3) {
- NotificationsManager.info("Maximum 3 models can be selected");
- return;
- }
- setSelectedModels(values);
- }
- };
-
- const handleAddCustomModel = () => {
- const trimmedModel = customModelInput.trim();
- if (!trimmedModel) return;
-
- if (selectedModels.includes(trimmedModel)) {
- NotificationsManager.info("Model already selected");
- return;
- }
- if (selectedModels.length >= 3) {
- NotificationsManager.info("Maximum 3 models can be selected");
- return;
- }
- setSelectedModels([...selectedModels, trimmedModel]);
- setCustomModelInput("");
- setShowCustomModelInput(false);
- };
-
- const handleRemoveModel = (modelToRemove: string) => {
- setSelectedModels(selectedModels.filter((m) => m !== modelToRemove));
+ setShowCustomModelInput(value === "custom");
};
const antIcon = <LoadingOutlined style={{ fontSize: 24 }} spin />;
@@ -1015,65 +980,40 @@ const ChatUI: React.FC<ChatUIProps> = ({ accessToken, token, userRole, userID, d
<div>
<Text className="font-medium block mb-2 text-gray-700 flex items-center">
- <RobotOutlined className="mr-2" /> Select Models
+ <RobotOutlined className="mr-2" /> Select Model
</Text>
<Select
- mode="multiple"
- value={selectedModels}
- placeholder="Select one or more models"
- onChange={onModelsChange}
+ value={selectedModel}
+ placeholder="Select a Model"
+ onChange={onModelChange}
options={[
...Array.from(new Set(modelInfo.map((option) => option.model_group))).map((model_group, index) => ({
value: model_group,
label: model_group,
key: index,
})),
- { value: "custom", label: "+ Add custom model", key: "custom" },
+ { value: "custom", label: "Enter custom model", key: "custom" },
]}
style={{ width: "100%" }}
showSearch={true}
className="rounded-md"
- maxTagCount={0}
- maxTagPlaceholder={`${selectedModels.length} model${selectedModels.length !== 1 ? "s" : ""} selected`}
/>
-
{showCustomModelInput && (
<TextInput
className="mt-2"
- placeholder="Custom Model Name (Enter to add)"
- value={customModelInput}
- onValueChange={setCustomModelInput}
- onKeyDown={(e) => {
- if (e.key === "Enter") {
- handleAddCustomModel();
+ placeholder="Enter custom model name"
+ onValueChange={(value) => {
+ // Using setTimeout to create a simple debounce effect
+ if (customModelTimeout.current) {
+ clearTimeout(customModelTimeout.current);
}
+
+ customModelTimeout.current = setTimeout(() => {
+ setSelectedModel(value);
+ }, 500); // 500ms delay after typing stops
}}
/>
)}
-
- {/* Selected Models Tags */}
- {selectedModels.length > 0 && (
- <div className="mt-2 overflow-hidden">
- <div className="flex flex-wrap gap-1.5">
- {selectedModels.map((model) => (
- <Tag
- key={model}
- closable
- onClose={(e) => {
- e.preventDefault();
- handleRemoveModel(model);
- }}
- color="blue"
- className="px-2 py-0.5 text-xs max-w-[200px]"
- >
- <span className="truncate inline-block max-w-[160px] align-middle" title={model}>
- {model}
- </span>
- </Tag>
- ))}
- </div>
- </div>
- )}
</div>
<div>
@@ -1225,8 +1165,8 @@ const ChatUI: React.FC<ChatUIProps> = ({ accessToken, token, userRole, userID, d
{/* Main Chat Area */}
<div className="w-3/4 flex flex-col bg-white">
- <div className="p-4 border-b border-gray-200 flex items-center justify-between">
- <Title className="text-xl font-semibold">Test Key</Title>
+ <div className="p-4 border-b border-gray-200 flex justify-between items-center">
+ <Title className="text-xl font-semibold mb-0">Test Key</Title>
<div className="flex gap-2">
<TremorButton
onClick={clearChatHistory}
diff --git a/ui/litellm-dashboard/src/components/guardrails/content_filter/ContentFilterManager.tsx b/ui/litellm-dashboard/src/components/guardrails/content_filter/ContentFilterManager.tsx
index f81aa478b93..3fac7e11393 100644
--- a/ui/litellm-dashboard/src/components/guardrails/content_filter/ContentFilterManager.tsx
+++ b/ui/litellm-dashboard/src/components/guardrails/content_filter/ContentFilterManager.tsx
@@ -114,13 +114,7 @@ const ContentFilterManager: React.FC<ContentFilterManagerProps> = ({
// Read-only display mode
if (!isEditing) {
- return (
- <ContentFilterDisplay
- patterns={selectedPatterns}
- blockedWords={blockedWords}
- readOnly={true}
- />
- );
+ return <ContentFilterDisplay patterns={selectedPatterns} blockedWords={blockedWords} readOnly={true} />;
}
// Edit mode
@@ -130,7 +124,8 @@ const ContentFilterManager: React.FC<ContentFilterManagerProps> = ({
{hasUnsavedChanges && (
<div className="mb-4 px-4 py-3 bg-yellow-50 border border-yellow-200 rounded-md">
<p className="text-sm text-yellow-800 font-medium">
- ⚠️ You have unsaved changes to patterns or keywords. Remember to click "Save Changes" at the bottom.
+ ⚠️ You have unsaved changes to patterns or keywords. Remember to click &quot;Save Changes&quot; at the
+ bottom.
</p>
</div>
)}
@@ -165,10 +160,7 @@ const ContentFilterManager: React.FC<ContentFilterManagerProps> = ({
export default ContentFilterManager;
// Helper function to format data for API
-export const formatContentFilterDataForAPI = (
- patterns: Pattern[],
- blockedWords: BlockedWord[]
-) => {
+export const formatContentFilterDataForAPI = (patterns: Pattern[], blockedWords: BlockedWord[]) => {
return {
patterns: patterns.map((p) => ({
pattern_type: p.type === "prebuilt" ? "prebuilt" : "regex",
@@ -184,4 +176,3 @@ export const formatContentFilterDataForAPI = (
})),
};
};
-
diff --git a/ui/litellm-dashboard/src/components/guardrails/guardrail_info.tsx b/ui/litellm-dashboard/src/components/guardrails/guardrail_info.tsx
index a92343e8456..fa34cf55636 100644
--- a/ui/litellm-dashboard/src/components/guardrails/guardrail_info.tsx
+++ b/ui/litellm-dashboard/src/components/guardrails/guardrail_info.tsx
@@ -21,7 +21,7 @@ import {
getGuardrailUISettings,
getGuardrailProviderSpecificParams,
} from "@/components/networking";
-import { getGuardrailLogoAndName, guardrail_provider_map, shouldRenderContentFilterConfigSettings } from "./guardrail_info_helpers";
+import { getGuardrailLogoAndName, guardrail_provider_map } from "./guardrail_info_helpers";
import PiiConfiguration from "./pii_configuration";
import GuardrailProviderFields from "./guardrail_provider_fields";
import GuardrailOptionalParams from "./guardrail_optional_params";
@@ -83,7 +83,7 @@ const GuardrailInfoView: React.FC<GuardrailInfoProps> = ({ guardrailId, onClose,
} | null>(null);
const [copiedStates, setCopiedStates] = useState<Record<string, boolean>>({});
const [hasUnsavedContentFilterChanges, setHasUnsavedContentFilterChanges] = useState(false);
-
+
// Content Filter data ref (managed by ContentFilterManager)
const contentFilterDataRef = React.useRef<{ patterns: any[]; blockedWords: any[] }>({
patterns: [],
@@ -240,10 +240,10 @@ const GuardrailInfoView: React.FC<GuardrailInfoProps> = ({ guardrailId, onClose,
if (guardrailData.litellm_params?.guardrail === "litellm_content_filter") {
const originalPatterns = guardrailData.litellm_params?.patterns || [];
const originalBlockedWords = guardrailData.litellm_params?.blocked_words || [];
-
+
const formattedData = formatContentFilterDataForAPI(
contentFilterDataRef.current.patterns,
- contentFilterDataRef.current.blockedWords
+ contentFilterDataRef.current.blockedWords,
);
if (JSON.stringify(originalPatterns) !== JSON.stringify(formattedData.patterns)) {
@@ -615,10 +615,14 @@ const GuardrailInfoView: React.FC<GuardrailInfoProps> = ({ guardrailId, onClose,
</Form.Item>
<div className="flex justify-end gap-2 mt-6">
- <Button onClick={() => {
- setIsEditing(false);
- setHasUnsavedContentFilterChanges(false);
- }}>Cancel</Button>
+ <Button
+ onClick={() => {
+ setIsEditing(false);
+ setHasUnsavedContentFilterChanges(false);
+ }}
+ >
+ Cancel
+ </Button>
<TremorButton>Save Changes</TremorButton>
</div>
</Form>
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx b/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx
index 231f29d4096..4ec60ed276a 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx
@@ -25,11 +25,7 @@ interface CreateMCPServerProps {
availableAccessGroups: string[];
}
-const AUTH_TYPES_REQUIRING_AUTH_VALUE = [
- AUTH_TYPE.API_KEY,
- AUTH_TYPE.BEARER_TOKEN,
- AUTH_TYPE.BASIC,
-];
+const AUTH_TYPES_REQUIRING_AUTH_VALUE = [AUTH_TYPE.API_KEY, AUTH_TYPE.BEARER_TOKEN, AUTH_TYPE.BASIC];
const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
userRole,
@@ -50,9 +46,7 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
const [searchValue, setSearchValue] = useState<string>("");
const [urlWarning, setUrlWarning] = useState<string>("");
const authType = formValues.auth_type as string | undefined;
- const shouldShowAuthValueField = authType
- ? AUTH_TYPES_REQUIRING_AUTH_VALUE.includes(authType)
- : false;
+ const shouldShowAuthValueField = authType ? AUTH_TYPES_REQUIRING_AUTH_VALUE.includes(authType) : false;
// Function to check URL format based on transport type
const checkUrlFormat = (url: string, transport: string) => {
@@ -92,7 +86,7 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
acc[header] = entry?.value ?? "";
return acc;
}, {})
- : {} as Record<string, string>;
+ : ({} as Record<string, string>);
const credentialsPayload =
credentialValues && typeof credentialValues === "object"
@@ -154,7 +148,7 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
}
// Prepare the payload with cost configuration and allowed tools
- const payload = {
+ const payload: Record<string, any> = {
...restValues,
...stdioFields,
// Remove the raw stdio_config field as we've extracted its components
@@ -171,14 +165,9 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
};
payload.static_headers = staticHeaders;
- const includeCredentials =
- restValues.auth_type && AUTH_TYPES_REQUIRING_AUTH_VALUE.includes(restValues.auth_type);
-
- if (
- includeCredentials &&
- credentialsPayload &&
- Object.keys(credentialsPayload).length > 0
- ) {
+ const includeCredentials = restValues.auth_type && AUTH_TYPES_REQUIRING_AUTH_VALUE.includes(restValues.auth_type);
+
+ if (includeCredentials && credentialsPayload && Object.keys(credentialsPayload).length > 0) {
payload.credentials = credentialsPayload;
}
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx b/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx
index bbfe0d1332d..109ab809225 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx
@@ -18,11 +18,7 @@ interface MCPServerEditProps {
availableAccessGroups: string[];
}
-const AUTH_TYPES_REQUIRING_AUTH_VALUE = [
- AUTH_TYPE.API_KEY,
- AUTH_TYPE.BEARER_TOKEN,
- AUTH_TYPE.BASIC,
-];
+const AUTH_TYPES_REQUIRING_AUTH_VALUE = [AUTH_TYPE.API_KEY, AUTH_TYPE.BEARER_TOKEN, AUTH_TYPE.BASIC];
const MCPServerEdit: React.FC<MCPServerEditProps> = ({
mcpServer,
@@ -39,9 +35,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
const [aliasManuallyEdited, setAliasManuallyEdited] = useState(false);
const [allowedTools, setAllowedTools] = useState<string[]>([]);
const authType = Form.useWatch("auth_type", form) as string | undefined;
- const shouldShowAuthValueField = authType
- ? AUTH_TYPES_REQUIRING_AUTH_VALUE.includes(authType)
- : false;
+ const shouldShowAuthValueField = authType ? AUTH_TYPES_REQUIRING_AUTH_VALUE.includes(authType) : false;
const initialStaticHeaders = React.useMemo(() => {
if (!mcpServer.static_headers) {
@@ -159,11 +153,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
if (!accessToken) return;
try {
// Ensure access groups is always a string array
- const {
- static_headers: staticHeadersList,
- credentials: credentialValues,
- ...restValues
- } = values;
+ const { static_headers: staticHeadersList, credentials: credentialValues, ...restValues } = values;
const accessGroups = (restValues.mcp_access_groups || []).map((g: any) =>
typeof g === "string" ? g : g.name || String(g),
@@ -178,7 +168,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
acc[header] = entry?.value ?? "";
return acc;
}, {})
- : {} as Record<string, string>;
+ : ({} as Record<string, string>);
const credentialsPayload =
credentialValues && typeof credentialValues === "object"
@@ -201,7 +191,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
: undefined;
// Prepare the payload with cost configuration and permission fields
- const payload = {
+ const payload: Record<string, any> = {
...restValues,
server_id: mcpServer.server_id,
mcp_info: {
@@ -218,14 +208,9 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
static_headers: staticHeaders,
};
- const includeCredentials =
- restValues.auth_type && AUTH_TYPES_REQUIRING_AUTH_VALUE.includes(restValues.auth_type);
+ const includeCredentials = restValues.auth_type && AUTH_TYPES_REQUIRING_AUTH_VALUE.includes(restValues.auth_type);
- if (
- includeCredentials &&
- credentialsPayload &&
- Object.keys(credentialsPayload).length > 0
- ) {
+ if (includeCredentials && credentialsPayload && Object.keys(credentialsPayload).length > 0) {
payload.credentials = credentialsPayload;
}
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/mcp_tools.tsx b/ui/litellm-dashboard/src/components/mcp_tools/mcp_tools.tsx
index 25563f41125..7c24b1b377b 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/mcp_tools.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/mcp_tools.tsx
@@ -1,14 +1,11 @@
-import React, { useState, useEffect } from "react";
+import React, { useState } from "react";
import { useQuery, useMutation } from "@tanstack/react-query";
import { ToolTestPanel } from "./ToolTestPanel";
import { MCPTool, MCPToolsViewerProps, CallMCPToolResponse } from "./types";
import { listMCPTools, callMCPTool } from "../networking";
-import { Modal, Input, Form } from "antd";
-import { Button, Card, Title, Text } from "@tremor/react";
-import { RobotOutlined, SafetyOutlined, ToolOutlined } from "@ant-design/icons";
-
-import NotificationsManager from "../molecules/notifications_manager";
+import { Card, Title, Text } from "@tremor/react";
+import { RobotOutlined, ToolOutlined } from "@ant-design/icons";
const MCPToolsViewer = ({
serverId,
@@ -43,11 +40,7 @@ const MCPToolsViewer = ({
if (!accessToken) throw new Error("Access Token required");
try {
- const result = await callMCPTool(
- accessToken,
- args.tool.name,
- args.arguments,
- );
+ const result = await callMCPTool(accessToken, args.tool.name, args.arguments);
return result;
} catch (error) {
throw error;