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
refactor(ui): extract hydrateBuiltInTiers so the edit modal stays under max-lines
moe-berria4f865b1bec1
diff --git a/ui/litellm-dashboard/src/components/add_model/build_complexity_router_config.ts b/ui/litellm-dashboard/src/components/add_model/build_complexity_router_config.tsindex 0fa2268f2ed..5b53941bc10 100644--- a/ui/litellm-dashboard/src/components/add_model/build_complexity_router_config.ts+++ b/ui/litellm-dashboard/src/components/add_model/build_complexity_router_config.ts@@ -385,6 +385,26 @@ export const customTierWireFields = (};};+/** The built-in tier pools and the opt-in flag, read back from a stored config. `tiers` is+ * rewritten wholesale on save, so a stored tier this misses is deleted by any unrelated edit. */+export const hydrateBuiltInTiers = (+ storedTiers: Partial<Record<keyof ComplexityTiers, unknown>> | undefined,+ storedFlag: boolean | undefined,+): { tiers: ComplexityTiers; enable_non_reasoning_tier: boolean } => {+ const nonReasoning: string[] = normalizeTierModels(storedTiers?.NON_REASONING);+ const enable_non_reasoning_tier: boolean = storedFlag === true || nonReasoning.length > 0;+ return {+ enable_non_reasoning_tier,+ tiers: {+ SIMPLE: normalizeTierModels(storedTiers?.SIMPLE),+ MEDIUM: normalizeTierModels(storedTiers?.MEDIUM),+ COMPLEX: normalizeTierModels(storedTiers?.COMPLEX),+ REASONING: normalizeTierModels(storedTiers?.REASONING),+ ...(enable_non_reasoning_tier && { NON_REASONING: nonReasoning }),+ },+ };+};+// plan_mode_min_tier rides the strip list because the base payload carries it as a row id;// customTierWireFields re-emits it as the row's name, and an unresolvable floor stays off.const CUSTOM_TIER_STRIPPED_KEYS: readonly string[] = [...CUSTOM_TIER_OMITTED_KEYS, "plan_mode_min_tier"];diff --git a/ui/litellm-dashboard/src/components/edit_auto_router/edit_auto_router_modal.tsx b/ui/litellm-dashboard/src/components/edit_auto_router/edit_auto_router_modal.tsxindex 76082a9444f..8a62e86e842 100644--- a/ui/litellm-dashboard/src/components/edit_auto_router/edit_auto_router_modal.tsx+++ b/ui/litellm-dashboard/src/components/edit_auto_router/edit_auto_router_modal.tsx@@ -14,7 +14,7 @@ import ModelChoiceCombobox, { type ModelChoice } from "../add_model/ModelChoiceCimport { modelAvailableCall, modelPatchUpdateCall, validateAutoRouterConfig } from "../networking";import { fetchAvailableModels, ModelGroup } from "@/components/llm_calls/fetch_models";import RouterConfigBuilder from "../add_model/RouterConfigBuilder";-import { hydrateTierModelParams, normalizeTierModels } from "../add_model/complexity_router_tiers";+import { hydrateTierModelParams } from "../add_model/complexity_router_tiers";import {type ActiveTierSet,CUSTOM_TIER_OMITTED_KEYS,@@ -34,6 +34,7 @@ import {getSemanticConfigError,getPlanModeTierError,getTierLabelsError,+ hydrateBuiltInTiers,hydrateCustomTierSet,hydratePlanModeMinTier,hydrateTierLabels,@@ -139,21 +140,10 @@ export const hydrateComplexityRouterConfig = (parsedConfig: StoredComplexityRouterConfig,complexityRouterDefaultModel: string | null | undefined,): ComplexityRouterConfigValue => {- // `tiers` is rewritten wholesale on save, so a stored tier this misses is deleted by any edit,- // including one made for an unrelated reason. Hence reading both back rather than assuming four.- const storedNonReasoning: string[] = normalizeTierModels(parsedConfig.tiers?.NON_REASONING);- const enable_non_reasoning_tier: boolean =- parsedConfig.enable_non_reasoning_tier === true || storedNonReasoning.length > 0;- const hydratedTiers: ComplexityTiers = {- SIMPLE: normalizeTierModels(parsedConfig.tiers?.SIMPLE),- MEDIUM: normalizeTierModels(parsedConfig.tiers?.MEDIUM),- COMPLEX: normalizeTierModels(parsedConfig.tiers?.COMPLEX),- REASONING: normalizeTierModels(parsedConfig.tiers?.REASONING),- ...(enable_non_reasoning_tier && { NON_REASONING: storedNonReasoning }),- };-+ const builtIn = hydrateBuiltInTiers(parsedConfig.tiers, parsedConfig.enable_non_reasoning_tier);+ const { tiers: hydratedTiers, enable_non_reasoning_tier } = builtIn;const custom_tier_set = hydrateCustomTierSet(parsedConfig);- const activeTiers = { tiers: hydratedTiers, enable_non_reasoning_tier, custom_tier_set };+ const activeTiers = { ...builtIn, custom_tier_set };return {tiers: hydratedTiers,