import Link from 'next/link'; import { cn } from '@/lib/cn'; import type { LicenseInfo, ModelLicence, ModelOpenness } from '@/lib/types'; import { OpennessChip, Tri } from './badges'; /* Openness explanation, reused by model pages and licence pages: "Open weights — weights downloadable under Apache-2.0; code available; training data not disclosed" built from `openness.dimensions`. Unknown dimensions are said to be unknown (null ≠ false). */ export const OPENNESS_DIMENSIONS: { key: string; label: string; yes: string; no: string; hint: string }[] = [ { key: 'weights_available', label: 'Weights', yes: 'weights downloadable', no: 'weights not available', hint: 'Can the model weights be downloaded (Hugging Face or an official mirror)?' }, { key: 'source_code_available', label: 'Inference code', yes: 'inference code available', no: 'inference code not published', hint: 'Is the inference / modelling code published?' }, { key: 'training_code_available', label: 'Training code', yes: 'training code available', no: 'training code not published', hint: 'Is the training code published?' }, { key: 'training_data_disclosed', label: 'Training data', yes: 'training data disclosed', no: 'training data not disclosed', hint: 'Is the composition of the training data documented?' }, { key: 'dataset_available', label: 'Dataset', yes: 'training dataset downloadable', no: 'training dataset not released', hint: 'Can the training dataset itself be downloaded?' }, { key: 'commercial_use_allowed', label: 'Commercial use', yes: 'commercial use allowed', no: 'commercial use restricted', hint: 'Does the licence allow commercial use without a separate agreement?' }, { key: 'redistribution_allowed', label: 'Redistribution', yes: 'redistribution allowed', no: 'redistribution restricted', hint: 'May the weights be redistributed (mirrors, bundles)?' }, { key: 'derivatives_allowed', label: 'Derivatives', yes: 'derivatives allowed', no: 'derivatives restricted', hint: 'May fine-tunes, merges and quantisations be published?' }, ]; export const LICENCE_DIMENSIONS: { key: keyof LicenseInfo; label: string; hint: string; invert?: boolean }[] = [ { key: 'commercial_use', label: 'Commercial use', hint: 'Use in a commercial product or service without a separate agreement.' }, { key: 'redistribution', label: 'Redistribution', hint: 'Sharing the licensed weights or code with third parties.' }, { key: 'derivatives', label: 'Derivatives', hint: 'Publishing fine-tunes, merges, quantisations or other modified versions.' }, { key: 'hosting_restrictions', label: 'Hosting restrictions', hint: 'Restrictions on serving the model as a hosted API (user caps, field-of-use, competitor clauses). Yes = restrictions exist.', invert: true }, { key: 'acceptable_use', label: 'Acceptable-use policy', hint: 'The licence attaches an acceptable-use policy / behavioural restrictions. Yes = a policy applies.', invert: true }, { key: 'attribution', label: 'Attribution', hint: 'Attribution or notice requirements.' }, ]; /** One-line sentence from the dimensions: "weights downloadable under Apache-2.0; inference code available; training data not disclosed". */ export function opennessSentence(o: ModelOpenness, licenceLabel?: string | null): string { const parts: string[] = []; for (const dim of OPENNESS_DIMENSIONS) { const v = o.dimensions?.[dim.key]; if (v === true) parts.push(dim.key === 'weights_available' && licenceLabel ? `${dim.yes} under ${licenceLabel}` : dim.yes); else if (v === false) parts.push(dim.no); } const unknown = OPENNESS_DIMENSIONS.filter((d) => o.dimensions?.[d.key] === null || o.dimensions?.[d.key] === undefined).length; let s = parts.join('; '); if (unknown) s += `${s ? '; ' : ''}${unknown} dimension${unknown === 1 ? '' : 's'} unknown`; return s; } export function OpennessBlock({ openness, licence, className, compact = false }: { openness: ModelOpenness | null | undefined; licence?: ModelLicence | null; className?: string; compact?: boolean }) { if (!openness) return

Openness not classified yet — no sourced evidence to place this model in the ontology.

; const lic = licence && 'key' in licence && licence.key ? (licence as LicenseInfo & { raw?: string | null }) : null; const licLabel = lic ? lic.key : licence && licence.raw ? licence.raw : null; return (

— {opennessSentence(openness, licLabel)}.

{openness.definition}

{!compact && ( )} {(lic || (licence && licence.raw)) && (

Licence:{' '} {lic ? ( <> {lic.label} {' '} ({lic.category} {lic.spdx ? ` · SPDX ${lic.spdx}` : ''} {lic.raw && lic.raw !== lic.key ? ` · stated as “${lic.raw}”` : ''}) ) : ( stated as “{licence?.raw}” — not mapped to a canonical licence yet{licence && 'note' in licence && licence.note ? ` (${licence.note})` : ''} )}

)} {openness.note &&

{openness.note}

}
); }