HTML 77.2%
TypeScript 10.5%
Python 9.6%
JavaScript 2.5%
1import { cn } from '@/lib/cn';2import type { Comparability, IdentityConfidence } from '@/lib/types';3import { COMPARABILITY_LABEL, IDENTITY_LABEL, opennessLabel, TRUST_LONG, trustShort } from './shared';45const base = 'inline-flex items-center gap-1 whitespace-nowrap rounded-[3px] px-1.5 py-[1px] text-[11px] font-medium leading-4 tracking-wide';67const TRUST_CLS: Record<string, string> = {8 'official-benchmark': 'text-tier-1 bg-positive-soft',9 'peer-reviewed': 'text-tier-1 bg-positive-soft',10 'independent-evaluator': 'text-tier-2 bg-accent-soft',11 'official-model-card': 'text-tier-3 bg-warning-soft',12 community: 'text-tier-3 bg-warning-soft',13 unverified: 'text-tier-4 bg-surface-2',14};15/** Trust level of a benchmark row (who produced the score). */16export function TrustBadge({ level, label, className }: { level: string | null | undefined; label?: string | null; className?: string }) {17 if (!level) return null;18 return (19 <span className={cn(base, TRUST_CLS[level] ?? 'text-ink-2 bg-surface-2', className)} title={label ?? TRUST_LONG[level] ?? level}>20 {trustShort(level, label)}21 </span>22 );23}2425const COMP_CLS: Record<Comparability, string> = { comparable: 'text-positive bg-positive-soft', 'partially-comparable': 'text-warning bg-warning-soft', 'not-comparable': 'text-danger bg-danger-soft' };26/** Comparability of a row vs the group leader (or of a compare dimension). `reasons` go in the title. */27export function ComparabilityBadge({ level, reasons, className, short = false }: { level: Comparability | string | null | undefined; reasons?: string[]; className?: string; short?: boolean }) {28 if (!level) return null;29 const l = level as Comparability;30 const text = COMPARABILITY_LABEL[l] ?? level;31 return (32 <span className={cn(base, COMP_CLS[l] ?? 'text-ink-2 bg-surface-2', className)} title={reasons?.length ? reasons.join('; ') : text}>33 {short ? text.replace('Partially comparable', 'Partial').replace('Not comparable', 'Not comp.') : text}34 </span>35 );36}3738const ID_CLS: Record<IdentityConfidence, string> = { high: 'text-positive bg-positive-soft', medium: 'text-warning bg-warning-soft', low: 'text-danger bg-danger-soft' };39/** identity_confidence of a model row: how sure AI Atlas is that this entry is one real model release. */40export function IdentityBadge({ level, className, hideHigh = true }: { level: IdentityConfidence | string | null | undefined; className?: string; hideHigh?: boolean }) {41 if (!level || (hideHigh && level === 'high')) return null;42 const l = level as IdentityConfidence;43 return (44 <span className={cn(base, ID_CLS[l] ?? 'text-ink-2 bg-surface-2', className)} title="identity_confidence: how sure AI Atlas is that this entry is one real model release">45 {IDENTITY_LABEL[l] ?? level}46 </span>47 );48}4950/** Artifact kind chip (checkpoint · quantization · conversion · packaging). */51export function ArtifactKindChip({ kind, className }: { kind: string | null | undefined; className?: string }) {52 if (!kind) return null;53 return <span className={cn(base, 'bg-surface-2 uppercase text-ink-2', className)}>{kind}</span>;54}5556/** Small config chip; task keys read stronger than condition keys. */57export function ConfigChipEl({ k, v, kind, className }: { k: string; v: string; kind: 'task' | 'condition' | 'other'; className?: string }) {58 return (59 <span className={cn('mono inline-flex max-w-[14rem] items-center gap-1 truncate rounded-[3px] px-1 text-[10.5px] leading-4', kind === 'task' ? 'bg-surface-3 text-ink-2' : 'bg-surface-2 text-ink-3', className)} title={`${k}=${v}${kind === 'task' ? ' (task-defining)' : kind === 'condition' ? ' (condition — partially comparable)' : ''}`}>60 <span className="opacity-70">{k}</span>61 <span className="truncate text-ink-2">{v}</span>62 </span>63 );64}6566/** Yes / No / — (unknown) for licence and openness dimensions. */67export function Tri({ v, yes = 'Yes', no = 'No' }: { v: boolean | null | undefined; yes?: string; no?: string }) {68 if (v === true) return <span className="font-medium text-positive">{yes}</span>;69 if (v === false) return <span className="text-ink-2">{no}</span>;70 return (71 <span className="text-ink-3" title="Unknown — the source or licence text is ambiguous, not false">72 —73 </span>74 );75}7677const OPEN_CLS: Record<string, string> = { 'open-source': 'text-positive bg-positive-soft', 'open-weights': 'text-positive bg-positive-soft', 'restricted-weights': 'text-warning bg-warning-soft', restricted: 'text-warning bg-warning-soft', proprietary: 'text-ink-2 bg-surface-2', unknown: 'text-ink-3 bg-surface-2' };78/** Openness chip with the 1.1 ontology labels (Open source · Open weights · Restricted weights · Closed). */79export function OpennessChip({ openness, label, className }: { openness: string | null | undefined; label?: string | null; className?: string }) {80 if (!openness) return null;81 return <span className={cn(base, OPEN_CLS[openness] ?? 'text-ink-2 bg-surface-2', className)}>{label ?? opennessLabel(openness)}</span>;82}83