Spaces:
Running on CPU Spr
Running on CPU Spr
File size: 2,989 Bytes
2fcae3f fe99ffa 06313c1 fe99ffa c2e86ea fe99ffa d249d5b fe99ffa d249d5b fe99ffa d249d5b fe99ffa d249d5b fe99ffa d249d5b fe99ffa d249d5b fe99ffa d249d5b fe99ffa d249d5b fe99ffa d249d5b fe99ffa 32864b0 d249d5b 32864b0 da8db3e fe99ffa d249d5b fe99ffa d249d5b fe99ffa d249d5b fe99ffa | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | import "server-only"
import type { BackendManifestStatus } from "@/lib/backend-artifacts"
import { cleanHierarchy } from "@/lib/clean-hierarchy"
async function viewBackend() {
return import("@/lib/view-data")
}
async function sidecars() {
return import("@/lib/sidecars")
}
async function hfData() {
return import("@/lib/hf-data")
}
async function applyModelCoverage<T extends { route_id: string; benchmarks_count: number }>(
cards: T[],
): Promise<T[]> {
try {
const coverage = await (await sidecars()).fetchModelCoverage()
if (Object.keys(coverage).length === 0) return cards
return cards.map((c) =>
coverage[c.route_id] != null
? { ...c, benchmarks_count: coverage[c.route_id] }
: c,
)
} catch {
return cards
}
}
export async function getModelCards() {
const cards = await (await viewBackend()).getModelCards()
return applyModelCoverage(cards)
}
export async function getModelCardsLite() {
const cards = await (await viewBackend()).getModelCardsLite()
return applyModelCoverage(cards)
}
export async function getEvalListData() {
return (await viewBackend()).getEvalListData()
}
export async function getEvalListLiteData() {
return (await viewBackend()).getEvalListLiteData()
}
export async function getEvalList() {
return (await viewBackend()).getEvalList()
}
export async function getDashboardData() {
return (await viewBackend()).getDashboardData()
}
export async function getDeveloperList() {
return (await viewBackend()).getDeveloperList()
}
export async function getDeveloperSummaryById(routeId: string) {
return (await viewBackend()).getDeveloperSummaryById(routeId)
}
export async function getModelSummaryById(modelId: string) {
return (await viewBackend()).getModelSummaryById(modelId)
}
export async function getEvalSummaryById(evalId: string) {
return (await viewBackend()).getEvalSummaryById(evalId)
}
export async function getBackendManifestData() {
return (await sidecars()).fetchManifest()
}
export async function getBackendManifestStatusData(): Promise<BackendManifestStatus> {
const manifest = await (await sidecars()).fetchManifest()
return {
currentManifest: manifest,
latestManifest: manifest,
currentManifestSignature: manifest.generated_at,
latestManifestSignature: manifest.generated_at,
updateAvailable: false,
refreshing: false,
pendingRefreshCount: 0,
}
}
export async function getEvalHierarchyData() {
// The v2 sidecar ships hierarchy.json in the composite/family/slice
// taxonomy shape (top-level `composites[]`, flat `families[]` lookup
// index). UI components expect the legacy nested
// `families[].composites[]` / `families[].standalone_benchmarks[]`
// shape, so route the sidecar through the adapter, then `cleanHierarchy`
// for sanitised display names + family-rollup filtering.
const raw = await (await sidecars()).fetchHierarchy()
return cleanHierarchy((await hfData()).adaptEvalHierarchy(raw))
}
|