Generation Stats
Metric pills for an assistant turn — token count, throughput (tok/s) and latency, data-driven with i18n unit labels.
A row of small metric pills for an assistant turn — output token count, throughput (tokens/second) and latency. It's purely presentational and data-driven: pass the numbers you have and it renders only those, in a compact bg-muted pill row that matches the rest of the chat chrome. When there's no data at all, it renders nothing.
Throughput is derived from tokens + latencyMs when you don't pass tokensPerSecond explicitly. Unit labels are configurable (labels) so the component carries no copy of its own — the defaults are English (tokens / tok/s / ms).
Import
1import { GenerationStats } from "@yuhuanowo/yunui/chat";Example
The first row passes tokens + latencyMs (throughput is derived); the second overrides the labels for a localized look and passes an explicit tokensPerSecond.
GenerationStats
Usage
1<GenerationStats2 tokens={message.tokens?.output}3 latencyMs={message.latencyMs}4 labels={{ tokens: t("tokens"), speed: t("tokensPerSecond"), latency: t("ms") }}5/>Pair it with the assistant name/model chip in a ChatMessage badges slot, and with
ThinkingBlock (isStreaming renders the "thinking…" state) for
the reasoning indicator.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | |
| labels | { tokens?: string; speed?: string; latency?: string | undefined; } | undefined | — | Localized unit labels — components carry no copy of their own. |
| latencyMs | number | — | Total generation latency in milliseconds. |
| tokens | number | — | Output token count (e.g. `completion_tokens` from an OpenAI-style usage). |
| tokensPerSecond | number | — | Throughput in tokens/second. If omitted but `tokens` + `latencyMs` are given, it's derived as `tokens / (latencyMs / 1000)`. |