YuhuanStudioYunUIDocs
Chat

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

tsx
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

Assistant
zai/glm-5.2
2.57K tokens49.8 tok/s51611 ms
Assistant
840 Token62.4 Token/秒13500 毫秒

Usage

tsx
1<GenerationStats
2 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

PropTypeDefaultDescription
classNamestring
labels{ tokens?: string; speed?: string; latency?: string | undefined; } | undefinedLocalized unit labels — components carry no copy of their own.
latencyMsnumberTotal generation latency in milliseconds.
tokensnumberOutput token count (e.g. `completion_tokens` from an OpenAI-style usage).
tokensPerSecondnumberThroughput in tokens/second. If omitted but `tokens` + `latencyMs` are given, it's derived as `tokens / (latencyMs / 1000)`.

On this page