Model Comparison

Two or more outputs side by side with a pick. Columns are equal width and height regardless of content, because a taller box reads as the better answer before a word of it is read.

src/components/ui/model-comparison.tsx

About

From the component's own source, where it was written.

Two or more model outputs side by side, with a pick.

Columns are equal width and equal height regardless of content, so neither answer is visually favoured — a taller box reads as the more substantial one before a word of it is read, which is exactly the bias a comparison is supposed to avoid. Metadata sits in a footer for the same reason: latency and cost are compared after the answers, not before them.

Stacks below the breakpoint, where two columns would be too narrow to read.

Install

npx astralyx-ui add model-comparison

Usage

import { ModelComparison } from '@/components/ui/model-comparison'

<ModelComparison outputs={outputs} onSelect={choose} />

Composer

Change the props and the source below follows.

astralyx-large
Define tokens in an @theme block; utilities are generated from them, so the token and the class that uses it live in one file.
2s148 tokensUS$0.0021
astralyx-small
Tailwind v4 uses CSS for config. Put your theme in @theme.
0s41 tokensUS$0.0003
Props
tsx
<ModelComparison
  outputs={outputs}
  responsive="md"
  onSelect={choose}
/>

Examples

Side by side

API

Generated from the source, so it cannot fall behind the code. One table per exported component, then hooks, functions and types.

ModelComparison

Extends Omit<ComponentProps<'div'>, 'onSelect'>.

PropTypeDefaultDescription
outputsModelOutput[]required{ id, model, output, latency?, tokens?, cost?, badge? }.
selectedstring—Controlled or uncontrolled pick.
onSelect(id: string) => void—Controlled or uncontrolled pick.
responsiveResponsive'md'Breakpoint the columns appear at. Below it they stack, where two columns would be too narrow to read.
pickedLabelReactNode'Picked'Badge on the chosen model.

Types

ModelOutput

Two or more model outputs side by side, with a pick.

FieldTypeDescription
idstring—
modelstring—
outputReactNode—
latency?numberSeconds.
tokens?number—
cost?number—
badge?ReactNode—

Behaviour

TopicDetailDescription
metadatafooterLatency, tokens and cost sit below the answers — compared after them, not before.