import { ExternalLink } from 'lucide-react'; import { ScrollX } from '@/components/models/scroll-x'; import Link from 'next/link'; import { Evidence } from '@/components/evidence/evidence'; import { ComparabilityBadge, ConfigChipEl, TrustBadge } from '@/components/models/badges'; import { configChipsOf, fmtScoreUnit, scoreDelta } from '@/components/models/shared'; import { Estimated } from '@/components/ui/badges'; import { DataTable, Td, Th } from '@/components/ui/data-table'; import { EntityLink } from '@/components/ui/entity'; import { Hint } from '@/components/ui/hint'; import { SourceCell } from '@/components/ui/provenance'; import { Note } from '@/components/ui/section'; import { EmptyState } from '@/components/ui/unavailable'; import { cn } from '@/lib/cn'; import { DASH, fmtAgo, fmtDate, fmtGb, fmtInt, fmtTokens, fmtUsdPerM, fmtValue, hostOf, num } from '@/lib/format'; import { propertyLabel, routes } from '@/lib/site'; import type { BenchmarkListItem, Deployment, HardwareFitRow, ModelDetail, ProvenanceEntry, VersionHistoryItem } from '@/lib/types'; /* ------------------------------------------------------------------------------------------------------ identity panel */ /** Canonical model · official checkpoints · third-party artifacts (by kind) · provider deployments · API aliases · folded variants. */ export function IdentityPanel({ d }: { d: ModelDetail }) { const id = d.identity; const kinds = d.artifacts?.items ?? []; if (!id) return

Identity block not returned by the API for this entity.

; // The definition hint sits at the far right of the value cell (right-aligned bubble): in the narrow label column the 18rem bubble would widen the page. const Row = ({ k, hint, children }: { k: string; hint?: string; children: React.ReactNode }) => (
{k}
{children} {hint && }
); return (
{id.canonical_model ? 'Yes' : 'No'} {d.identity_confidence && identity confidence: {d.identity_confidence}} {id.official_checkpoints.length ? ( ) : ( None recorded{d.openness?.category === 'proprietary' ? ' — closed weights' : ''} )} {kinds.length ? ( {kinds.map((k) => ( {fmtInt(k.count)} {k.kind} {k.count === 1 ? '' : 's'} ))} {fmtInt(id.official_artifacts)} official · {fmtInt(id.third_party_artifacts)} third-party ) : ( None recorded )} {id.provider_deployments ? ( {fmtInt(id.provider_deployments)} ) : ( None recorded )} {id.api_aliases.length ? {id.api_aliases.map((a) => {a})} : None} {fmtInt(id.folded_variants)}
); } /* ------------------------------------------------------------------------------------------------------ deployments */ export function DeploymentsTable({ deployments, modelSlug }: { deployments: Deployment[]; modelSlug: string }) { if (!deployments.length) return Deployments appear when a provider's public pricing or model listing is crawled.; const rows = [...deployments].sort((a, b) => (num(a.prices.output) ?? Infinity) - (num(b.prices.output) ?? Infinity) || (num(a.prices.input) ?? Infinity) - (num(b.prices.input) ?? Infinity)); const has = (k: keyof Deployment['prices']) => rows.some((r) => num(r.prices[k]) !== null); const showCached = has('cached_input'); const showWrite = has('cache_write'); const showBatch = has('batch_input') || has('batch_output'); const showNative = rows.some((r) => Object.keys(r.prices.native_units ?? {}).length > 0); const showImage = has('per_image') || has('per_request'); const delisted = rows.filter((r) => r.status === 'delisted').length; return ( <> Provider Context Input / 1M {showCached && Cached in} {showWrite && Cache write} Output / 1M {showBatch && Batch in / out} {showImage && Per image / request} {showNative && Native units} Status Observed Source {rows.map((r, i) => { const native = Object.entries(r.prices.native_units ?? {}); const evidence = (k: string, v: unknown, display: string) => ( {display} ); return ( {i === 0 && r.status === 'active' && num(r.prices.output) !== null && cheapest output} {r.provider_model_id && {r.provider_model_id}} {num(r.context_length) === null ? DASH : fmtTokens(r.context_length)} {num(r.max_output_tokens) !== null && out {fmtTokens(r.max_output_tokens)}} {num(r.prices.input) === null ? DASH : evidence('input_per_mtok', r.prices.input, fmtUsdPerM(r.prices.input))} {showCached && ( {fmtUsdPerM(r.prices.cached_input)} )} {showWrite && ( {fmtUsdPerM(r.prices.cache_write)} )} {num(r.prices.output) === null ? DASH : evidence('output_per_mtok', r.prices.output, fmtUsdPerM(r.prices.output))} {showBatch && ( {num(r.prices.batch_input) === null && num(r.prices.batch_output) === null ? DASH : `${fmtUsdPerM(r.prices.batch_input)} / ${fmtUsdPerM(r.prices.batch_output)}`} )} {showImage && ( {num(r.prices.per_image) === null && num(r.prices.per_request) === null ? DASH : `${num(r.prices.per_image) === null ? DASH : `$${fmtValue(num(r.prices.per_image))}`} / ${num(r.prices.per_request) === null ? DASH : `$${fmtValue(num(r.prices.per_request))}`}`} )} {showNative && ( {native.length ? ( `${k}=${String(v)}`).join('\n')}> {native.slice(0, 3).map(([k, v]) => ( {k}={typeof v === 'object' ? JSON.stringify(v) : String(v)} ))} {native.length > 3 && +{native.length - 3}} ) : ( DASH )} )} {r.status} {r.valid_to && until {fmtDate(r.valid_to)}} {fmtAgo(r.observed_at)} since {fmtDate(r.valid_from)} ); })} {rows[0]?.prices.unit ?? 'USD per 1M tokens'} as published by each provider; native units (per-request fees, flex/priority tiers) are kept verbatim. Rows are append-only — every price change is kept in the history below. {delisted > 0 && ` ${fmtInt(delisted)} delisted deployment${delisted === 1 ? '' : 's'} shown greyed.`} Cost of a workload → ); } /* ------------------------------------------------------------------------------------------------------ version history */ function fmtVersionValue(property: string, v: unknown): string { if (v === null || v === undefined) return 'unknown'; if (/context_length|max_output_tokens/.test(property)) return `${fmtTokens(v)}`; return fmtValue(v, property); } /** property → "128K → 200K → 1M" with dates; every hop is an evidence trigger (claim id, source, tier). */ export function VersionHistoryBlock({ items, d }: { items: VersionHistoryItem[]; d: ModelDetail }) { const shown = items.filter((v) => v.transitions.length > 0); if (!shown.length) return

No versioned property recorded yet.

; const sorted = [...shown].sort((a, b) => b.transitions.length - a.transitions.length || a.property.localeCompare(b.property)); return (
{sorted.map((v) => { const first = v.transitions[0]; const chain = [first?.from ?? null, ...v.transitions.map((t) => t.to)]; const changes = v.transitions.filter((t) => t.from !== null && t.from !== undefined).length; return (

{propertyLabel(v.property)} {changes ? `${fmtInt(changes)} change${changes === 1 ? '' : 's'}` : 'first observation only'}

{chain.map((val, i) => { const t = i === 0 ? null : v.transitions[i - 1]; const isLast = i === chain.length - 1; const text = fmtVersionValue(v.property, val); if (!t) return val === null || val === undefined ? null : {text}; const fallback: ProvenanceEntry = { source_id: null, source_name: hostOf(t.source_url) ?? undefined, url: t.source_url, observed_at: t.valid_from, tier: t.tier, confidence: t.status === 'conflicting' ? 'conflicted' : 'high', extractor: 'deterministic' }; return ( {(i > 1 || (chain[0] !== null && chain[0] !== undefined)) && →} {text} {fmtDate(t.effective_at ?? t.valid_from)} ); })} {v.transitions[v.transitions.length - 1]?.valid_to === null && current}

); })} Each hop is a claim: click a value for its source, tier and observation time. Nothing is overwritten — a new observation closes the previous claim.
); } /* ------------------------------------------------------------------------------------------------------ benchmarks grouped */ /** Benchmark → metric / comparability group → best current row (trust, comparability note, n results, vs leader, leaderboard link). */ export function ModelBenchmarksBlock({ d, leaders }: { d: ModelDetail; leaders: BenchmarkListItem[] | null }) { const b = d.benchmarks; if (!b || !b.items.length) return Results appear when a tier 1–3 source publishes them; we never copy scores without a source.; const leaderMap = new Map(); for (const l of leaders ?? []) leaderMap.set(l.slug, l); const items = [...b.items].sort((x, y) => (x.category ?? '').localeCompare(y.category ?? '') || x.name.localeCompare(y.name)); const rows: React.ReactNode[] = []; for (const bm of items) { const li = leaderMap.get(bm.slug); for (const m of bm.metrics) { for (const g of m.groups) { const isPrimary = li?.primary_group?.config_key === g.config_key && li?.primary_group?.metric === m.metric; const leader = isPrimary ? li?.leader : null; const leaderIsSelf = leader?.model.slug === d.slug; const delta = leader && !leaderIsSelf ? scoreDelta(g.best.score, leader.score, g.best.unit) : null; const chips = configChipsOf(g.best.config, null, 4); const conditions = chips.filter((c) => c.kind === 'condition'); rows.push( {bm.name} {bm.category ?? ''} {bm.category ? ' · ' : ''} {g.comparability_group} {fmtScoreUnit(g.best.score, g.best.unit)} {!g.higher_is_better && lower is better} {chips.length ? chips.map((c) => ) : {DASH}} {conditions.length > 0 && conditions differ across rows → partially comparable} {fmtInt(g.n_rows)} {leaderIsSelf ? ( current leader ) : leader ? ( {delta} vs {leader.model.name} ) : ( {isPrimary ? DASH : 'non-primary group'} )} {g.best.evaluated_at ? fmtDate(g.best.evaluated_at) : obs. {fmtDate(g.best.observed_at)}} , ); } } } return ( <> Benchmark · group Best score Trust Configuration Results vs leader Evaluated Source {rows} {b.note ?? 'Current rows only, grouped by benchmark → canonical metric → comparability group.'} {fmtInt(b.total_rows)} current rows in total. “vs leader” compares with the current leader of the benchmark's primary group only; other groups are not directly comparable. Comparability rules → ); } /* ------------------------------------------------------------------------------------------------------ hardware fit */ export function HardwareFitBlock({ rows, assumptions, modelSlug }: { rows: HardwareFitRow[]; assumptions?: string[]; modelSlug: string }) { if (!rows.length) return Estimates need a parameter count; this model has none recorded from a source.; const sorted = [...rows].sort((a, b) => Number(b.fits) - Number(a.fits) || (num(a.hardware.attributes?.memory_gb) ?? 0) - (num(b.hardware.attributes?.memory_gb) ?? 0)); const fits = sorted.filter((r) => r.fits).length; return ( <>

{fmtInt(fits)} of {fmtInt(sorted.length)} device × quantization combinations fit.

Run locally: your machine →
Hardware Quantization Device memory Est. memory Fits {sorted.map((r, i) => ( {r.quantization} {fmtGb(r.hardware.attributes?.memory_gb as never)} {fmtGb(r.estimated_memory_gb, 1)} est. {r.fits ? 'Yes' : 'No'} ))} {assumptions && assumptions.length > 0 && (
Assumptions ({assumptions.length})
    {assumptions.map((a) => (
  • {a}
  • ))}
)} ); } /* ------------------------------------------------------------------------------------------------------ artifacts */ export function ArtifactsBlock({ d }: { d: ModelDetail }) { const groups = d.artifacts?.items ?? []; if (!groups.length) return

No artifact (checkpoint, quantisation, conversion or packaging) points to this model yet.

; return (
{groups.map((g) => (

{g.kind} {g.count === 1 ? '' : 's'} {fmtInt(g.count)}

    {g.items.map((a) => { const at = a.attributes ?? {}; return (
  • {a.name} {a.organization?.name ?? ''} {typeof at.quant_format === 'string' ? ` · ${String(at.quant_format).toUpperCase()}` : ''} {Array.isArray(at.weights_dtype) && at.weights_dtype.length ? ` · ${(at.weights_dtype as string[]).join('/')}` : ''} {num(at['metric.downloads']) !== null ? ` · ${fmtInt(at['metric.downloads'])} downloads` : ''} {num(at.file_size_gb) !== null ? fmtGb(at.file_size_gb, 1) : DASH}
  • ); })} {g.count > g.items.length &&
  • +{fmtInt(g.count - g.items.length)} more — see the graph.
  • }
))}
); } /* ------------------------------------------------------------------------------------------------------ comparability legend (reused) */ export function ComparabilityLegend() { return (

same task and conditions · same task, conditions differ (effort, temperature, judge) · different variant or metric

); }