litellm/ui/litellm-dashboard/tests/mocks/autoRouterPresets.ts
tin-berri 993766be0e
feat(proxy): serve the auto-router preset catalog at runtime (#39412)
The dashboard's template picker imported autorouter_presets.json at build time, so every
catalog change needed a dashboard rebuild and artifacts refresh. The catalog now lives in
litellm/proxy/public_endpoints/ and GET /public/autorouter_presets serves it, fetching
litellm.autorouter_presets_url (GitHub raw on main, 1h in-process cache, bundled fallback)
so a merged catalog change propagates to running proxies like the model cost map does.
The dashboard fetches it at runtime via useAutoRouterPresets and keeps no local copy.

Resolves LIT-6764
2026-09-02 18:03:22 -07:00

16 lines
697 B
TypeScript

import { vi } from "vitest";
import bundledPresets from "../../../../litellm/proxy/public_endpoints/autorouter_presets.json";
import { hydratePresets, type AutoRouterPresetsResponse } from "@/lib/autorouter_presets";
// Derived from the real bundled catalog so a preset edit there flows into test expectations
// instead of redding on a stale copy. Exported as vi.fn so a test can override the query state.
export const BUNDLED_PRESETS = hydratePresets(bundledPresets as AutoRouterPresetsResponse);
export const LOADED_PRESETS_QUERY = {
data: BUNDLED_PRESETS,
isPending: false,
isError: false,
refetch: vi.fn(),
};
export const useAutoRouterPresets = vi.fn(() => LOADED_PRESETS_QUERY);