diff --git a/ui/litellm-dashboard/src/components/add_model/AutoSetupControls.tsx b/ui/litellm-dashboard/src/components/add_model/AutoSetupControls.tsx index ab0f45bd907..c77d7ffd0d0 100644 --- a/ui/litellm-dashboard/src/components/add_model/AutoSetupControls.tsx +++ b/ui/litellm-dashboard/src/components/add_model/AutoSetupControls.tsx @@ -5,11 +5,24 @@ import { UiLoadingSpinner } from "@/components/ui/ui-loading-spinner"; import type { AutoSetupObjective, AutoSetupQualityLevel } from "./build_complexity_router_config"; const OBJECTIVE_DESCRIPTION: Record = { - cost: "Uses expected cost per completed benchmark task, including failures", - task_completion_speed: "Uses live response speed for easy requests and benchmark completion time for hard ones", - balanced: "Balances cost per completed task with those same completion-time signals", + cost: "Spend less while staying within your selected quality level", + task_completion_speed: "Finish requests sooner, not just generate tokens faster", + balanced: "Balance expected cost with time to completion", }; +const QUALITY_OPTIONS = [ + { value: "economy", label: "Economy" }, + { value: "balanced", label: "Balanced" }, + { value: "high", label: "High" }, + { value: "max", label: "Max" }, +]; + +const OBJECTIVE_OPTIONS = [ + { value: "cost", label: "Cost" }, + { value: "task_completion_speed", label: "Task completion speed" }, + { value: "balanced", label: "Balanced" }, +]; + interface AutoSetupControlsProps { qualityLevel: AutoSetupQualityLevel; optimizeFor: AutoSetupObjective; @@ -24,7 +37,7 @@ interface AutoSetupControlsProps { hasAutoPolicy: boolean; onRetry: () => void; onRegenerate: () => void; - onUseManual: () => void; + onBack: () => void; } const recommendationErrorMessage = (error: unknown): string => @@ -32,7 +45,18 @@ const recommendationErrorMessage = (error: unknown): string => const readyMessage = (recommendation: AutoRouterRecommendationResponse): string => { const count = recommendation.matched_model_groups.length; - return `Ready with ${count} available model${count === 1 ? "" : "s"}. Review or edit below`; + return `Uses ${count} available model${count === 1 ? "" : "s"} across four complexity levels`; +}; + +const recommendationDescription = (optimizeFor: AutoSetupObjective): string => { + switch (optimizeFor) { + case "cost": + return "Favors the lowest expected cost while keeping each request within your selected quality level"; + case "task_completion_speed": + return "Easy requests use live response speed; difficult requests use benchmark completion time"; + case "balanced": + return "Balances expected cost with response speed and benchmark completion time"; + } }; export default function AutoSetupControls({ @@ -49,20 +73,26 @@ export default function AutoSetupControls({ hasAutoPolicy, onRetry, onRegenerate, - onUseManual, + onBack, }: AutoSetupControlsProps) { return ( -
-
-
Auto setup
-
- Builds an editable complexity router from the models available to you +
+
+
+
Configure automatically
+
+ Choose the outcome you want. LiteLLM will build the model tiers for you +
+
value && onOptimizeForChange(value)} > @@ -115,20 +146,22 @@ export default function AutoSetupControls({
)} {recommendation && ( -
-
- {hasAutoPolicy ? readyMessage(recommendation) : "Customized model pools now use standard manual selection"} +
+
+ {hasAutoPolicy ? "Recommended setup" : "Configuration edited"} +
+
+ {hasAutoPolicy + ? `${readyMessage(recommendation)}. ${recommendationDescription(optimizeFor)}` + : "Your model changes are now treated as a manual configuration"}
{!hasAutoPolicy && ( )}
)} -
); } diff --git a/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.test.tsx b/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.test.tsx index fc681bbf940..b97efff74c5 100644 --- a/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.test.tsx +++ b/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.test.tsx @@ -43,11 +43,17 @@ const ANTHROPIC_ONLY_MODEL = ANTHROPIC_TIERS.COMPLEX[0]; const openTemplateDropdown = (): void => { if (!screen.queryByTestId("template-selector")) { - fireEvent.click(screen.getByRole("button", { name: /choose a template or set up manually/i })); + fireEvent.click(screen.getByRole("button", { name: "Back" })); } fireEvent.click(screen.getByTestId("template-selector")); }; +const openAutoSetup = (): void => { + if (!screen.queryByTestId("auto-quality-selector")) { + fireEvent.click(screen.getByTestId("configure-automatically-button")); + } +}; + // Detailed Configuration is collapsed by default, so any test reaching into it (a tier select, an // "Advanced: ..." sub-section) has to open it first. const expandDetailedConfiguration = (): void => { @@ -152,9 +158,23 @@ describe("AddAutoRouterTab", () => { vi.mocked(useAutoRouterRecommendation).mockReturnValue(EMPTY_RECOMMENDATION_QUERY); }); - it("starts with only quality and optimization choices in Auto setup", () => { + it("keeps the manual form and adds Configure automatically above it", () => { renderWithProviders(); + expect(screen.getByTestId("configure-automatically-button")).toBeInTheDocument(); + expect(screen.getByTestId("template-selector")).toBeInTheDocument(); + expect(screen.getByTestId("detailed-configuration-toggle")).toBeInTheDocument(); + expect(screen.queryByTestId("auto-quality-selector")).not.toBeInTheDocument(); + expect(screen.getByRole("button", { name: /add auto router/i })).toBeDisabled(); + expect(useAutoRouterRecommendation).toHaveBeenCalledWith(expect.objectContaining({ enabled: false })); + }); + + it("shows the two outcome choices after Configure automatically is selected", async () => { + const user = userEvent.setup(); + renderWithProviders(); + + await user.click(screen.getByTestId("configure-automatically-button")); + expect(screen.getByTestId("auto-quality-selector")).toBeInTheDocument(); expect(screen.getByTestId("auto-objective-selector")).toBeInTheDocument(); expect(screen.queryByTestId("template-selector")).not.toBeInTheDocument(); @@ -163,6 +183,18 @@ describe("AddAutoRouterTab", () => { ); }); + it("returns to the original manual form from automatic setup", async () => { + const user = userEvent.setup(); + renderWithProviders(); + + await user.click(screen.getByTestId("configure-automatically-button")); + await user.click(screen.getByRole("button", { name: "Back" })); + + expect(screen.getByTestId("template-selector")).toBeInTheDocument(); + expect(screen.getByTestId("configure-automatically-button")).toBeInTheDocument(); + expect(screen.queryByTestId("auto-quality-selector")).not.toBeInTheDocument(); + }); + it("submits the editable policy generated for the caller's available model groups", async () => { const user = userEvent.setup(); const autoSetup: AutoSetupConfigPayload = { @@ -221,7 +253,8 @@ describe("AddAutoRouterTab", () => { }); renderWithProviders(); - await screen.findByText(/Ready with 1 available model/); + await user.click(screen.getByTestId("configure-automatically-button")); + await screen.findByText(/Uses 1 available model/); await user.type(screen.getByPlaceholderText(/smart_router/i), "max-speed-router"); await user.click(screen.getByRole("button", { name: /add auto router/i })); @@ -231,8 +264,8 @@ describe("AddAutoRouterTab", () => { }); }); - // Detailed Configuration starts collapsed so the modal opens onto just Name + Template; a caller - // opts into the full tier/classifier form rather than always seeing it up front. + // Detailed Configuration starts collapsed after manual setup is selected; a caller opts into the + // full tier/classifier form rather than always seeing it up front. it("keeps Detailed Configuration collapsed until a caller opens it", () => { renderWithProviders(); @@ -243,9 +276,7 @@ describe("AddAutoRouterTab", () => { expect(screen.getByText("Complexity Tier Configuration")).toBeInTheDocument(); }); - // Nothing is filled in, so there is nothing to submit. The button reports that itself instead of - // accepting a click and answering with a toast. - it("offers no submit at all until every tier has a model", async () => { + it("offers no submit until every tier has a model", async () => { renderWithProviders(); expect(screen.getByRole("button", { name: /add auto router/i })).toBeDisabled(); @@ -259,6 +290,7 @@ describe("AddAutoRouterTab", () => { }); const { container } = renderWithProviders(); + openAutoSetup(); fireEvent.change(screen.getByPlaceholderText(/smart_router/i), { target: { value: "early-router" } }); fireEvent.submit(container.querySelector("form")!); @@ -465,6 +497,7 @@ describe("AddAutoRouterTab", () => { , ); + openAutoSetup(); expect(screen.getByText("Select a team to build its Auto setup")).toBeInTheDocument(); expect(screen.getByRole("button", { name: /add auto router/i })).toBeDisabled(); expect(handleAddAutoRouterSubmit).not.toHaveBeenCalled(); @@ -480,6 +513,7 @@ describe("AddAutoRouterTab", () => { , ); + openAutoSetup(); await user.type(screen.getByPlaceholderText(/smart_router/i), "team-scoped-router"); await user.selectOptions(screen.getByTestId("team-dropdown"), "team-1"); await user.click(screen.getByTestId("team-dropdown-clear")); diff --git a/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.tsx b/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.tsx index f2f16605dc9..aa7f878d233 100644 --- a/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.tsx +++ b/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.tsx @@ -186,7 +186,7 @@ const AddAutoRouterTab: React.FC = ({ const watchedName = useWatch({ control: form.control, name: "auto_router_name" }); const watchedTeamId = useWatch({ control: form.control, name: "team_id" }); const [modelAccessGroups, setModelAccessGroups] = useState([]); - const [setupMode, setSetupMode] = useState("auto"); + const [setupMode, setSetupMode] = useState("manual"); const [qualityLevel, setQualityLevel] = useState("balanced"); const [optimizeFor, setOptimizeFor] = useState("balanced"); const appliedRecommendationKey = useRef(null); @@ -338,6 +338,20 @@ const AddAutoRouterTab: React.FC = ({ setEscalationKeywords(prefill.escalationKeywords); }, []); + const chooseAutoSetup = () => { + appliedRecommendationKey.current = null; + setDetailsExpanded(false); + setSetupMode("auto"); + }; + + const returnToManualSetup = () => { + appliedRecommendationKey.current = null; + setSelectedPreset(undefined); + applyPrefill(buildEmptyPrefill()); + setDetailsExpanded(false); + setSetupMode("manual"); + }; + useEffect(() => { if (!recommendation || setupMode !== "auto") return; const key = [ @@ -596,22 +610,14 @@ const AddAutoRouterTab: React.FC = ({ hasAutoPolicy={Boolean(complexityRouterConfig.auto_setup)} onRetry={() => void refetchRecommendation()} onRegenerate={regenerateAutoSetup} - onUseManual={() => setSetupMode("manual")} + onBack={returnToManualSetup} /> ) : (
-