/** * llmindex.io — interactive live Pareto frontier chart (full-page, SVG) * Author: Simon-Pierre Boucher * Contact: contact@spboucher.ai * License: Proprietary — © Simon-Pierre Boucher, all rights reserved * * Form: scatter + Pareto step line (quality vs log-cost). Color encodes the * two-class identity frontier/dominated — palette #047857/#7c3aed validated * (lightness band, chroma, CVD ΔE 23.9 deutan, normal-vision ΔE 32, contrast). * Provider identity rides on labels/tooltips/logos, never on hue cycling. * CI whiskers on every point; frontier points carry direct labels; per-mark * hover tooltips with enlarged hit targets; polls fresh data every 15 s and * animates newly landed models in. */ 'use client'; import { useEffect, useMemo, useRef, useState } from 'react'; import { useRouter } from 'next/navigation'; import { ProviderLogo } from './ProviderLogo'; export interface FrontierPoint { model: string; name: string; provider: string; score: number; score_low: number; score_high: number; latency_p50: number | null; cost_per_1k_items: number; on_frontier: boolean; } const FRONTIER = '#047857'; const DOMINATED = '#7c3aed'; const INK = '#3f3f46'; const INK_MUTED = '#a1a1aa'; const GRID = '#e4e4e7'; const POLL_MS = 15000; const W = 1280; const H = 720; const M = { top: 28, right: 48, bottom: 64, left: 72 }; const IW = W - M.left - M.right; const IH = H - M.top - M.bottom; function fmtCost(v: number): string { if (v >= 100) return `$${Math.round(v)}`; if (v >= 1) return `$${v.toFixed(v >= 10 ? 0 : 1)}`; if (v >= 0.01) return `$${v.toFixed(2)}`; return `$${v.toFixed(3)}`; } export function FrontierChart({ initial }: { initial: FrontierPoint[] }) { const router = useRouter(); const [points, setPoints] = useState(initial); const [hover, setHover] = useState(null); const [fresh, setFresh] = useState>(new Set()); const [updatedAt, setUpdatedAt] = useState(null); const knownRef = useRef>(new Set(initial.map((p) => p.model))); useEffect(() => { let cancelled = false; async function tick() { try { const res = await fetch('/api/v1/efficiency', { cache: 'no-store' }); if (!res.ok || cancelled) return; const body = (await res.json()) as { points: FrontierPoint[] }; if (!body.points) return; const newcomers = body.points.map((p) => p.model).filter((m) => !knownRef.current.has(m)); if (newcomers.length > 0) { setFresh(new Set(newcomers)); newcomers.forEach((m) => knownRef.current.add(m)); setTimeout(() => setFresh(new Set()), 5000); } setPoints(body.points); setUpdatedAt(new Date()); } catch { /* keep last state */ } } const id = setInterval(tick, POLL_MS); tick(); return () => { cancelled = true; clearInterval(id); }; }, []); const view = useMemo(() => { if (points.length === 0) return null; const costs = points.map((p) => p.cost_per_1k_items).filter((c) => c > 0); const minC = Math.min(...costs); const maxC = Math.max(...costs); const lo = Math.floor(Math.log10(minC) - 0.15); const hi = Math.ceil(Math.log10(maxC) + 0.15); const yMin = Math.max(0, Math.floor((Math.min(...points.map((p) => p.score_low)) - 50) / 100) * 100); const yMax = Math.min(1000, Math.ceil((Math.max(...points.map((p) => p.score_high)) + 50) / 100) * 100); const x = (c: number): number => M.left + ((Math.log10(c) - lo) / (hi - lo)) * IW; const y = (s: number): number => M.top + (1 - (s - yMin) / (yMax - yMin)) * IH; const xTicks: Array<{ v: number; major: boolean }> = []; for (let d = lo; d <= hi; d++) { xTicks.push({ v: 10 ** d, major: true }); for (const m of [2, 5]) { const v = m * 10 ** d; if (Math.log10(v) < hi) xTicks.push({ v, major: false }); } } const yTicks: number[] = []; for (let s = yMin; s <= yMax; s += 100) yTicks.push(s); // Pareto step polyline (const-right steps in cost order). const front = points.filter((p) => p.on_frontier).sort((a, b) => a.cost_per_1k_items - b.cost_per_1k_items); let path = ''; front.forEach((p, i) => { const px = x(p.cost_per_1k_items); const py = y(p.score); if (i === 0) path += `M ${px} ${py}`; else path += ` L ${px} ${y(front[i - 1]!.score)} L ${px} ${py}`; }); if (front.length > 0) { path += ` L ${M.left + IW} ${y(front[front.length - 1]!.score)}`; } // Direct labels on frontier points, nudged apart vertically when close. const labels = front.map((p) => ({ p, lx: x(p.cost_per_1k_items) + 12, ly: y(p.score) - 10 })); for (let i = 1; i < labels.length; i++) { const prev = labels[i - 1]!; const cur = labels[i]!; if (Math.abs(cur.ly - prev.ly) < 16 && cur.lx - prev.lx < 130) cur.ly = prev.ly - 16; } return { x, y, xTicks, yTicks, path, labels, yMin, yMax }; }, [points]); if (!view || points.length === 0) { return (
Waiting for the first scored models — the chart populates automatically as the live benchmark lands them.
); } const shortName = (slug: string): string => slug.split('/')[1] ?? slug; return (
{/* legend + live status — one row above the chart */}
Pareto frontier ({points.filter((p) => p.on_frontier).length}) dominated ({points.filter((p) => !p.on_frontier).length}) 95% CI live · {points.length} models{updatedAt ? ` · updated ${updatedAt.toLocaleTimeString()}` : ''}
{/* grid */} {view.yTicks.map((s) => ( ))} {view.xTicks.filter((t) => t.major).map((t) => ( ))} {/* axes labels */} {view.yTicks.map((s) => ( {s} ))} {view.xTicks.map((t) => ( {fmtCost(t.v)} ))} cost per 1,000 items (USD, log scale) → Global Index → {/* frontier step line */} {/* CI whiskers */} {points.map((p) => { const px = view.x(p.cost_per_1k_items); const color = p.on_frontier ? FRONTIER : DOMINATED; return ( ); })} {/* dots (2px surface ring separates overlapping marks) */} {points.map((p) => ( ))} {/* selective direct labels: frontier only */} {view.labels.map(({ p, lx, ly }) => ( {shortName(p.model)} ))} {/* enlarged invisible hit targets */} {points.map((p) => ( setHover(p)} onMouseLeave={() => setHover(null)} onClick={() => router.push(`/models/${p.model}`)} /> ))} {/* hover ring */} {hover && ( )} {/* tooltip */} {hover && (
{hover.name}
Global Index {hover.score} [{hover.score_low}–{hover.score_high}] Cost / 1k items {fmtCost(hover.cost_per_1k_items)} Latency p50 {hover.latency_p50 != null ? `${(hover.latency_p50 / 1000).toFixed(1)}s` : '—'} Status {hover.on_frontier ? ( frontier ) : ( dominated )}

click to open the model page

)}
); }