From b9759b4bfaaa4d28405a95007e1b988c7b8f82f0 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Tue, 11 Nov 2025 18:52:11 -0800 Subject: [PATCH] [Feature] UI - Add LiteLLM Params to Edit Model (#16496) * Add LiteLLM Params to Edit Model * Fixed tests --- .../add_model/advanced_settings.test.tsx | 19 ++++++- .../add_model/advanced_settings.tsx | 17 ++----- .../src/components/model_info_view.test.tsx | 7 +++ .../src/components/model_info_view.tsx | 49 ++++++++++++++++++- .../src/utils/textUtils.test.ts | 13 ++++- ui/litellm-dashboard/src/utils/textUtils.ts | 12 +++++ 6 files changed, 99 insertions(+), 18 deletions(-) diff --git a/ui/litellm-dashboard/src/components/add_model/advanced_settings.test.tsx b/ui/litellm-dashboard/src/components/add_model/advanced_settings.test.tsx index 8c2e339141f..6515c67c292 100644 --- a/ui/litellm-dashboard/src/components/add_model/advanced_settings.test.tsx +++ b/ui/litellm-dashboard/src/components/add_model/advanced_settings.test.tsx @@ -1,4 +1,4 @@ -import { fireEvent, render, waitFor } from "@testing-library/react"; +import { act, fireEvent, render, waitFor } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import AdvancedSettings from "./advanced_settings"; @@ -31,4 +31,21 @@ describe("AdvancedSettings", () => { expect(getByText("Tags")).toBeInTheDocument(); }); }); + + it("should render the litellm params", async () => { + const { getByText } = render( + {}} + guardrailsList={[]} + tagsList={{}} + />, + ); + act(() => { + fireEvent.click(getByText("Advanced Settings")); + }); + await waitFor(() => { + expect(getByText("LiteLLM Params")).toBeInTheDocument(); + }); + }); }); diff --git a/ui/litellm-dashboard/src/components/add_model/advanced_settings.tsx b/ui/litellm-dashboard/src/components/add_model/advanced_settings.tsx index 7314b5d9c46..c9f5ef8a4b1 100644 --- a/ui/litellm-dashboard/src/components/add_model/advanced_settings.tsx +++ b/ui/litellm-dashboard/src/components/add_model/advanced_settings.tsx @@ -7,6 +7,7 @@ import { InfoCircleOutlined } from "@ant-design/icons"; import { Team } from "../key_team_helpers/key_list"; import CacheControlSettings from "./cache_control_settings"; import { Tag } from "../tag_management/types"; +import { formItemValidateJSON } from "../../utils/textUtils"; const { Link } = Typography; interface AdvancedSettingsProps { @@ -40,18 +41,6 @@ const AdvancedSettings: React.FC = ({ return Promise.resolve(); }; - const validateJSON = (_: any, value: string) => { - if (!value) { - return Promise.resolve(); - } - try { - JSON.parse(value); - return Promise.resolve(); - } catch (error) { - return Promise.reject("Please enter valid JSON"); - } - }; - // Handle custom pricing changes const handleCustomPricingChange = (checked: boolean) => { setCustomPricing(checked); @@ -233,7 +222,7 @@ const AdvancedSettings: React.FC = ({ name="litellm_extra_params" tooltip="Optional litellm params used for making a litellm.completion() call." className="mb-4 mt-4" - rules={[{ validator: validateJSON }]} + rules={[{ validator: formItemValidateJSON }]} >