import type { Metadata } from 'next'; import Link from 'next/link'; import { CompareButton } from '@/components/compare/compare-button'; import { CompareTrayBar } from '@/components/compare/compare-tray-bar'; import { QUANTS } from '@/components/hardware/fit-form'; import { FINDER_USE_CASES, FinderForm, type FinderInputs, MODALITIES } from '@/components/intelligence/finder-form'; import { FitCell, Methodology, RankChips } from '@/components/intelligence/bits'; import { TerminalLayout } from '@/components/layout/terminal'; import { Chip, Estimated, OpennessBadge } from '@/components/ui/badges'; import { DataTable, EmptyRow, Td, Th } from '@/components/ui/data-table'; import { EntityLink } from '@/components/ui/entity'; import { Note, PageHeader } from '@/components/ui/section'; import { EmptyState, Unavailable } from '@/components/ui/unavailable'; import { WatchButton } from '@/components/watchlist/watch-button'; import { ApiError, intel, safe } from '@/lib/api'; import { fmtDate, fmtInt, fmtParams, fmtTokens, fmtUsdPerM, num } from '@/lib/format'; import { routes, SITE_NAME, SITE_URL } from '@/lib/site'; import type { FinderPayload } from '@/lib/types'; export const revalidate = 300; type SP = Record; const one = (v: string | string[] | undefined) => (Array.isArray(v) ? v[0] : v); function parse(sp: SP): FinderInputs { const custom = num(one(sp.memory_custom)); const preset = num(one(sp.memory_gb)); const mods = (Array.isArray(sp.mod) ? sp.mod : sp.mod ? [sp.mod] : one(sp.modalities)?.split(',') ?? []).filter((m) => MODALITIES.includes(m)); const dep = one(sp.deployment); const lic = one(sp.license); return { useCase: FINDER_USE_CASES.some((u) => u.value === one(sp.use_case)) ? (one(sp.use_case) as string) : '', deployment: dep === 'local' || dep === 'api' ? dep : 'any', memory: custom !== null && custom > 0 ? custom : preset !== null && preset > 0 ? preset : null, quant: QUANTS.some((q) => q.value === one(sp.quant)) ? (one(sp.quant) as string) : '4bit', contextMin: num(one(sp.context_min)), license: lic === 'commercial' ? 'commercial' : 'any', openness: ['open-source', 'open-weights', 'restricted-weights', 'proprietary'].includes(one(sp.openness) ?? '') ? (one(sp.openness) as string) : '', maxIn: num(one(sp.max_input_price)), maxOut: num(one(sp.max_output_price)), modalities: mods, }; } const active = (v: FinderInputs) => [v.useCase, v.deployment !== 'any', v.memory, v.contextMin, v.license !== 'any', v.openness, v.maxIn, v.maxOut, v.modalities.length].filter(Boolean).length; const TITLE = 'Find a model — guided search over observed dimensions'; const DESC = 'Tell the atlas what you need — use case, local or API deployment, memory, licence, openness, context, price ceiling, modalities — and it lists the canonical models that satisfy the criteria, with the reasons, their observed dimensions, an estimated local fit and current deployments. Deterministic rules, no composite score, no single winner.'; export async function generateMetadata({ searchParams }: { searchParams: Promise }): Promise { const v = parse(await searchParams); const n = active(v); const title = n ? `Models for ${[FINDER_USE_CASES.find((u) => u.value === v.useCase)?.label, v.deployment !== 'any' ? v.deployment : null, v.memory ? `${v.memory} GB` : null].filter(Boolean).join(' · ') || 'your criteria'}` : TITLE; return { title, description: DESC, alternates: { canonical: routes.findAModel() }, openGraph: { title: `${title} | ${SITE_NAME}`, description: DESC, url: `${SITE_URL}${routes.findAModel()}`, siteName: SITE_NAME }, robots: n ? { index: false, follow: true } : undefined }; } export default async function FindAModelPage({ searchParams }: { searchParams: Promise }) { const sp = await searchParams; const v = parse(sp); const n = active(v); let res: FinderPayload | null = null; let error: string | null = null; if (n > 0) { try { res = await intel.findAModel({ use_case: v.useCase || undefined, deployment: v.deployment, memory_gb: v.memory ?? undefined, quant: v.deployment === 'local' || v.memory ? v.quant : undefined, context_min: v.contextMin ?? undefined, license: v.license, openness: v.openness || undefined, max_input_price: v.maxIn ?? undefined, max_output_price: v.maxOut ?? undefined, modalities: v.modalities.length ? v.modalities.join(',') : undefined, limit: 40 }); } catch (e) { error = e instanceof ApiError ? e.detail ?? e.message : 'API unreachable'; } } const rules = res?.rules ?? (await safe(intel.methodology()))?.find_a_model ?? null; const rulesObj = rules && typeof rules === 'object' ? (rules as Record) : null; const apiMode = v.deployment === 'api'; const localMode = v.deployment === 'local' || v.memory !== null; const inspector = (

Rules (deterministic)

{rulesObj ? (
{Object.entries(rulesObj).map(([k, r]) => (
{k}
{r}
))}
) : (

Rules unavailable from the API.

)}

/methodology · GET /find-a-model

); return ( } inspector={inspector} filtersTitle="What do you need?" inspectorTitle="Rules" storageKey="aia-inspector-finder" filterCount={n}>
{n === 0 ? ( Examples: coding · local · 64 GB, vision · API · output ≤ $5, 1M context · commercial licence. ) : !res ? ( ) : ( <>

{fmtInt(res.total)} model{res.total === 1 ? '' : 's'} satisfy {res.matches[0]?.why.length ? 'at least one of' : ''} the criteria No single winner — these are the observed dimensions; the order is criteria met → best rank → release date.

{Object.entries(res.filters_applied).map(([k, val]) => ( {k.replace(/_/g, ' ')} {String(val)} ))}

{res.matches.length === 0 ? ( Relax a bound (price, memory, context) or drop a modality. Every rule is listed in the Rules pane. ) : ( Model Why Observed dimensions {localMode && ( Fit )} {apiMode && Deployments} Ranks {res.matches.length === 0 && } {res.matches.map((m) => { const o = m.observed ?? {}; const mods = Array.isArray(o.modalities) ? (o.modalities as string[]) : []; return ( {typeof o.openness === 'string' && } {m.model.organization && {m.model.organization.name}}
    {m.why.map((w) => (
  • {w}
  • ))} {m.why.length === 0 &&
  • —
  • }
{[ num(o.parameter_count) !== null ? `${fmtParams(o.parameter_count)} params` : null, num(o.context_length) !== null ? `${fmtTokens(o.context_length)} context` : null, typeof o.license === 'string' ? o.license : null, mods.length ? mods.join(' · ') : null, o.reasoning === true ? 'reasoning' : null, o.tool_calling === true ? 'tool calling' : null, typeof o.release_date === 'string' ? `released ${fmtDate(o.release_date)}` : null, num(o.cheapest_input_per_mtok) !== null ? `from ${fmtUsdPerM(o.cheapest_input_per_mtok)} in / ${fmtUsdPerM(o.cheapest_output_per_mtok)} out` : null, num(o.providers) !== null ? `${fmtInt(o.providers)} provider${num(o.providers) === 1 ? '' : 's'}` : null, ] .filter(Boolean) .join(' · ') || '—'} {localMode && ( )} {apiMode && ( {m.deployments && m.deployments.length ? (
    {m.deployments.slice(0, 4).map((d) => (
  • {fmtUsdPerM(d.prices.input)} / {fmtUsdPerM(d.prices.output)}
  • ))} {m.deployments.length > 4 &&
  • +{m.deployments.length - 4} more
  • }
) : ( — )} )} ); })}
)} Green chips = criteria satisfied by an observed fact; dashed amber = satisfied by an estimate (hardware fit). Ranks are positions inside each benchmark's primary comparability group. )}
); }