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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(ui): exclude existing Auto Routers from auto setup
moe-berria48afd22421e
diff --git a/ui/litellm-dashboard/src/components/add_model/auto_setup.test.ts b/ui/litellm-dashboard/src/components/add_model/auto_setup.test.tsindex 165b060129d..b5340dbad2e 100644--- a/ui/litellm-dashboard/src/components/add_model/auto_setup.test.ts+++ b/ui/litellm-dashboard/src/components/add_model/auto_setup.test.ts@@ -35,6 +35,23 @@ describe("buildAutomaticRouterConfig", () => {expect(config?.classifier_type).toBe("heuristic_v2");});+ it("selects one model per tier from a large inventory", () => {+ const names = Array.from({ length: 100 }, (_, index) => `model-${index.toString().padStart(3, "0")}`);+ const config = buildAutomaticRouterConfig(+ models(...names),+ names.map((name, index) => deployment(name, index + 1)),+ {},+ );+ const expectedTiers = {+ SIMPLE: ["model-000"],+ MEDIUM: ["model-033"],+ COMPLEX: ["model-066"],+ REASONING: ["model-099"],+ };++ expect(config?.tiers).toEqual(expectedTiers);+ });+it("only repeats models when fewer than four are available", () => {expect(tierModels(@@ -87,8 +104,12 @@ describe("buildAutomaticRouterConfig", () => {{ model_group: "chat-model", mode: "chat" },{ model_group: "image-model", mode: "image_generation" },{ model_group: "auto_router/existing", mode: "chat" },+ { model_group: "smart-router", mode: "chat" },+ ],+ [+ deployment("chat-model", 1),+ { model_name: "smart-router", litellm_params: { model: "auto_router/complexity_router" } },],- [deployment("chat-model", 1)],{},);diff --git a/ui/litellm-dashboard/src/components/add_model/auto_setup.ts b/ui/litellm-dashboard/src/components/add_model/auto_setup.tsindex f5c35ef5150..265a943e859 100644--- a/ui/litellm-dashboard/src/components/add_model/auto_setup.ts+++ b/ui/litellm-dashboard/src/components/add_model/auto_setup.ts@@ -1,4 +1,4 @@-import type { AutoRouterDeployment } from "@/app/(dashboard)/hooks/models/useModels";+import { isAutoRouterDeployment, type AutoRouterDeployment } from "@/app/(dashboard)/hooks/models/useModels";import type { ModelGroup } from "@/components/llm_calls/fetch_models";import type { ComplexityRouterConfigValue } from "./ComplexityRouterConfig";@@ -47,17 +47,31 @@ const groupPrice = (return Math.max(...knownPrices);};+const selectTierModels = (ranked: string[]): [string, string, string, string] => {+ if (ranked.length === 1) return [ranked[0], ranked[0], ranked[0], ranked[0]];+ if (ranked.length === 2) return [ranked[0], ranked[0], ranked[1], ranked[1]];+ if (ranked.length === 3) return [ranked[0], ranked[1], ranked[2], ranked[2]];++ const last = ranked.length - 1;+ return [ranked[0], ranked[Math.floor(last / 3)], ranked[Math.floor((2 * last) / 3)], ranked[last]];+};+export const buildAutomaticRouterConfig = (models: ModelGroup[],deployments: AutoRouterDeployment[],costMap: ModelCostMap,): ComplexityRouterConfigValue | null => {+ const autoRouterNames: ReadonlySet<string> = new Set(+ deployments+ .filter(isAutoRouterDeployment)+ .flatMap((deployment) => (deployment.model_name ? [deployment.model_name] : [])),+ );const names = Array.from(new Set(models.filter((model) => model.mode === undefined || model.mode === "chat").map((model) => model.model_group)- .filter((name) => name && !name.startsWith("auto_router/")),+ .filter((name) => name && !name.startsWith("auto_router/") && !autoRouterNames.has(name)),),);if (names.length === 0) return null;@@ -74,14 +88,7 @@ export const buildAutomaticRouterConfig = (}).map(({ name }) => name);- let selected: [string, string, string, string];- if (ranked.length === 1) selected = [ranked[0], ranked[0], ranked[0], ranked[0]];- else if (ranked.length === 2) selected = [ranked[0], ranked[0], ranked[1], ranked[1]];- else if (ranked.length === 3) selected = [ranked[0], ranked[1], ranked[2], ranked[2]];- else {- const last = ranked.length - 1;- selected = [ranked[0], ranked[Math.floor(last / 3)], ranked[Math.floor((2 * last) / 3)], ranked[last]];- }+ const selected = selectTierModels(ranked);return {tiers: {