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]

feat(ui): migrate ChatUI off Ant Design and Tremor

mubashir1osmanibb5d9a199ad6
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.test.tsx
index 3c94977f0dc..5407fa7e66c 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.test.tsx
@@ -1,10 +1,10 @@
-import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
import { beforeEach, describe, expect, it, vi } from "vitest";
import ChatUI from "./ChatUI";
import * as fetchModelsModule from "@/components/llm_calls/fetch_models";
import { makeOpenAIChatCompletionRequest } from "@/components/llm_calls/chat_completion";
-// Mock the fetchAvailableModels function
vi.mock("@/components/llm_calls/fetch_models", () => ({
fetchAvailableModels: vi.fn(),
}));
@@ -13,15 +13,18 @@ vi.mock("@/components/llm_calls/chat_completion", () => ({
makeOpenAIChatCompletionRequest: vi.fn().mockResolvedValue(undefined),
}));
-// Mock other networking functions that cause errors
vi.mock("@/components/networking", () => ({
- tagListCall: vi.fn().mockResolvedValue({ data: [] }),
+ tagListCall: vi.fn().mockResolvedValue({}),
vectorStoreListCall: vi.fn().mockResolvedValue({ data: [] }),
getGuardrailsList: vi.fn().mockResolvedValue({ data: [] }),
+ getPoliciesList: vi.fn().mockResolvedValue({ data: [] }),
modelHubCall: vi.fn().mockResolvedValue({ data: [] }),
+ fetchMCPServers: vi.fn().mockResolvedValue([]),
+ fetchMCPToolsets: vi.fn().mockResolvedValue([]),
+ listMCPTools: vi.fn().mockResolvedValue({ tools: [] }),
+ callMCPTool: vi.fn(),
}));
-// Mock scrollIntoView which is not available in jsdom
beforeEach(() => {
Element.prototype.scrollIntoView = () => {};
});
@@ -29,17 +32,27 @@ beforeEach(() => {
const CHAT_REQUEST_ARG_COUNT = 26;
const STREAMING_ENABLED_ARG_INDEX = 25;
+async function openComboboxByPlaceholder(placeholder: string) {
+ const user = userEvent.setup();
+ const combobox = screen.getByPlaceholderText(placeholder);
+ await user.click(combobox);
+ return combobox;
+}
+
+async function selectComboboxOption(placeholder: string, optionLabel: string) {
+ const user = userEvent.setup();
+ await openComboboxByPlaceholder(placeholder);
+ const option = await screen.findByText(optionLabel);
+ await user.click(option);
+}
+
describe("ChatUI", () => {
beforeEach(() => {
- // Reset mocks before each test
vi.clearAllMocks();
sessionStorage.clear();
-
- // Mock scrollIntoView which is not available in JSDOM
Element.prototype.scrollIntoView = vi.fn();
- // Mock the fetchAvailableModels to return test models
- (fetchModelsModule.fetchAvailableModels as any).mockResolvedValue([
+ (fetchModelsModule.fetchAvailableModels as ReturnType<typeof vi.fn>).mockResolvedValue([
{ model_group: "Model 1", mode: "chat" },
{ model_group: "Model 2", mode: "chat" },
{ model_group: "Model 3", mode: "chat" },
@@ -47,7 +60,7 @@ describe("ChatUI", () => {
});
it("should render the chat UI", async () => {
- const { getByText } = render(
+ render(
<ChatUI
accessToken="1234567890"
token="1234567890"
@@ -56,11 +69,11 @@ describe("ChatUI", () => {
disabledPersonalKeyCreation={false}
/>,
);
- expect(getByText("Test Key")).toBeInTheDocument();
+ expect(screen.getByText("Test Key")).toBeInTheDocument();
});
it("should show the voice selector when the endpoint type is audio_speech", async () => {
- const { getByText } = render(
+ render(
<ChatUI
accessToken="1234567890"
token="1234567890"
@@ -70,47 +83,20 @@ describe("ChatUI", () => {
/>,
);
- // Wait for the component to render
- await waitFor(() => {
- expect(getByText("Test Key")).toBeInTheDocument();
- });
-
- // 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();
+ expect(screen.getByText("Test Key")).toBeInTheDocument();
});
- // Click on the audio_speech option
- const audioSpeechOption = screen.getByText("/v1/audio/speech");
- fireEvent.click(audioSpeechOption);
+ await selectComboboxOption("Select an endpoint", "/v1/audio/speech");
- // Verify the voice selector appears
await waitFor(() => {
- expect(getByText("Voice")).toBeInTheDocument();
+ expect(screen.getByText("Voice")).toBeInTheDocument();
+ expect(screen.getByLabelText("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();
});
it("should allow the user to select a model", async () => {
- const { getByText } = render(
+ render(
<ChatUI
accessToken="1234567890"
token="1234567890"
@@ -120,35 +106,26 @@ describe("ChatUI", () => {
/>,
);
- // Wait for the component to render
await waitFor(() => {
- expect(getByText("Test Key")).toBeInTheDocument();
+ expect(screen.getByText("Test Key")).toBeInTheDocument();
});
- // Open the "Select Model" dropdown (AntD renders options in a portal)
- const selectModelLabel = getByText("Select Model");
- // The Select component is a sibling of the Text component, so we need to find it in the parent container
- const modelSelectContainer = selectModelLabel.closest("div");
- const modelSelect = modelSelectContainer?.querySelector(".ant-select-selector");
- expect(modelSelect).toBeTruthy();
-
- fireEvent.mouseDown(modelSelect!);
+ await openComboboxByPlaceholder("Select a Model");
await waitFor(() => {
- const model1Label = screen.getAllByText("Model 1");
- expect(model1Label.length).toBeGreaterThan(0);
+ expect(screen.getAllByText("Model 1").length).toBeGreaterThan(0);
});
});
- it("shows only chat-compatible models when chat endpoint is selected", async () => {
- (fetchModelsModule.fetchAvailableModels as any).mockResolvedValueOnce([
+ it("shows all models returned for the active key regardless of endpoint", async () => {
+ (fetchModelsModule.fetchAvailableModels as ReturnType<typeof vi.fn>).mockResolvedValueOnce([
{ model_group: "ChatModel", mode: "chat" },
{ model_group: "SpeechModel", mode: "audio_speech" },
{ model_group: "ImageModel", mode: "image_generation" },
{ model_group: "ResponsesModel", mode: "responses" },
]);
- const { getByText } = render(
+ render(
<ChatUI
accessToken="1234567890"
token="1234567890"
@@ -159,43 +136,22 @@ describe("ChatUI", () => {
);
await waitFor(() => {
- expect(getByText("Test Key")).toBeInTheDocument();
- });
-
- // Open endpoint selector and explicitly select /v1/chat/completions
- const endpointTypeText = getByText("Endpoint Type");
- const endpointSelect = endpointTypeText.parentElement?.querySelector(".ant-select-selector");
- expect(endpointSelect).toBeTruthy();
- act(() => {
- fireEvent.mouseDown(endpointSelect!);
- fireEvent.click(screen.getByText("/v1/chat/completions"));
+ expect(screen.getByText("Test Key")).toBeInTheDocument();
});
- // Open model selector
- const selectModelLabel = getByText("Select Model");
- // The Select component is a sibling of the Text component, so we need to find it in the parent container
- const modelSelectContainer = selectModelLabel.closest("div");
- const modelSelect = modelSelectContainer?.querySelector(".ant-select-selector");
- expect(modelSelect).toBeTruthy();
- act(() => {
- fireEvent.mouseDown(modelSelect!);
- });
+ await selectComboboxOption("Select an endpoint", "/v1/chat/completions");
+ await openComboboxByPlaceholder("Select a Model");
await waitFor(() => {
- // Chat-compatible: ChatModel should be visible
expect(screen.getAllByText("ChatModel").length).toBeGreaterThan(0);
- expect(screen.queryByText("SpeechModel")).toBeNull();
- expect(screen.queryByText("ImageModel")).toBeNull();
- expect(screen.queryByText("ResponsesModel")).toBeNull();
+ expect(screen.getAllByText("SpeechModel").length).toBeGreaterThan(0);
+ expect(screen.getAllByText("ImageModel").length).toBeGreaterThan(0);
+ expect(screen.getAllByText("ResponsesModel").length).toBeGreaterThan(0);
});
});
- /**
- * Tests that the 'Enter custom model' option is available in the model selector dropdown.
- * This ensures users can manually enter a model name if it's not in the list.
- */
it("should show 'Enter custom model' option in model selector", async () => {
- const { getByText } = render(
+ render(
<ChatUI
accessToken="1234567890"
token="1234567890"
@@ -205,24 +161,14 @@ describe("ChatUI", () => {
/>,
);
- // Wait for the component to render
await waitFor(() => {
- expect(getByText("Test Key")).toBeInTheDocument();
+ expect(screen.getByText("Test Key")).toBeInTheDocument();
});
- // Open the "Select Model" dropdown
- const selectModelLabel = getByText("Select Model");
- const modelSelectContainer = selectModelLabel.closest("div");
- const modelSelect = modelSelectContainer?.querySelector(".ant-select-selector");
-
- fireEvent.mouseDown(modelSelect!);
+ await openComboboxByPlaceholder("Select a Model");
await waitFor(() => {
- // Get all options in the dropdown (Ant Design renders these in a portal)
- const options = document.querySelectorAll(".ant-select-item-option-content");
- expect(options.length).toBeGreaterThan(0);
- // Check if the first option is 'Enter custom model'
- expect(options[0]).toHaveTextContent("Enter custom model");
+ expect(screen.getByText("Enter custom model")).toBeInTheDocument();
});
});
@@ -241,44 +187,23 @@ describe("ChatUI", () => {
expect(screen.getByText("Test Key")).toBeInTheDocument();
});
- const endpointTypeText = screen.getByText("Endpoint Type");
- const endpointSelect = endpointTypeText.parentElement?.querySelector(".ant-select-selector") as HTMLElement | null;
- expect(endpointSelect).not.toBeNull();
-
- const selectEndpointOption = async (label: string) => {
- act(() => {
- fireEvent.mouseDown(endpointSelect!);
- });
-
- await waitFor(() => {
- expect(screen.getByText(label)).toBeInTheDocument();
- });
+ const mcpInput = () => screen.getByLabelText("Select MCP servers");
- act(() => {
- fireEvent.click(screen.getByText(label));
- });
- };
-
- const getMcpSelect = () =>
- screen.getByText("MCP Servers").closest("div")?.querySelector(".ant-select") as HTMLElement | null;
-
- await selectEndpointOption("/v1/embeddings");
-
- const mcpSelect = getMcpSelect();
- expect(mcpSelect).not.toBeNull();
+ await selectComboboxOption("Select an endpoint", "/v1/embeddings");
await waitFor(() => {
- expect(mcpSelect).toHaveClass("ant-select-disabled");
+ expect(mcpInput()).toBeDisabled();
});
- await selectEndpointOption("/v1/chat/completions");
+ await selectComboboxOption("Select an endpoint", "/v1/chat/completions");
await waitFor(() => {
- expect(mcpSelect).not.toHaveClass("ant-select-disabled");
+ expect(mcpInput()).not.toBeDisabled();
});
});
it("should show Simulate failure to test fallbacks in Model Settings when chat endpoint is selected", async () => {
+ const user = userEvent.setup();
render(
<ChatUI
accessToken="1234567890"
@@ -293,35 +218,13 @@ describe("ChatUI", () => {
expect(screen.getByText("Test Key")).toBeInTheDocument();
});
- // Model Settings button only appears when a chat model is selected; select "Model 1" first
- const selectModelLabel = screen.getByText("Select Model");
- const modelSelectContainer = selectModelLabel.closest("div");
- const modelSelect = modelSelectContainer?.querySelector(".ant-select-selector");
- expect(modelSelect).toBeTruthy();
-
- await act(async () => {
- fireEvent.mouseDown(modelSelect!);
- });
-
- await waitFor(() => {
- expect(screen.getAllByText("Model 1").length).toBeGreaterThan(0);
- });
-
- // Ant Design Select options may not have role="option"; click the dropdown option by text
- const model1Options = screen.getAllByText("Model 1");
- await act(async () => {
- fireEvent.click(model1Options[model1Options.length - 1]);
- });
+ await selectComboboxOption("Select a Model", "Model 1");
await waitFor(() => {
- const modelSettingsButton = screen.getByTestId("model-settings-button");
- expect(modelSettingsButton).toBeInTheDocument();
+ expect(screen.getByTestId("model-settings-button")).toBeInTheDocument();
});
- const modelSettingsButton = screen.getByTestId("model-settings-button");
- await act(async () => {
- fireEvent.click(modelSettingsButton);
- });
+ await user.click(screen.getByTestId("model-settings-button"));
await waitFor(() => {
expect(screen.getByText("Model Settings")).toBeInTheDocument();
@@ -333,9 +236,7 @@ describe("ChatUI", () => {
});
expect(fallbacksCheckbox).not.toBeChecked();
- await act(async () => {
- fireEvent.click(fallbacksCheckbox);
- });
+ await user.click(fallbacksCheckbox);
await waitFor(() => {
expect(screen.getByRole("checkbox", { name: /Simulate failure to test fallbacks/i })).toBeChecked();
@@ -343,6 +244,7 @@ describe("ChatUI", () => {
});
it("should send the chat request non-streaming after Stream responses is unchecked", async () => {
+ const user = userEvent.setup();
render(
<ChatUI
accessToken="1234567890"
@@ -357,35 +259,18 @@ describe("ChatUI", () => {
expect(screen.getByText("Test Key")).toBeInTheDocument();
});
- const selectModelLabel = screen.getByText("Select Model");
- const modelSelect = selectModelLabel.closest("div")?.querySelector(".ant-select-selector");
- await act(async () => {
- fireEvent.mouseDown(modelSelect!);
- });
-
- await waitFor(() => {
- expect(screen.getAllByText("Model 1").length).toBeGreaterThan(0);
- });
-
- const model1Options = screen.getAllByText("Model 1");
- await act(async () => {
- fireEvent.click(model1Options[model1Options.length - 1]);
- });
+ await selectComboboxOption("Select a Model", "Model 1");
await waitFor(() => {
expect(screen.getByTestId("model-settings-button")).toBeInTheDocument();
});
- await act(async () => {
- fireEvent.click(screen.getByTestId("model-settings-button"));
- });
+ await user.click(screen.getByTestId("model-settings-button"));
const streamingCheckbox = await screen.findByRole("checkbox", { name: /Stream responses/i });
expect(streamingCheckbox).toBeChecked();
- await act(async () => {
- fireEvent.click(streamingCheckbox);
- });
+ await user.click(streamingCheckbox);
await waitFor(() => {
expect(screen.getByRole("checkbox", { name: /Stream responses/i })).not.toBeChecked();
@@ -446,7 +331,8 @@ describe("ChatUI", () => {
});
it("should offer the streaming toggle for a responses-only model without advanced params", async () => {
- (fetchModelsModule.fetchAvailableModels as any).mockResolvedValue([
+ const user = userEvent.setup();
+ (fetchModelsModule.fetchAvailableModels as ReturnType<typeof vi.fn>).mockResolvedValue([
{ model_group: "ResponsesModel", mode: "responses" },
]);
@@ -464,37 +350,14 @@ describe("ChatUI", () => {
expect(screen.getByText("Test Key")).toBeInTheDocument();
});
- const endpointTypeText = screen.getByText("Endpoint Type");
- const endpointSelect = endpointTypeText.parentElement?.querySelector(".ant-select-selector");
- await act(async () => {
- fireEvent.mouseDown(endpointSelect!);
- });
- await act(async () => {
- fireEvent.click(screen.getByText("/v1/responses"));
- });
-
- const selectModelLabel = screen.getByText("Select Model");
- const modelSelect = selectModelLabel.closest("div")?.querySelector(".ant-select-selector");
- await act(async () => {
- fireEvent.mouseDown(modelSelect!);
- });
-
- await waitFor(() => {
- expect(screen.getAllByText("ResponsesModel").length).toBeGreaterThan(0);
- });
-
- const modelOptions = screen.getAllByText("ResponsesModel");
- await act(async () => {
- fireEvent.click(modelOptions[modelOptions.length - 1]);
- });
+ await selectComboboxOption("Select an endpoint", "/v1/responses");
+ await selectComboboxOption("Select a Model", "ResponsesModel");
await waitFor(() => {
expect(screen.getByTestId("model-settings-button")).toBeInTheDocument();
});
- await act(async () => {
- fireEvent.click(screen.getByTestId("model-settings-button"));
- });
+ await user.click(screen.getByTestId("model-settings-button"));
expect(await screen.findByRole("checkbox", { name: /Stream responses/i })).toBeChecked();
expect(screen.queryByText("Temperature")).not.toBeInTheDocument();
@@ -543,6 +406,7 @@ describe("ChatUI", () => {
});
it("should enable search functionality for MCP server selector", async () => {
+ const user = userEvent.setup();
render(
<ChatUI
accessToken="1234567890"
@@ -557,27 +421,16 @@ describe("ChatUI", () => {
expect(screen.getByText("Test Key")).toBeInTheDocument();
});
- const mcpServersText = screen.queryByText("MCP Servers");
- expect(mcpServersText).toBeInTheDocument();
-
- if (mcpServersText) {
- const selectContainer = mcpServersText.parentElement?.nextElementSibling;
- const selectElement = selectContainer?.querySelector(".ant-select-selector");
- expect(selectElement).toBeInTheDocument();
+ expect(screen.getByText("MCP Servers")).toBeInTheDocument();
- if (selectElement) {
- fireEvent.mouseDown(selectElement);
+ const mcpInput = screen.getByLabelText("Select MCP servers");
+ expect(mcpInput).toBeInTheDocument();
+ expect(mcpInput).not.toBeDisabled();
- await waitFor(() => {
- const allServersOption = screen.queryByText("All MCP Servers");
- if (allServersOption) {
- expect(allServersOption).toBeInTheDocument();
- }
- });
+ await user.click(mcpInput);
- const searchInput = document.querySelector(".ant-select-selection-search-input");
- expect(searchInput).toBeInTheDocument();
- }
- }
+ await waitFor(() => {
+ expect(screen.getByText("All MCP Servers")).toBeInTheDocument();
+ });
});
});
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.tsx
index 5edcbe84aa8..ce6880fbb30 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/ChatUI.tsx
@@ -1,27 +1,25 @@
"use client";
import {
- ApiOutlined,
- ArrowUpOutlined,
- ClearOutlined,
- CodeOutlined,
- DatabaseOutlined,
- DeleteOutlined,
- InfoCircleOutlined,
- KeyOutlined,
- LinkOutlined,
- LoadingOutlined,
- PictureOutlined,
- RobotOutlined,
- SafetyOutlined,
- SettingOutlined,
- SoundOutlined,
- TagsOutlined,
- ToolOutlined,
-} from "@ant-design/icons";
-import { Card, Text, TextInput, Title, Button as TremorButton } from "@tremor/react";
-import { Button, Input, Modal, Popover, Select, Spin, Tooltip, Upload } from "antd";
-import React, { useEffect, useRef, useState } from "react";
+ ArrowUp,
+ Bot,
+ Code2,
+ Database,
+ Eraser,
+ Image as ImageIcon,
+ Info,
+ Key,
+ Link2,
+ Loader2,
+ Settings,
+ Shield,
+ Tags,
+ Trash2,
+ Volume2,
+ Wrench,
+ X,
+} from "lucide-react";
+import React, { useEffect, useMemo, useRef, useState } from "react";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import { coy } from "react-syntax-highlighter/dist/esm/styles/prism";
import { v4 as uuidv4 } from "uuid";
@@ -66,8 +64,15 @@ import { MessageType } from "@/components/chat_ui/types";
import { useCodeInterpreter } from "../../hooks/useCodeInterpreter";
import { useChatHistory } from "../../hooks/useChatHistory";
import { getSecureItem, setSecureItem } from "@/utils/secureStorage";
+import { MultiSelect, type MultiSelectOption } from "@/components/shared/MultiSelect";
import { SearchSelect } from "@/components/shared/SearchSelect";
+import { Button } from "@/components/ui/button";
+import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
+import { Input } from "@/components/ui/input";
+import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { Select as ShadcnSelect, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
+import { Textarea } from "@/components/ui/textarea";
+import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { useDebouncedCallback } from "@tanstack/react-pacer/debouncer";
import {
AUDIO_ACCEPT,
@@ -77,9 +82,6 @@ import {
validateImageEditFile,
} from "./uploadValidation";
-const { TextArea } = Input;
-const { Dragger } = Upload;
-
interface ChatUIProps {
accessToken: string | null;
token: string | null;
@@ -535,9 +537,8 @@ const ChatUI: React.FC<ChatUIProps> = ({
setImagePreviewUrls((prev) => [...prev, ...previews]);
};
- const handleImageUpload = (file: File): false => {
+ const handleImageUpload = (file: File): void => {
handleImageFiles([file]);
- return false;
};
const handleRemoveImage = (index: number) => {
@@ -592,14 +593,71 @@ const ChatUI: React.FC<ChatUIProps> = ({
setChatImagePreviewUrl(null);
};
- const handleAudioUpload = (file: File): false => {
+ const handleAudioUpload = (file: File): void => {
const result = validateAudioFile(file);
if (!result.ok) {
NotificationsManager.error(result.error);
- return false;
+ return;
}
setUploadedAudio(file);
- return false;
+ };
+
+ const mcpServerOptions = useMemo((): MultiSelectOption[] => {
+ const options: MultiSelectOption[] = [];
+ if (endpointType !== EndpointType.MCP) {
+ options.push({
+ value: "__all__",
+ label: "All MCP Servers",
+ description: "Use all available MCP servers",
+ });
+ }
+ for (const toolset of mcpToolsets) {
+ options.push({
+ value: `toolset:${toolset.toolset_id}`,
+ label: toolset.toolset_name,
+ description: toolset.description || `Toolset (${toolset.tools.length} tools)`,
+ });
+ }
+ for (const server of mcpServers) {
+ options.push({
+ value: server.server_id,
+ label: server.alias || server.server_name || server.server_id,
+ description: server.description,
+ });
+ }
+ return options;
+ }, [endpointType, mcpToolsets, mcpServers]);
+
+ const handleMcpServersChange = (value: string[]) => {
+ if (endpointType === EndpointType.MCP) {
+ const serverId = value[0];
+ setSelectedMCPServers(serverId ? [serverId] : []);
+ setSelectedMCPDirectTool(undefined);
+ if (serverId && !serverToolsMap[serverId]) {
+ loadServerTools(serverId);
+ }
+ return;
+ }
+
+ if (value.includes("__all__")) {
+ setSelectedMCPServers(["__all__"]);
+ setMCPServerToolRestrictions({});
+ return;
+ }
+
+ setSelectedMCPServers(value);
+ setMCPServerToolRestrictions((prev) => {
+ const updated = { ...prev };
+ Object.keys(updated).forEach((serverId) => {
+ if (!value.includes(serverId)) delete updated[serverId];
+ });
+ return updated;
+ });
+ value.forEach((serverId) => {
+ if (!serverToolsMap[serverId]) {
+ loadServerTools(serverId);
+ }
+ });
};
const handleRemoveAudio = () => {
@@ -1079,21 +1137,43 @@ const ChatUI: React.FC<ChatUIProps> = ({
modelEmptyText = "Enter a Virtual Key to load models";
}
- const antIcon = <LoadingOutlined style={{ fontSize: 24 }} spin />;
+ const inputPlaceholder =
+ endpointType === EndpointType.CHAT ||
+ endpointType === EndpointType.EMBEDDINGS ||
+ endpointType === EndpointType.RESPONSES ||
+ endpointType === EndpointType.ANTHROPIC_MESSAGES ||
+ endpointType === EndpointType.INTERACTIONS
+ ? "Type your message... (Shift+Enter for new line)"
+ : endpointType === EndpointType.A2A_AGENTS
+ ? "Send a message to the A2A agent..."
+ : endpointType === EndpointType.IMAGE_EDITS
+ ? "Describe how you want to edit the image..."
+ : endpointType === EndpointType.SPEECH
+ ? "Enter text to convert to speech..."
+ : endpointType === EndpointType.TRANSCRIPTION
+ ? "Optional: Add context or prompt for transcription..."
+ : "Describe the image you want to generate...";
+
+ const sendDisabled =
+ isLoading ||
+ (endpointType === EndpointType.MCP
+ ? !(selectedMCPServers.length === 1 && selectedMCPServers[0] !== "__all__" && selectedMCPDirectTool)
+ : endpointType === EndpointType.TRANSCRIPTION
+ ? !uploadedAudio
+ : !inputMessage.trim());
return (
<div className={`min-h-0 min-w-0 bg-white ${simplified ? "flex h-full w-full flex-col" : "h-full w-full p-3"}`}>
- <Card className="flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden rounded-xl shadow-md">
+ <div className="flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden rounded-xl bg-white shadow-md ring-1 ring-foreground/10">
<div className="flex h-full min-h-0 min-w-0 w-full flex-col lg:flex-row">
- {/* Left Sidebar with Controls - hidden in simplified mode */}
{!simplified && (
<div className="max-h-[42%] w-full shrink-0 overflow-y-auto border-b border-gray-200 bg-gray-50 p-4 lg:max-h-none lg:w-72 lg:border-r lg:border-b-0 xl:w-80">
- <Title className="text-xl font-semibold mb-6 mt-2">Configurations</Title>
+ <h2 className="mb-6 mt-2 text-xl font-semibold">Configurations</h2>
<div className="space-y-4">
<div>
- <Text className="font-medium block mb-2 text-gray-700 flex items-center">
- <KeyOutlined className="mr-2" /> Virtual Key Source
- </Text>
+ <label className="mb-2 flex items-center text-sm font-medium text-gray-700">
+ <Key className="mr-2 size-4" aria-hidden="true" /> Virtual Key Source
+ </label>
<ShadcnSelect
disabled={disabledPersonalKeyCreation}
value={apiKeySource}
@@ -1110,79 +1190,84 @@ const ChatUI: React.FC<ChatUIProps> = ({
</SelectContent>
</ShadcnSelect>
{apiKeySource === "custom" && (
- <TextInput
- className="mt-2"
- placeholder="Enter custom Virtual Key"
- type="password"
- onValueChange={setApiKey}
- value={apiKey}
- icon={KeyOutlined}
- />
+ <div className="relative mt-2">
+ <Key className="pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground" />
+ <Input
+ className="h-8 pl-8"
+ placeholder="Enter custom Virtual Key"
+ type="password"
+ onChange={(event) => setApiKey(event.target.value)}
+ value={apiKey}
+ />
+ </div>
)}
</div>
<div>
- <div className="flex items-center justify-between mb-2">
- <Text className="font-medium block text-gray-700 flex items-center">
- <SettingOutlined className="mr-2" /> Custom Proxy Base URL
- </Text>
+ <div className="mb-2 flex items-center justify-between">
+ <label className="flex items-center text-sm font-medium text-gray-700">
+ <Settings className="mr-2 size-4" aria-hidden="true" /> Custom Proxy Base URL
+ </label>
{proxySettings?.LITELLM_UI_API_DOC_BASE_URL && !customProxyBaseUrl && (
<Button
- type="link"
- size="small"
- icon={<LinkOutlined />}
+ type="button"
+ variant="link"
+ size="xs"
+ className="h-auto p-0 text-gray-500 hover:text-gray-700"
onClick={() => {
setCustomProxyBaseUrl(proxySettings.LITELLM_UI_API_DOC_BASE_URL || "");
sessionStorage.setItem("customProxyBaseUrl", proxySettings.LITELLM_UI_API_DOC_BASE_URL || "");
}}
- className="text-gray-500 hover:text-gray-700"
>
+ <Link2 className="size-3" />
Fill
</Button>
)}
{customProxyBaseUrl && (
<Button
- type="link"
- size="small"
- icon={<ClearOutlined />}
+ type="button"
+ variant="link"
+ size="xs"
+ className="h-auto p-0 text-gray-500 hover:text-gray-700"
onClick={() => {
setCustomProxyBaseUrl("");
sessionStorage.removeItem("customProxyBaseUrl");
}}
- className="text-gray-500 hover:text-gray-700"
>
+ <Eraser className="size-3" />
Clear
</Button>
)}
</div>
- <TextInput
- placeholder="Optional: Enter custom proxy URL (e.g., http://localhost:5000)"
- onValueChange={(value) => {
- setCustomProxyBaseUrl(value);
- sessionStorage.setItem("customProxyBaseUrl", value);
- }}
- value={customProxyBaseUrl}
- icon={ApiOutlined}
- />
+ <div className="relative">
+ <Wrench className="pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground" />
+ <Input
+ className="h-8 pl-8"
+ placeholder="Optional: Enter custom proxy URL (e.g., http://localhost:5000)"
+ value={customProxyBaseUrl}
+ onChange={(event) => {
+ setCustomProxyBaseUrl(event.target.value);
+ sessionStorage.setItem("customProxyBaseUrl", event.target.value);
+ }}
+ />
+ </div>
{customProxyBaseUrl && (
- <Text className="text-xs text-gray-500 mt-1">API calls will be sent to: {customProxyBaseUrl}</Text>
+ <p className="mt-1 text-xs text-gray-500">API calls will be sent to: {customProxyBaseUrl}</p>
)}
</div>
<div>
- <Text className="font-medium block mb-2 text-gray-700 flex items-center">
- <ApiOutlined className="mr-2" /> Endpoint Type
- </Text>
+ <label className="mb-2 flex items-center text-sm font-medium text-gray-700">
+ <Wrench className="mr-2 size-4" aria-hidden="true" /> Endpoint Type
+ </label>
<EndpointSelector
endpointType={endpointType}
onEndpointChange={(value) => {
setEndpointType(value);
- // Clear model/agent selection when switching endpoint type
setSelectedModel(undefined);
setSelectedAgent(undefined);
setShowCustomModelInput(false);
setSelectedMCPDirectTool(undefined);
- // For MCP direct mode, require single server (clear __all__ or multiple)
if (value === EndpointType.MCP) {
setSelectedMCPServers((prev) => (prev.length === 1 && prev[0] !== "__all__" ? prev : []));
}
@@ -1194,13 +1279,12 @@ const ChatUI: React.FC<ChatUIProps> = ({
className="mb-4"
/>
- {/* Voice Selector for Speech Endpoint */}
{endpointType === EndpointType.SPEECH && (
<div className="mb-4">
- <Text className="font-medium block mb-2 text-gray-700 flex items-center">
- <SoundOutlined className="mr-2" />
+ <label className="mb-2 flex items-center text-sm font-medium text-gray-700">
+ <Volume2 className="mr-2 size-4" aria-hidden="true" />
Voice
- </Text>
+ </label>
<ShadcnSelect
value={selectedVoice}
onValueChange={(value) => {
@@ -1222,7 +1306,6 @@ const ChatUI: React.FC<ChatUIProps> = ({
</div>
)}
- {/* Session Management Component */}
<SessionManagement
endpointType={endpointType}
responsesSessionId={responsesSessionId}
@@ -1231,16 +1314,30 @@ const ChatUI: React.FC<ChatUIProps> = ({
/>
</div>
- {/* Model Selector - shown when NOT using A2A Agents or MCP direct mode */}
{endpointType !== EndpointType.A2A_AGENTS && endpointType !== EndpointType.MCP && (
<div>
- <Text className="font-medium block mb-2 text-gray-700 flex items-center justify-between">
+ <div className="mb-2 flex items-center justify-between text-sm font-medium text-gray-700">
<span className="flex items-center">
- <RobotOutlined className="mr-2" /> Select Model
+ <Bot className="mr-2 size-4" aria-hidden="true" /> Select Model
</span>
{isChatModel() || supportsStreamingToggle ? (
- <Popover
- content={
+ <Popover>
+ <PopoverTrigger
+ render={
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-xs"
+ className="text-gray-500 hover:text-gray-700"
+ aria-label="Model Settings"
+ data-testid="model-settings-button"
+ />
+ }
+ >
+ <Settings className="size-3.5" />
+ </PopoverTrigger>
+ <PopoverContent side="right" className="w-auto p-0">
+ <div className="border-b border-border px-4 py-2 text-sm font-medium">Model Settings</div>
<AdditionalModelSettings
showAdvancedParams={isChatModel()}
temperature={temperature}
@@ -1254,32 +1351,30 @@ const ChatUI: React.FC<ChatUIProps> = ({
streamingEnabled={streamingEnabled}
onStreamingChange={supportsStreamingToggle ? setStreamingEnabled : undefined}
/>
- }
- title="Model Settings"
- trigger="click"
- placement="right"
- >
- <Button
- type="text"
- size="small"
- icon={<SettingOutlined />}
- className="text-gray-500 hover:text-gray-700"
- aria-label="Model Settings"
- data-testid="model-settings-button"
- />
+ </PopoverContent>
</Popover>
) : (
- <Tooltip title="Advanced parameters are only supported for chat models currently">
- <Button
- type="text"
- size="small"
- icon={<SettingOutlined />}
- className="text-gray-300 cursor-not-allowed"
- disabled
- />
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-xs"
+ className="cursor-not-allowed text-gray-300"
+ disabled
+ aria-label="Model Settings unavailable"
+ />
+ }
+ >
+ <Settings className="size-3.5" />
+ </TooltipTrigger>
+ <TooltipContent>
+ Advanced parameters are only supported for chat models currently
+ </TooltipContent>
</Tooltip>
)}
- </Text>
+ </div>
<SearchSelect
value={selectedModel}
placeholder={isLoadingModels ? "Loading models..." : "Select a Model"}
@@ -1296,21 +1391,20 @@ const ChatUI: React.FC<ChatUIProps> = ({
]}
/>
{showCustomModelInput && (
- <TextInput
- className="mt-2"
+ <Input
+ className="mt-2 h-8"
placeholder="Enter custom model name"
- onValueChange={debouncedSetSelectedModel}
+ onChange={(event) => debouncedSetSelectedModel(event.target.value)}
/>
)}
</div>
)}
- {/* Agent Selector - shown ONLY for A2A Agents endpoint */}
{endpointType === EndpointType.A2A_AGENTS && (
<div>
- <Text className="font-medium block mb-2 text-gray-700 flex items-center">
- <RobotOutlined className="mr-2" /> Select Agent
- </Text>
+ <label className="mb-2 flex items-center text-sm font-medium text-gray-700">
+ <Bot className="mr-2 size-4" aria-hidden="true" /> Select Agent
+ </label>
<SearchSelect
value={selectedAgent}
placeholder="Select an Agent"
@@ -1322,17 +1416,17 @@ const ChatUI: React.FC<ChatUIProps> = ({
}))}
/>
{agentInfo.length === 0 && (
- <Text className="text-xs text-gray-500 mt-2 block">
+ <p className="mt-2 text-xs text-gray-500">
No agents found. Create agents via /v1/agents endpoint.
- </Text>
+ </p>
)}
</div>
)}
<div>
- <Text className="font-medium block mb-2 text-gray-700 flex items-center">
- <TagsOutlined className="mr-2" /> Tags
- </Text>
+ <label className="mb-2 flex items-center text-sm font-medium text-gray-700">
+ <Tags className="mr-2 size-4" aria-hidden="true" /> Tags
+ </label>
<TagSelector
value={selectedTags}
onChange={setSelectedTags}
@@ -1341,165 +1435,57 @@ const ChatUI: React.FC<ChatUIProps> = ({
/>
</div>
- {/* MCP Server Selection */}
<div>
- <Text className="font-medium block mb-2 text-gray-700 flex items-center">
- <ToolOutlined className="mr-2" />
+ <div className="mb-2 flex items-center gap-1 text-sm font-medium text-gray-700">
+ <Wrench className="mr-1 size-4" aria-hidden="true" />
{endpointType === EndpointType.MCP ? "MCP Server" : "MCP Servers"}
- <Tooltip
- className="ml-1"
- title={
- endpointType === EndpointType.MCP
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <button
+ type="button"
+ className="inline-flex"
+ aria-label="About MCP servers and toolsets"
+ onClick={() => setIsToolsetsInfoModalVisible(true)}
+ />
+ }
+ >
+ <Info className="size-3.5 cursor-pointer text-gray-400" />
+ </TooltipTrigger>
+ <TooltipContent className="max-w-xs">
+ {endpointType === EndpointType.MCP
? "Select an MCP server or toolset to test tools directly."
- : "Select MCP servers or toolsets to use in your conversation."
- }
- >
- <InfoCircleOutlined
- className="cursor-pointer"
- onClick={() => setIsToolsetsInfoModalVisible(true)}
- />
+ : "Select MCP servers or toolsets to use in your conversation."}
+ </TooltipContent>
</Tooltip>
- </Text>
- <Select
- mode={endpointType === EndpointType.MCP ? undefined : "multiple"}
- style={{ width: "100%" }}
- placeholder={endpointType === EndpointType.MCP ? "Select MCP server" : "Select MCP servers"}
- value={
- endpointType === EndpointType.MCP
- ? selectedMCPServers[0] !== "__all__" && selectedMCPServers.length === 1
+ </div>
+ {endpointType === EndpointType.MCP ? (
+ <SearchSelect
+ value={
+ selectedMCPServers[0] !== "__all__" && selectedMCPServers.length === 1
? selectedMCPServers[0]
: undefined
- : selectedMCPServers
- }
- onChange={(value) => {
- if (endpointType === EndpointType.MCP) {
- const serverId = value as string | undefined;
- setSelectedMCPServers(serverId ? [serverId] : []);
- setSelectedMCPDirectTool(undefined);
- if (serverId && !serverToolsMap[serverId]) {
- loadServerTools(serverId);
- }
- } else {
- if ((value as string[]).includes("__all__")) {
- setSelectedMCPServers(["__all__"]);
- setMCPServerToolRestrictions({});
- } else {
- setSelectedMCPServers(value as string[]);
- setMCPServerToolRestrictions((prev) => {
- const updated = { ...prev };
- Object.keys(updated).forEach((serverId) => {
- if (!(value as string[]).includes(serverId)) delete updated[serverId];
- });
- return updated;
- });
- (value as string[]).forEach((serverId) => {
- if (!serverToolsMap[serverId]) {
- loadServerTools(serverId);
- }
- });
- }
- }
- }}
- loading={isLoadingMCPServers}
- className="mb-2"
- allowClear
- showSearch
- optionLabelProp="label"
- disabled={!MCP_SUPPORTED_ENDPOINTS.has(endpointType as EndpointType)}
- maxTagCount={endpointType === EndpointType.MCP ? 1 : "responsive"}
- filterOption={(input, option) => {
- if (option?.value === "__all__") {
- return "All MCP Servers".toLowerCase().includes(input.toLowerCase());
}
- const val = option?.value as string | undefined;
- if (val?.startsWith("toolset:")) {
- const toolsetId = val.slice("toolset:".length);
- const toolset = mcpToolsets.find((t) => t.toolset_id === toolsetId);
- if (!toolset) return false;
- return [toolset.toolset_name, toolset.description]
- .filter(Boolean)
- .join(" ")
- .toLowerCase()
- .includes(input.toLowerCase());
- }
- const server = mcpServers.find((s) => s.server_id === val);
- if (!server) return false;
- const searchText = [server.server_name, server.alias, server.server_id, server.description]
- .filter(Boolean)
- .join(" ")
- .toLowerCase();
- return searchText.includes(input.toLowerCase());
- }}
- >
- {/* All MCP Servers option - hidden for MCP direct mode */}
- {endpointType !== EndpointType.MCP && (
- <Select.Option key="__all__" value="__all__" label="All MCP Servers">
- <div className="flex flex-col py-1">
- <span className="font-medium">All MCP Servers</span>
- <span className="text-xs text-gray-500 mt-1">Use all available MCP servers</span>
- </div>
- </Select.Option>
- )}
-
- {/* Toolsets (purple badge) */}
- {mcpToolsets.length > 0 && (
- <Select.OptGroup label="Toolsets">
- {mcpToolsets.map((toolset) => (
- <Select.Option
- key={`toolset:${toolset.toolset_id}`}
- value={`toolset:${toolset.toolset_id}`}
- label={toolset.toolset_name}
- disabled={
- endpointType === EndpointType.MCP ? false : selectedMCPServers.includes("__all__")
- }
- >
- <div className="flex flex-col py-1">
- <div className="flex items-center gap-1">
- <span className="font-medium">{toolset.toolset_name}</span>
- <span
- className="text-xs px-1 rounded-sm"
- style={{ background: "#ede9fe", color: "#7c3aed" }}
- >
- Toolset
- </span>
- <span className="text-xs text-gray-500">({toolset.tools.length} tools)</span>
- </div>
- {toolset.description && (
- <span className="text-xs text-gray-500 mt-1">{toolset.description}</span>
- )}
- </div>
- </Select.Option>
- ))}
- </Select.OptGroup>
- )}
-
- {/* Individual servers */}
- {mcpServers.length > 0 && (
- <Select.OptGroup label="Servers">
- {mcpServers.map((server) => (
- <Select.Option
- key={server.server_id}
- value={server.server_id}
- label={server.alias || server.server_name || server.server_id}
- disabled={
- endpointType === EndpointType.MCP ? false : selectedMCPServers.includes("__all__")
- }
- >
- <div className="flex flex-col py-1">
- <span className="font-medium">
- {server.alias || server.server_name || server.server_id}
- </span>
- {server.description && (
- <span className="text-xs text-gray-500 mt-1">{server.description}</span>
- )}
- </div>
- </Select.Option>
- ))}
- </Select.OptGroup>
- )}
- </Select>
+ placeholder="Select MCP server"
+ emptyText={isLoadingMCPServers ? "Loading..." : "No MCP servers"}
+ disabled={!MCP_SUPPORTED_ENDPOINTS.has(endpointType as EndpointType) || isLoadingMCPServers}
+ onValueChange={(value) => handleMcpServersChange(value ? [value] : [])}
+ options={mcpServerOptions}
+ className="mb-2"
+ />
+ ) : (
+ <MultiSelect
+ value={selectedMCPServers}
+ onValueChange={handleMcpServersChange}
+ placeholder="Select MCP servers"
+ emptyText={isLoadingMCPServers ? "Loading..." : "No MCP servers"}
+ disabled={!MCP_SUPPORTED_ENDPOINTS.has(endpointType as EndpointType)}
+ loading={isLoadingMCPServers}
+ options={mcpServerOptions}
+ className="mb-2"
+ />
+ )}
- {/* MCP Tool selector - only for MCP direct mode */}
{endpointType === EndpointType.MCP &&
selectedMCPServers.length === 1 &&
selectedMCPServers[0] !== "__all__" &&
@@ -1517,28 +1503,25 @@ const ChatUI: React.FC<ChatUIProps> = ({
}));
}
} else {
- toolOptions = (serverToolsMap[rawSel] || []).map((tool: any) => ({
+ toolOptions = (serverToolsMap[rawSel] || []).map((tool: { name: string }) => ({
value: tool.name,
label: tool.name,
}));
}
return (
<div className="mt-3">
- <Text className="text-xs text-gray-600 mb-1 block">Select Tool</Text>
- <Select
- style={{ width: "100%" }}
- placeholder="Select a tool to call"
+ <p className="mb-1 block text-xs text-gray-600">Select Tool</p>
+ <SearchSelect
value={selectedMCPDirectTool}
- onChange={(value) => setSelectedMCPDirectTool(value)}
+ placeholder="Select a tool to call"
+ onValueChange={(value) => setSelectedMCPDirectTool(value || undefined)}
options={toolOptions}
- allowClear
className="rounded-md"
/>
</div>
);
})()}
- {/* Tool restrictions UI (optional) - hidden for MCP direct mode */}
{selectedMCPServers.length > 0 &&
!selectedMCPServers.includes("__all__") &&
endpointType !== EndpointType.MCP &&
@@ -1550,27 +1533,23 @@ const ChatUI: React.FC<ChatUIProps> = ({
if (tools.length === 0) return null;
return (
- <div key={serverId} className="border rounded-sm p-2">
- <Text className="text-xs text-gray-600 mb-1">
+ <div key={serverId} className="rounded-sm border p-2">
+ <p className="mb-1 text-xs text-gray-600">
Limit tools for {server?.alias || server?.server_name || serverId}:
- </Text>
- <Select
- mode="multiple"
- size="small"
- style={{ width: "100%" }}
- placeholder="All tools (default)"
+ </p>
+ <MultiSelect
value={mcpServerToolRestrictions[serverId] || []}
- onChange={(selectedTools) => {
+ onValueChange={(selectedTools) => {
setMCPServerToolRestrictions((prev) => ({
...prev,
[serverId]: selectedTools,
}));
}}
- options={tools.map((tool) => ({
+ placeholder="All tools (default)"
+ options={tools.map((tool: { name: string }) => ({
value: tool.name,
label: tool.name,
}))}
- maxTagCount={2}
/>
</div>
);
@@ -1578,7 +1557,6 @@ const ChatUI: React.FC<ChatUIProps> = ({
</div>
)}
- {/* BYOK credential status for selected servers */}
{selectedMCPServers.length > 0 &&
!selectedMCPServers.includes("__all__") &&
selectedMCPServers.some((serverId) => {
@@ -1593,28 +1571,31 @@ const ChatUI: React.FC<ChatUIProps> = ({
return (
<div
key={serverId}
- className="border border-blue-100 rounded-sm p-2 bg-blue-50 flex items-center justify-between"
+ className="flex items-center justify-between rounded-sm border border-blue-100 bg-blue-50 p-2"
>
- <Text className="text-xs text-blue-700">{serverName} requires your API key</Text>
+ <p className="text-xs text-blue-700">{serverName} requires your API key</p>
{server.has_user_credential ? (
<div className="flex items-center gap-2">
- <span className="text-green-600 text-xs font-medium flex items-center gap-1">
- <KeyOutlined /> Connected
+ <span className="flex items-center gap-1 text-xs font-medium text-green-600">
+ <Key className="size-3" /> Connected
</span>
<button
- className="text-xs text-gray-400 hover:text-blue-500 underline"
+ type="button"
+ className="text-xs text-gray-400 underline hover:text-blue-500"
onClick={() => setByokModalServer(server)}
>
Reconnect
</button>
</div>
) : (
- <button
- className="text-xs bg-blue-500 hover:bg-blue-600 text-white px-3 py-1 rounded-lg font-medium"
+ <Button
+ type="button"
+ size="xs"
+ className="rounded-lg bg-blue-500 px-3 py-1 text-xs font-medium text-white hover:bg-blue-600"
onClick={() => setByokModalServer(server)}
>
Connect
- </button>
+ </Button>
)}
</div>
);
@@ -1624,23 +1605,21 @@ const ChatUI: React.FC<ChatUIProps> = ({
</div>
<div>
- <Text className="font-medium block mb-2 text-gray-700 flex items-center">
- <DatabaseOutlined className="mr-2" /> Vector Store
- <Tooltip
- className="ml-1"
- title={
- <span>
- Select vector store(s) to use for this LLM API call. You can set up your vector store{" "}
- <a href="?page=vector-stores" style={{ color: "#1890ff" }}>
- here
- </a>
- .
- </span>
- }
- >
- <InfoCircleOutlined />
+ <div className="mb-2 flex items-center gap-1 text-sm font-medium text-gray-700">
+ <Database className="mr-1 size-4" aria-hidden="true" /> Vector Store
+ <Tooltip>
+ <TooltipTrigger aria-label="About vector stores">
+ <Info className="size-3.5 text-gray-400" />
+ </TooltipTrigger>
+ <TooltipContent className="max-w-xs">
+ Select vector store(s) to use for this LLM API call. You can set up your vector store{" "}
+ <a href="?page=vector-stores" className="text-blue-500 underline">
+ here
+ </a>
+ .
+ </TooltipContent>
</Tooltip>
- </Text>
+ </div>
<VectorStoreSelector
value={selectedVectorStores}
onChange={setSelectedVectorStores}
@@ -1650,23 +1629,21 @@ const ChatUI: React.FC<ChatUIProps> = ({
</div>
<div>
- <Text className="font-medium block mb-2 text-gray-700 flex items-center">
- <SafetyOutlined className="mr-2" /> Guardrails
- <Tooltip
- className="ml-1"
- title={
- <span>
- Select guardrail(s) to use for this LLM API call. You can set up your guardrails{" "}
- <a href="?page=guardrails" style={{ color: "#1890ff" }}>
- here
- </a>
- .
- </span>
- }
- >
- <InfoCircleOutlined />
+ <div className="mb-2 flex items-center gap-1 text-sm font-medium text-gray-700">
+ <Shield className="mr-1 size-4" aria-hidden="true" /> Guardrails
+ <Tooltip>
+ <TooltipTrigger aria-label="About guardrails">
+ <Info className="size-3.5 text-gray-400" />
+ </TooltipTrigger>
+ <TooltipContent className="max-w-xs">
+ Select guardrail(s) to use for this LLM API call. You can set up your guardrails{" "}
+ <a href="?page=guardrails" className="text-blue-500 underline">
+ here
+ </a>
+ .
+ </TooltipContent>
</Tooltip>
- </Text>
+ </div>
<GuardrailSelector
value={selectedGuardrails}
onChange={setSelectedGuardrails}
@@ -1676,24 +1653,22 @@ const ChatUI: React.FC<ChatUIProps> = ({
</div>
<div>
- <Text className="font-medium block mb-2 text-gray-700 flex items-center">
- <SafetyOutlined className="mr-2" /> Policies
- <Tooltip
- className="ml-1"
- title={
- <span>
- Select policy/policies to apply to this LLM API call. Policies define which guardrails are
- applied based on conditions. You can set up your policies{" "}
- <a href="?page=policies" style={{ color: "#1890ff" }}>
- here
- </a>
- .
- </span>
- }
- >
- <InfoCircleOutlined />
+ <div className="mb-2 flex items-center gap-1 text-sm font-medium text-gray-700">
+ <Shield className="mr-1 size-4" aria-hidden="true" /> Policies
+ <Tooltip>
+ <TooltipTrigger aria-label="About policies">
+ <Info className="size-3.5 text-gray-400" />
+ </TooltipTrigger>
+ <TooltipContent className="max-w-xs">
+ Select policy/policies to apply to this LLM API call. Policies define which guardrails are
+ applied based on conditions. You can set up your policies{" "}
+ <a href="?page=policies" className="text-blue-500 underline">
+ here
+ </a>
+ .
+ </TooltipContent>
</Tooltip>
- </Text>
+ </div>
<PolicySelector
value={selectedPolicies}
onChange={setSelectedPolicies}
@@ -1702,7 +1677,6 @@ const ChatUI: React.FC<ChatUIProps> = ({
/>
</div>
- {/* Code Interpreter Toggle - Only for Responses endpoint */}
{endpointType === EndpointType.RESPONSES && (
<div>
<CodeInterpreterTool
@@ -1719,7 +1693,6 @@ const ChatUI: React.FC<ChatUIProps> = ({
</div>
)}
- {/* Main Chat Area */}
<div className="flex min-h-0 min-w-0 flex-1 flex-col bg-white">
{endpointType === EndpointType.REALTIME ? (
<RealtimePlayground
@@ -1731,31 +1704,25 @@ const ChatUI: React.FC<ChatUIProps> = ({
) : (
<>
<div className="flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-gray-200 p-3 sm:p-4">
- <Title className="text-xl font-semibold mb-0">{simplified ? "Chat" : "Test Key"}</Title>
+ <h2 className="mb-0 text-xl font-semibold">{simplified ? "Chat" : "Test Key"}</h2>
<div className="flex flex-wrap justify-end gap-2">
- <TremorButton
- onClick={clearChatHistory}
- className="bg-gray-100 hover:bg-gray-200 text-gray-700 border-gray-300"
- icon={ClearOutlined}
- >
+ <Button type="button" variant="outline" size="sm" onClick={clearChatHistory}>
+ <Eraser className="size-3.5" />
Clear Chat
- </TremorButton>
+ </Button>
{!simplified && (
- <TremorButton
- onClick={() => setIsGetCodeModalVisible(true)}
- className="bg-gray-100 hover:bg-gray-200 text-gray-700 border-gray-300"
- icon={CodeOutlined}
- >
+ <Button type="button" variant="outline" size="sm" onClick={() => setIsGetCodeModalVisible(true)}>
+ <Code2 className="size-3.5" />
Get Code
- </TremorButton>
+ </Button>
)}
</div>
</div>
<div className="min-h-0 min-w-0 flex-1 overflow-auto p-3 pb-0 sm:p-4 sm:pb-0">
{chatHistory.length === 0 && (
- <div className="h-full flex flex-col items-center justify-center text-gray-400">
- <RobotOutlined style={{ fontSize: "48px", marginBottom: "16px" }} />
- <Text>Start a conversation, generate an image, or handle audio</Text>
+ <div className="flex h-full flex-col items-center justify-center text-gray-400">
+ <Bot className="mb-4 size-12" aria-hidden="true" />
+ <p className="text-sm">Start a conversation, generate an image, or handle audio</p>
</div>
)}
@@ -1772,29 +1739,26 @@ const ChatUI: React.FC<ChatUIProps> = ({
</div>
))}
- {/* Show MCP events during loading if no assistant message exists yet */}
{isLoading &&
mcpEvents.length > 0 &&
(endpointType === EndpointType.RESPONSES || endpointType === EndpointType.CHAT) &&
chatHistory.length > 0 &&
chatHistory[chatHistory.length - 1].role === "user" && (
- <div className="text-left mb-4">
+ <div className="mb-4 text-left">
<div
- className="inline-block max-w-[80%] rounded-lg shadow-xs p-3.5 px-4"
+ className="inline-block max-w-[80%] rounded-lg p-3.5 px-4 shadow-xs"
style={{
backgroundColor: "#ffffff",
border: "1px solid #f0f0f0",
textAlign: "left",
}}
>
- <div className="flex items-center gap-2 mb-1.5">
+ <div className="mb-1.5 flex items-center gap-2">
<div
- className="flex items-center justify-center w-6 h-6 rounded-full mr-1"
- style={{
- backgroundColor: "#f5f5f5",
- }}
+ className="mr-1 flex h-6 w-6 items-center justify-center rounded-full"
+ style={{ backgroundColor: "#f5f5f5" }}
>
- <RobotOutlined style={{ fontSize: "12px", color: "#4b5563" }} />
+ <Bot className="size-3 text-gray-600" aria-hidden="true" />
</div>
<strong className="text-sm capitalize">Assistant</strong>
</div>
@@ -1804,27 +1768,34 @@ const ChatUI: React.FC<ChatUIProps> = ({
)}
{isLoading && (
- <div className="flex justify-center items-center my-4">
- <Spin indicator={antIcon} />
+ <div className="my-4 flex items-center justify-center">
+ <Loader2 className="size-6 animate-spin text-gray-500" aria-label="Loading" />
</div>
)}
<div ref={chatEndRef} style={{ height: "1px" }} />
</div>
<div className="max-h-[50%] shrink-0 overflow-y-auto border-t border-gray-200 bg-white p-3 sm:p-4">
- {/* Image Upload Section for Image Edits */}
{endpointType === EndpointType.IMAGE_EDITS && (
<div className="mb-4">
{uploadedImages.length === 0 ? (
- <Dragger beforeUpload={handleImageUpload} accept={IMAGE_EDIT_ACCEPT} showUploadList={false}>
- <p className="ant-upload-drag-icon">
- <PictureOutlined style={{ fontSize: "24px", color: "#666" }} />
- </p>
- <p className="ant-upload-text text-sm">Click or drag images to upload</p>
- <p className="ant-upload-hint text-xs text-gray-500">
+ <label className="flex cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 px-4 py-8 text-center hover:border-gray-400">
+ <ImageIcon className="mb-2 size-6 text-gray-500" aria-hidden="true" />
+ <p className="text-sm">Click or drag images to upload</p>
+ <p className="text-xs text-gray-500">
Support for PNG, JPG, JPEG, GIF, WebP. Multiple images supported.
</p>
- </Dragger>
+ <input
+ type="file"
+ accept={IMAGE_EDIT_ACCEPT}
+ multiple
+ className="sr-only"
+ onChange={(event) => {
+ handleImageFiles(Array.from(event.target.files || []));
+ event.target.value = "";
+ }}
+ />
+ </label>
) : (
<div className="flex flex-wrap gap-2">
{uploadedImages.map((file, index) => (
@@ -1841,76 +1812,83 @@ const ChatUI: React.FC<ChatUIProps> = ({
}
})()}
alt={`Upload preview ${index + 1}`}
- className="max-w-32 max-h-32 rounded-md border border-gray-200 object-cover"
+ className="max-h-32 max-w-32 rounded-md border border-gray-200 object-cover"
/>
- <button
- className="absolute top-1 right-1 bg-white shadow-xs border border-gray-200 rounded-sm px-1 py-1 text-red-500 hover:bg-red-50 text-xs"
+ <Button
+ type="button"
+ variant="outline"
+ size="icon-xs"
+ className="absolute top-1 right-1 bg-white text-red-500 hover:bg-red-50"
+ aria-label={`Remove ${file.name}`}
onClick={() => handleRemoveImage(index)}
>
- <DeleteOutlined />
- </button>
+ <X className="size-3" />
+ </Button>
</div>
))}
- {/* Add more images button */}
- <div
- className="flex items-center justify-center w-32 h-32 border-2 border-dashed border-gray-300 rounded-md hover:border-gray-400 cursor-pointer"
- onClick={() => document.getElementById("additional-image-upload")?.click()}
- >
- <div className="text-center">
- <PictureOutlined style={{ fontSize: "24px", color: "#666" }} />
- <p className="text-xs text-gray-500 mt-1">Add more</p>
- </div>
+ <label className="flex h-32 w-32 cursor-pointer flex-col items-center justify-center rounded-md border-2 border-dashed border-gray-300 hover:border-gray-400">
+ <ImageIcon className="size-6 text-gray-500" aria-hidden="true" />
+ <p className="mt-1 text-xs text-gray-500">Add more</p>
<input
- id="additional-image-upload"
type="file"
accept={IMAGE_EDIT_ACCEPT}
multiple
- style={{ display: "none" }}
- onChange={(e) => {
- handleImageFiles(Array.from(e.target.files || []));
- e.target.value = "";
+ className="sr-only"
+ onChange={(event) => {
+ handleImageFiles(Array.from(event.target.files || []));
+ event.target.value = "";
}}
/>
- </div>
+ </label>
</div>
)}
</div>
)}
- {/* Audio Upload Section for Transcriptions */}
{endpointType === EndpointType.TRANSCRIPTION && (
<div className="mb-4">
{!uploadedAudio ? (
- <Dragger beforeUpload={handleAudioUpload} accept={AUDIO_ACCEPT} showUploadList={false}>
- <p className="ant-upload-drag-icon">
- <SoundOutlined style={{ fontSize: "24px", color: "#666" }} />
- </p>
- <p className="ant-upload-text text-sm">Click or drag audio file to upload</p>
- <p className="ant-upload-hint text-xs text-gray-500">
+ <label className="flex cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 px-4 py-8 text-center hover:border-gray-400">
+ <Volume2 className="mb-2 size-6 text-gray-500" aria-hidden="true" />
+ <p className="text-sm">Click or drag audio file to upload</p>
+ <p className="text-xs text-gray-500">
Support for MP3, MP4, MPEG, MPGA, M4A, WAV, WEBM formats. Max file size: 25 MB.
</p>
- </Dragger>
+ <input
+ type="file"
+ accept={AUDIO_ACCEPT}
+ className="sr-only"
+ onChange={(event) => {
+ const file = event.target.files?.[0];
+ if (file) handleAudioUpload(file);
+ event.target.value = "";
+ }}
+ />
+ </label>
) : (
- <div className="flex items-center gap-3 p-3 bg-gray-50 rounded-lg border border-gray-200">
- <div className="flex items-center gap-2 flex-1">
- <SoundOutlined style={{ fontSize: "20px", color: "#666" }} />
+ <div className="flex items-center gap-3 rounded-lg border border-gray-200 bg-gray-50 p-3">
+ <div className="flex flex-1 items-center gap-2">
+ <Volume2 className="size-5 text-gray-500" aria-hidden="true" />
<span className="text-sm font-medium">{uploadedAudio.name}</span>
<span className="text-xs text-gray-500">
({(uploadedAudio.size / 1024 / 1024).toFixed(2)} MB)
</span>
</div>
- <button
- className="bg-white shadow-xs border border-gray-200 rounded-sm px-2 py-1 text-red-500 hover:bg-red-50 text-xs"
+ <Button
+ type="button"
+ variant="outline"
+ size="xs"
+ className="text-red-500"
onClick={handleRemoveAudio}
>
- <DeleteOutlined /> Remove
- </button>
+ <Trash2 className="size-3" />
+ Remove
+ </Button>
</div>
)}
</div>
)}
- {/* Show file previews above input when files are uploaded */}
{endpointType === EndpointType.RESPONSES && responsesUploadedImage && (
<FilePreviewCard
file={responsesUploadedImage}
@@ -1927,31 +1905,30 @@ const ChatUI: React.FC<ChatUIProps> = ({
/>
)}
- {/* Code Interpreter indicator and sample prompts when enabled */}
{endpointType === EndpointType.RESPONSES && codeInterpreter.enabled && (
<div className="mb-2 space-y-2">
- <div className="px-3 py-2 bg-linear-to-r from-blue-50 to-purple-50 rounded-lg border border-blue-200 flex items-center justify-between">
+ <div className="flex items-center justify-between rounded-lg border border-blue-200 bg-linear-to-r from-blue-50 to-purple-50 px-3 py-2">
<div className="flex items-center gap-2">
{isLoading ? (
<>
- <LoadingOutlined className="text-blue-500" spin />
- <span className="text-sm text-blue-700 font-medium">Running Python code...</span>
+ <Loader2 className="size-4 animate-spin text-blue-500" aria-hidden="true" />
+ <span className="text-sm font-medium text-blue-700">Running Python code...</span>
</>
) : (
<>
- <CodeOutlined className="text-blue-500" />
- <span className="text-sm text-blue-700 font-medium">Code Interpreter Active</span>
+ <Code2 className="size-4 text-blue-500" aria-hidden="true" />
+ <span className="text-sm font-medium text-blue-700">Code Interpreter Active</span>
</>
)}
</div>
<button
+ type="button"
className="text-xs text-blue-500 hover:text-blue-700"
onClick={() => codeInterpreter.setEnabled(false)}
>
Disable
</button>
</div>
- {/* Sample prompts - only show when not loading */}
{!isLoading && (
<div className="flex flex-wrap gap-2">
{[
@@ -1961,7 +1938,8 @@ const ChatUI: React.FC<ChatUIProps> = ({
].map((prompt, idx) => (
<button
key={idx}
- className="text-xs px-3 py-1.5 bg-white border border-gray-200 rounded-full hover:bg-blue-50 hover:border-blue-300 hover:text-blue-600 transition-colors"
+ type="button"
+ className="rounded-full border border-gray-200 bg-white px-3 py-1.5 text-xs transition-colors hover:border-blue-300 hover:bg-blue-50 hover:text-blue-600"
onClick={() => setInputMessage(prompt)} // lgtm[js/xss-through-dom]
>
{prompt}
@@ -1972,9 +1950,8 @@ const ChatUI: React.FC<ChatUIProps> = ({
</div>
)}
- {/* Suggested prompts - show when chat is empty and not loading (skip for MCP - uses structured form) */}
{chatHistory.length === 0 && !isLoading && endpointType !== EndpointType.MCP && (
- <div className="flex items-center gap-2 mb-3 overflow-x-auto">
+ <div className="mb-3 flex items-center gap-2 overflow-x-auto">
{(endpointType === EndpointType.A2A_AGENTS
? ["What can you help me with?", "Tell me about yourself", "What tasks can you perform?"]
: ["Write me a poem", "Explain quantum computing", "Draft a polite email requesting a meeting"]
@@ -1982,7 +1959,7 @@ const ChatUI: React.FC<ChatUIProps> = ({
<button
key={prompt}
type="button"
- className="shrink-0 rounded-full border border-gray-200 px-3 py-1 text-xs font-medium text-gray-600 transition-colors hover:bg-blue-50 hover:border-blue-300 hover:text-blue-600 cursor-pointer"
+ className="shrink-0 cursor-pointer rounded-full border border-gray-200 px-3 py-1 text-xs font-medium text-gray-600 transition-colors hover:border-blue-300 hover:bg-blue-50 hover:text-blue-600"
onClick={() => setInputMessage(prompt)} // lgtm[js/xss-through-dom]
>
{prompt}
@@ -1992,9 +1969,8 @@ const ChatUI: React.FC<ChatUIProps> = ({
)}
<div className="flex items-center gap-2">
- <div className="flex items-center flex-1 bg-white border border-gray-300 rounded-xl px-3 py-1 min-h-[44px]">
- {/* Left: attachment and code interpreter icons */}
- <div className="shrink-0 mr-2 flex items-center gap-1">
+ <div className="flex min-h-[44px] flex-1 items-center rounded-xl border border-gray-300 bg-white px-3 py-1">
+ <div className="mr-2 flex shrink-0 items-center gap-1">
{endpointType === EndpointType.RESPONSES && !responsesUploadedImage && (
<ResponsesImageUpload
responsesUploadedImage={responsesUploadedImage}
@@ -2011,43 +1987,50 @@ const ChatUI: React.FC<ChatUIProps> = ({
onRemoveImage={handleRemoveChatImage}
/>
)}
- {/* Quick Code Interpreter toggle for Responses */}
{endpointType === EndpointType.RESPONSES && (
- <Tooltip
- title={
- codeInterpreter.enabled
- ? "Code Interpreter enabled (click to disable)"
- : "Enable Code Interpreter"
- }
- >
- <button
- className={`p-1.5 rounded-md transition-colors ${
- codeInterpreter.enabled
- ? "bg-blue-100 text-blue-600"
- : "text-gray-400 hover:text-gray-600 hover:bg-gray-100"
- }`}
- onClick={() => {
- codeInterpreter.toggle();
- if (!codeInterpreter.enabled) {
- NotificationsManager.success("Code Interpreter enabled!");
- }
- }}
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <button
+ type="button"
+ className={`rounded-md p-1.5 transition-colors ${
+ codeInterpreter.enabled
+ ? "bg-blue-100 text-blue-600"
+ : "text-gray-400 hover:bg-gray-100 hover:text-gray-600"
+ }`}
+ aria-label={
+ codeInterpreter.enabled
+ ? "Code Interpreter enabled (click to disable)"
+ : "Enable Code Interpreter"
+ }
+ onClick={() => {
+ codeInterpreter.toggle();
+ if (!codeInterpreter.enabled) {
+ NotificationsManager.success("Code Interpreter enabled!");
+ }
+ }}
+ />
+ }
>
- <CodeOutlined style={{ fontSize: "16px" }} />
- </button>
+ <Code2 className="size-4" />
+ </TooltipTrigger>
+ <TooltipContent>
+ {codeInterpreter.enabled
+ ? "Code Interpreter enabled (click to disable)"
+ : "Enable Code Interpreter"}
+ </TooltipContent>
</Tooltip>
)}
</div>
- {/* Middle: input field or MCP structured form */}
{endpointType === EndpointType.MCP &&
selectedMCPServers.length === 1 &&
selectedMCPServers[0] !== "__all__" &&
selectedMCPDirectTool ? (
- <div className="flex-1 overflow-y-auto max-h-48 min-h-[44px] p-2 border border-gray-200 rounded-lg bg-gray-50/50">
+ <div className="max-h-48 min-h-[44px] flex-1 overflow-y-auto rounded-lg border border-gray-200 bg-gray-50/50 p-2">
{(() => {
const rawSel = selectedMCPServers[0];
- let toolPool: any[] = [];
+ let toolPool: { name: string }[] = [];
if (rawSel.startsWith("toolset:")) {
const toolsetId = rawSel.slice("toolset:".length);
const toolset = mcpToolsets.find((t) => t.toolset_id === toolsetId);
@@ -2060,82 +2043,51 @@ const ChatUI: React.FC<ChatUIProps> = ({
} else {
toolPool = serverToolsMap[rawSel] || [];
}
- const mcpTool = toolPool.find((t: any) => t.name === selectedMCPDirectTool);
+ const mcpTool = toolPool.find((t) => t.name === selectedMCPDirectTool);
return mcpTool ? (
<MCPToolArgumentsForm ref={mcpToolArgsFormRef} tool={mcpTool} className="space-y-2" />
) : (
- <div className="flex items-center justify-center h-10 text-sm text-gray-500">
+ <div className="flex h-10 items-center justify-center text-sm text-gray-500">
Loading tool schema...
</div>
);
})()}
</div>
) : (
- <TextArea
+ <Textarea
value={inputMessage}
- onChange={(e) => setInputMessage(e.target.value)}
+ onChange={(event) => setInputMessage(event.target.value)}
onKeyDown={handleKeyDown}
- placeholder={
- endpointType === EndpointType.CHAT ||
- endpointType === EndpointType.EMBEDDINGS ||
- endpointType === EndpointType.RESPONSES ||
- endpointType === EndpointType.ANTHROPIC_MESSAGES ||
- endpointType === EndpointType.INTERACTIONS
- ? "Type your message... (Shift+Enter for new line)"
- : endpointType === EndpointType.A2A_AGENTS
- ? "Send a message to the A2A agent..."
- : endpointType === EndpointType.IMAGE_EDITS
- ? "Describe how you want to edit the image..."
- : endpointType === EndpointType.SPEECH
- ? "Enter text to convert to speech..."
- : endpointType === EndpointType.TRANSCRIPTION
- ? "Optional: Add context or prompt for transcription..."
- : "Describe the image you want to generate..."
- }
+ placeholder={inputPlaceholder}
disabled={isLoading}
- className="flex-1"
- autoSize={{ minRows: 1, maxRows: 4 }}
- style={{
- resize: "none",
- border: "none",
- boxShadow: "none",
- background: "transparent",
- padding: "4px 0",
- fontSize: "14px",
- lineHeight: "20px",
- }}
+ rows={1}
+ className="min-h-0 flex-1 resize-none border-0 bg-transparent px-0 py-1 text-sm shadow-none focus-visible:ring-0"
/>
)}
- {/* Right: send button - matching blue theme */}
- <TremorButton
+ <Button
+ type="button"
+ size="icon-sm"
onClick={handleSendMessage}
- disabled={
- isLoading ||
- (endpointType === EndpointType.MCP
- ? !(
- selectedMCPServers.length === 1 &&
- selectedMCPServers[0] !== "__all__" &&
- selectedMCPDirectTool
- )
- : endpointType === EndpointType.TRANSCRIPTION
- ? !uploadedAudio
- : !inputMessage.trim())
- }
- className="shrink-0 ml-2 w-8! h-8! min-w-8! p-0! rounded-full! bg-blue-600! hover:bg-blue-700! disabled:bg-gray-300! border-none! text-white! disabled:text-gray-500! flex! items-center! justify-center!"
+ disabled={sendDisabled}
+ className="ml-2 size-8 shrink-0 rounded-full bg-blue-600 text-white hover:bg-blue-700 disabled:bg-gray-300 disabled:text-gray-500"
+ aria-label="Send message"
>
- <ArrowUpOutlined style={{ fontSize: "14px" }} />
- </TremorButton>
+ <ArrowUp className="size-3.5" />
+ </Button>
</div>
{isLoading && (
- <TremorButton
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ className="border-red-200 bg-red-50 text-red-600 hover:bg-red-100"
onClick={handleCancelRequest}
- className="bg-red-50 hover:bg-red-100 text-red-600 border-red-200"
- icon={DeleteOutlined}
>
+ <Trash2 className="size-3.5" />
Cancel
- </TremorButton>
+ </Button>
)}
</div>
</div>
@@ -2143,50 +2095,55 @@ const ChatUI: React.FC<ChatUIProps> = ({
)}
</div>
</div>
- </Card>
- <Modal
- title="Generated Code"
- open={isGetCodeModalVisible}
- onCancel={() => setIsGetCodeModalVisible(false)}
- footer={null}
- width={800}
- >
- <div className="flex justify-between items-end my-4">
- <div>
- <Text className="font-medium block mb-1 text-gray-700">SDK Type</Text>
- <Select
- value={selectedSdk}
- onChange={(value) => setSelectedSdk(value as "openai" | "azure")}
- style={{ width: 150 }}
- options={[
- { value: "openai", label: "OpenAI SDK" },
- { value: "azure", label: "Azure SDK" },
- ]}
- />
+ </div>
+
+ <Dialog open={isGetCodeModalVisible} onOpenChange={setIsGetCodeModalVisible}>
+ <DialogContent className="sm:max-w-3xl">
+ <DialogHeader>
+ <DialogTitle>Generated Code</DialogTitle>
+ </DialogHeader>
+ <div className="my-2 flex items-end justify-between gap-3">
+ <div>
+ <p className="mb-1 text-sm font-medium text-gray-700">SDK Type</p>
+ <ShadcnSelect value={selectedSdk} onValueChange={(value) => setSelectedSdk(value as "openai" | "azure")}>
+ <SelectTrigger className="w-[150px]" size="sm" aria-label="SDK Type">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="openai">OpenAI SDK</SelectItem>
+ <SelectItem value="azure">Azure SDK</SelectItem>
+ </SelectContent>
+ </ShadcnSelect>
+ </div>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => {
+ void navigator.clipboard.writeText(generatedCode).then(
+ () => NotificationsManager.success("Copied to clipboard!"),
+ () => NotificationsManager.error("Unable to copy to clipboard"),
+ );
+ }}
+ >
+ Copy to Clipboard
+ </Button>
</div>
- <Button
- onClick={() => {
- navigator.clipboard.writeText(generatedCode);
- NotificationsManager.success("Copied to clipboard!");
+ <SyntaxHighlighter
+ language="python"
+ style={coy as Record<string, React.CSSProperties>}
+ wrapLines={true}
+ wrapLongLines={true}
+ className="rounded-md"
+ customStyle={{
+ maxHeight: "60vh",
+ overflowY: "auto",
}}
>
- Copy to Clipboard
- </Button>
- </div>
- <SyntaxHighlighter
- language="python"
- style={coy as any}
- wrapLines={true}
- wrapLongLines={true}
- className="rounded-md"
- customStyle={{
- maxHeight: "60vh",
- overflowY: "auto",
- }}
- >
- {generatedCode}
- </SyntaxHighlighter>
- </Modal>
+ {generatedCode}
+ </SyntaxHighlighter>
+ </DialogContent>
+ </Dialog>
{byokModalServer && (
<ByokCredentialModal
@@ -2194,58 +2151,56 @@ const ChatUI: React.FC<ChatUIProps> = ({
open={!!byokModalServer}
onClose={() => setByokModalServer(null)}
onSuccess={(_serverId) => {
- // Refresh MCP servers to pick up updated has_user_credential
loadMCPServers();
setByokModalServer(null);
}}
/>
)}
- {/* Toolsets info modal */}
- <Modal
- title="How Toolsets Work"
- open={isToolsetsInfoModalVisible}
- onCancel={() => setIsToolsetsInfoModalVisible(false)}
- footer={[
- <Button key="close" onClick={() => setIsToolsetsInfoModalVisible(false)}>
- Close
- </Button>,
- ]}
- width={600}
- >
- <div className="space-y-4 py-2">
- <p className="text-gray-700">
- <strong>Toolsets</strong> are named collections of specific tools from one or more MCP servers. Instead of
- exposing all tools from a server, a toolset gives an agent exactly the tools it needs.
- </p>
- <div>
- <h4 className="font-semibold text-gray-800 mb-2">How to use a toolset:</h4>
- <ol className="list-decimal list-inside space-y-2 text-gray-700">
- <li>
- Select a <span style={{ color: "#7c3aed", fontWeight: 600 }}>Toolset</span> (purple badge) from the MCP
- Servers dropdown.
- </li>
- <li>The tool picker will show only the tools included in that toolset.</li>
- <li>Select a tool and fill in its parameters, then send.</li>
- <li>The tool call is routed to the correct underlying MCP server automatically.</li>
- </ol>
- </div>
- <div className="bg-purple-50 border border-purple-200 rounded-sm p-3">
- <p className="text-sm text-purple-800">
- <strong>Example:</strong> A &quot;GitHub Read-only&quot; toolset might include only{" "}
- <code>list_repos</code> and <code>get_file</code> from a GitHub MCP server — preventing agents from making
- writes.
- </p>
- </div>
- <div>
- <h4 className="font-semibold text-gray-800 mb-1">Creating toolsets:</h4>
- <p className="text-sm text-gray-600">
- Admins can create and manage toolsets from the <strong>MCP</strong> page → <strong>Toolsets</strong> tab.
- Toolsets can then be assigned to keys and teams to scope their tool access.
+ <Dialog open={isToolsetsInfoModalVisible} onOpenChange={setIsToolsetsInfoModalVisible}>
+ <DialogContent className="sm:max-w-xl">
+ <DialogHeader>
+ <DialogTitle>How Toolsets Work</DialogTitle>
+ </DialogHeader>
+ <div className="space-y-4 py-2">
+ <p className="text-gray-700">
+ <strong>Toolsets</strong> are named collections of specific tools from one or more MCP servers. Instead of
+ exposing all tools from a server, a toolset gives an agent exactly the tools it needs.
</p>
+ <div>
+ <h4 className="mb-2 font-semibold text-gray-800">How to use a toolset:</h4>
+ <ol className="list-inside list-decimal space-y-2 text-gray-700">
+ <li>
+ Select a <span className="font-semibold text-violet-600">Toolset</span> (purple badge) from the MCP
+ Servers dropdown.
+ </li>
+ <li>The tool picker will show only the tools included in that toolset.</li>
+ <li>Select a tool and fill in its parameters, then send.</li>
+ <li>The tool call is routed to the correct underlying MCP server automatically.</li>
+ </ol>
+ </div>
+ <div className="rounded-sm border border-purple-200 bg-purple-50 p-3">
+ <p className="text-sm text-purple-800">
+ <strong>Example:</strong> A &quot;GitHub Read-only&quot; toolset might include only{" "}
+ <code>list_repos</code> and <code>get_file</code> from a GitHub MCP server, preventing agents from
+ making writes.
+ </p>
+ </div>
+ <div>
+ <h4 className="mb-1 font-semibold text-gray-800">Creating toolsets:</h4>
+ <p className="text-sm text-gray-600">
+ Admins can create and manage toolsets from the <strong>MCP</strong> page → <strong>Toolsets</strong>{" "}
+ tab. Toolsets can then be assigned to keys and teams to scope their tool access.
+ </p>
+ </div>
</div>
- </div>
- </Modal>
+ <DialogFooter>
+ <Button type="button" variant="outline" onClick={() => setIsToolsetsInfoModalVisible(false)}>
+ Close
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
</div>
);
};
diff --git a/ui/litellm-dashboard/src/components/shared/MultiSelect.tsx b/ui/litellm-dashboard/src/components/shared/MultiSelect.tsx
index 429e12ed646..f084572bc0c 100644
--- a/ui/litellm-dashboard/src/components/shared/MultiSelect.tsx
+++ b/ui/litellm-dashboard/src/components/shared/MultiSelect.tsx
@@ -53,19 +53,25 @@ export function MultiSelect({
className,
}: MultiSelectProps) {
const [query, setQuery] = useState("");
- const selectedOptions = value.map(
- (selectedValue) =>
- options.find((option) => option.value === selectedValue) ?? {
- label: selectedValue,
- value: selectedValue,
- },
+ const safeOptions = options.filter(
+ (option): option is MultiSelectOption =>
+ option != null && typeof option.value === "string" && option.value.length > 0,
);
+ const selectedOptions = value
+ .filter((selectedValue): selectedValue is string => typeof selectedValue === "string" && selectedValue.length > 0)
+ .map(
+ (selectedValue) =>
+ safeOptions.find((option) => option.value === selectedValue) ?? {
+ label: selectedValue,
+ value: selectedValue,
+ },
+ );
const customOption = query.trim();
- const customOptionExists = options.some((option) => option.value.toLowerCase() === customOption.toLowerCase());
+ const customOptionExists = safeOptions.some((option) => option.value.toLowerCase() === customOption.toLowerCase());
const items =
allowCustomValues && customOption && !customOptionExists
- ? [...options, { label: `Create "${customOption}"`, value: customOption }]
- : options;
+ ? [...safeOptions, { label: `Create "${customOption}"`, value: customOption }]
+ : safeOptions;
return (
<Combobox