/** * llmindex.io — live leaderboard: polls scores + benchmark progress, updates in place * Author: Simon-Pierre Boucher * Contact: contact@spboucher.ai * License: Proprietary — © Simon-Pierre Boucher, all rights reserved * * Results appear gradually, one model at a time, as the online benchmark * finishes each model and the IRT refit publishes a new score run. */ 'use client'; import { useEffect, useRef, useState } from 'react'; import Link from 'next/link'; import { DemoBanner, ScoreBar, ScoreValue, formatMs, formatUsd } from '@llmindex/ui'; import { ProviderLogo } from './ProviderLogo'; export interface ApiEntry { rank: number; model: string; name: string; provider: string; score: number; score_low: number; score_high: number; sub_metrics?: Record | null; } export interface ApiRun { id: string; kind: string; status: string; created_at: string; notes?: string | null; } interface Progress { active: boolean; models?: string[]; completed?: string[]; failed?: string[]; current?: { model: string; domain: string; domain_index: number; domains_total: number; calls_done: number; calls_total: number; } | null; currents?: Array>; note?: string; } export interface LiveLeaderboardProps { domain?: string; initialRun: ApiRun | null; initialEntries: ApiEntry[]; indexVersion: string; } const POLL_MS = 5000; function ProgressBanner({ progress }: { progress: Progress }) { const total = progress.models?.length ?? 0; const nDone = progress.completed?.length ?? 0; const nFailed = progress.failed?.length ?? 0; const done = nDone + nFailed; const overallPct = total > 0 ? Math.round((100 * done) / total) : 0; const lanes = progress.currents && progress.currents.length > 0 ? progress.currents : progress.current ? [progress.current] : []; const runningModels = new Set(lanes.map((l) => l.model)).size; const recent = (progress.completed ?? []).slice(-5).reverse(); const remaining = Math.max(0, total - done - runningModels); return (
{/* header */}
Live benchmark {done} /{total} models {nFailed > 0 && {nFailed} failed} {overallPct}%
{/* overall bar */}
{/* active evaluation lanes (parallel) */} {lanes.length > 0 && (
{lanes.map((lane, i) => { const pct = lane.calls_total > 0 ? Math.round((100 * lane.calls_done) / lane.calls_total) : 0; return (
{lane.model.split('/')[1] ?? lane.model} {lane.domain.replaceAll('_', ' ')} {lane.calls_done}/{lane.calls_total}
); })}
)} {/* recent completions + queue count */} {(recent.length > 0 || remaining > 0) && (
{recent.length > 0 && just finished:} {recent.map((m) => ( {m.split('/')[1] ?? m} ))} {remaining > 0 && ( {remaining} in queue )}
)}
); } export function LiveLeaderboard({ domain, initialRun, initialEntries, indexVersion }: LiveLeaderboardProps) { const [entries, setEntries] = useState(initialEntries); const [run, setRun] = useState(initialRun); const [progress, setProgress] = useState({ active: false }); const [fresh, setFresh] = useState>(new Set()); const knownRef = useRef>(new Set(initialEntries.map((e) => e.model))); useEffect(() => { let cancelled = false; async function tick() { try { const base = domain ? `/api/v1/leaderboard/${domain}` : '/api/v1/leaderboard'; const [pRes, lRes] = await Promise.all([ fetch('/api/v1/benchmark/progress', { cache: 'no-store' }), fetch(`${base}?limit=100`, { cache: 'no-store' }), ]); if (cancelled) return; if (pRes.ok) { const p = (await pRes.json()) as { progress: Progress }; setProgress(p.progress ?? { active: false }); } if (lRes.ok) { const body = (await lRes.json()) as { run: ApiRun; entries: ApiEntry[] }; if (body.entries) { const newcomers = body.entries .map((e) => e.model) .filter((slug) => !knownRef.current.has(slug)); if (newcomers.length > 0) { setFresh(new Set(newcomers)); for (const slug of newcomers) knownRef.current.add(slug); setTimeout(() => setFresh(new Set()), 4000); } setEntries(body.entries); setRun(body.run); } } } catch { /* transient poll failure — keep last state */ } } tick(); const id = setInterval(tick, POLL_MS); return () => { cancelled = true; clearInterval(id); }; }, [domain]); const showSub = Boolean(domain); return (
{progress.active && } {run?.kind === 'demo_seed' && }

{domain ? `${domain.replaceAll('_', ' ')} ranking` : 'Global Index'}

{run && ( index v{indexVersion} · run {run.id.slice(0, 8)} ·{' '} {new Date(run.created_at).toISOString().slice(0, 16).replace('T', ' ')} UTC )}
{entries.length === 0 ? (

No scores yet{progress.active ? ' — the live benchmark is warming up; first results appear once two models complete.' : '.'}

) : ( <> {/* Desktop table */}
{showSub && ( <> )} {entries.map((e) => ( {showSub && ( <> )} ))}
# Model Provider Score (95% CI) Consist. Calib. Contam. Δ p50 $/1k
{e.rank} {e.name} {e.provider} {e.sub_metrics?.consistency?.toFixed(2) ?? '—'} {e.sub_metrics?.calibration?.toFixed(2) ?? '—'} {e.sub_metrics?.contamination_delta?.toFixed(3) ?? '—'} {formatMs(e.sub_metrics?.latency_p50)} {formatUsd(e.sub_metrics?.cost_per_1k_items)}
{/* Mobile cards */}
    {entries.map((e) => (
  • #{e.rank} {e.name} {e.provider}
    {showSub && e.sub_metrics && (
    {e.sub_metrics.consistency != null && ( consist {e.sub_metrics.consistency.toFixed(2)} )} {e.sub_metrics.calibration != null && ( calib {e.sub_metrics.calibration.toFixed(2)} )} {e.sub_metrics.contamination_delta != null && ( Δ {e.sub_metrics.contamination_delta.toFixed(3)} )} {e.sub_metrics.latency_p50 != null && ( {formatMs(e.sub_metrics.latency_p50)} )} {e.sub_metrics.cost_per_1k_items != null && ( {formatUsd(e.sub_metrics.cost_per_1k_items)}/1k )}
    )}
  • ))}
)}
); }