File size: 2,723 Bytes
bca888a
3a12290
415ac43
3a12290
04b4cff
3a12290
 
 
 
 
 
 
 
 
 
03e2430
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a12290
 
 
 
 
 
 
 
 
 
 
436ada0
3a12290
 
 
436ada0
3a12290
 
 
 
 
 
 
 
 
 
 
 
 
03e2430
415ac43
 
 
 
 
 
03e2430
 
 
 
 
 
 
 
 
04b4cff
 
 
 
c1f2130
 
8058fce
c1f2130
 
 
 
 
415ac43
 
 
 
bca888a
 
 
 
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
104
105
106
import type { BackendManifestStatus, ComparisonIndex, CorpusAggregates, EvalHierarchy } from "@/lib/backend-artifacts"
import type { BenchmarkEvaluationCardData } from "@/components/benchmark-evaluation-card"
import type { HFEvalDetail } from "@/lib/hf-data"
import type {
  BenchmarkCard,
  BenchmarkEvalListItem,
  BenchmarkEvalSummary,
  ModelEvaluationSummary,
} from "@/lib/eval-processing"

export interface EvalListResponse {
  evals: BenchmarkEvalListItem[]
  totalModels: number
}

export interface DeveloperListItem {
  developer: string
  route_id: string
  model_count: number
  benchmark_count: number
  evaluation_count: number
  popular_evals: Array<{
    benchmark: string
    model_count: number
  }>
}

export interface DeveloperSummaryResponse {
  developer: string
  route_id: string
  model_count: number
  benchmark_count: number
  evaluation_count: number
  popular_evals: Array<{
    benchmark: string
    model_count: number
  }>
  models: BenchmarkEvaluationCardData[]
}

async function fetchJson<T>(input: string): Promise<T> {
  const response = await fetch(input)

  if (!response.ok) {
    throw new Error(`Request failed: ${response.status}`)
  }

  return response.json() as Promise<T>
}

export function fetchModelCards() {
  return fetchJson<BenchmarkEvaluationCardData[]>("/api/model-cards-lite")
}

export function fetchEvalList() {
  return fetchJson<EvalListResponse>("/api/eval-list-lite")
}

export function fetchModelSummary(modelId: string) {
  return fetchJson<ModelEvaluationSummary>(
    `/api/model-summary?id=${encodeURIComponent(modelId)}`
  )
}

export function fetchEvalSummary(evalId: string) {
  return fetchJson<BenchmarkEvalSummary>(
    `/api/eval-summary?id=${encodeURIComponent(evalId)}`
  )
}

export function fetchEvalDetail(evalId: string) {
  return fetchJson<HFEvalDetail>(
    `/api/eval-detail?id=${encodeURIComponent(evalId)}`
  )
}

export function fetchDevelopers() {
  return fetchJson<DeveloperListItem[]>("/api/developers")
}

export function fetchDeveloperSummary(developerId: string) {
  return fetchJson<DeveloperSummaryResponse>(
    `/api/developer-summary?id=${encodeURIComponent(developerId)}`
  )
}

export function fetchBenchmarkMetadata() {
  return fetchJson<Record<string, BenchmarkCard>>("/api/benchmark-metadata")
}

export function fetchBackendManifest() {
  return fetchJson<BackendManifestStatus>("/api/backend-manifest")
}

export function fetchEvalHierarchy() {
  return fetchJson<EvalHierarchy>("/api/eval-hierarchy")
}

export function fetchComparisonIndex() {
  return fetchJson<ComparisonIndex>("/api/comparison-index")
}

export function fetchCorpusAggregates() {
  return fetchJson<CorpusAggregates>("/api/corpus-aggregates")
}