| 1 | import { Icon } from "./icon"; |
| 2 | import type { ModelFact } from "@/lib/facts"; |
| 3 | import { MODELS_COPY, groupModelsByMaker, formatModelTokens, formatModelDate } from "@/lib/content/models"; |
| 4 | import { fill, getChrome, pickText } from "@/lib/i18n/dictionaries"; |
| 5 | |
| 6 | export function ModelBadge({ locale }: { locale: string }) { |
| 7 | return <span className="models-reasoning">{pickText(MODELS_COPY.reasoning, locale)}</span>; |
| 8 | } |
| 9 | |
| 10 | export function ModelsCatalog({ models, locale }: { models: ModelFact[]; locale: string }) { |
| 11 | const t = (copy: { en: string; zh: string }) => pickText(copy, locale); |
| 12 | const dateLocale = getChrome(locale).dateLocale; |
| 13 | const groups = groupModelsByMaker(models); |
| 14 | |
| 15 | return ( |
| 16 | <div className="group-card"> |
| 17 | {groups.map((group) => { |
| 18 | const label = group.label || t(MODELS_COPY.otherMakers); |
| 19 | return ( |
| 20 | <details key={group.key} className="disclosure-row"> |
| 21 | <summary> |
| 22 | <span>{label}</span> |
| 23 | <span className="models-count">{fill(t(MODELS_COPY.models), { count: String(group.models.length) })}</span> |
| 24 | <Icon name="chevron-down" className="disclosure-chevron" /> |
| 25 | </summary> |
| 26 | <div className="disclosure-body"> |
| 27 | <div className="data-table-wrap"> |
| 28 | <table className="data-table"> |
| 29 | <thead> |
| 30 | <tr> |
| 31 | <th scope="col">{t(MODELS_COPY.colModel)}</th> |
| 32 | <th scope="col"><span className="sr-only">{t(MODELS_COPY.colKind)}</span></th> |
| 33 | <th scope="col">{t(MODELS_COPY.colContext)}</th> |
| 34 | <th scope="col">{t(MODELS_COPY.colAdded)}</th> |
| 35 | </tr> |
| 36 | </thead> |
| 37 | <tbody> |
| 38 | {group.models.map((model) => ( |
| 39 | <tr key={model.id}> |
| 40 | <th scope="row"> |
| 41 | <code>{model.id}</code> |
| 42 | </th> |
| 43 | <td>{model.reasoning ? <ModelBadge locale={locale} /> : null}</td> |
| 44 | <td className="tabular">{formatModelTokens(model.contextWindow)}</td> |
| 45 | <td className="tabular">{formatModelDate(model.addedAt, dateLocale)}</td> |
| 46 | </tr> |
| 47 | ))} |
| 48 | </tbody> |
| 49 | </table> |
| 50 | </div> |
| 51 | </div> |
| 52 | </details> |
| 53 | ); |
| 54 | })} |
| 55 | </div> |
| 56 | ); |
| 57 | } |
| 58 |