Token Stream
Text that arrives the way a model writes it, token by token, in real clumps and stalls. Each token lands at full ink and dries to how likely it was.
Needs: Nothing. Real token probabilities (logprobs) or a live stream are optional.
Customize
mode
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | required | The reply, cut into word-piece tokens with seeded, simulated probabilities. Leave it out when you pass tokens or stream. |
| tokens | { text: string; p?: number }[] | – | Real tokens with their probabilities (exp of the logprob). Leading whitespace belongs to the token after it. Wins over text. |
| stream | AsyncIterable<string | { text: string; p?: number }> | – | A live stream. Plain strings are shown at full ink, since nothing says how likely they were. Wins over both. |
| speed | number | 24 | Tokens a second. A live stream is paced to it, and catches up when it falls behind. |
| jitter | number | 0.5 | 0 to 1: how bursty the simulated stream is. 0 is a metronome; real streams clump and stall. |
| inkFloor | number | 0.35 | Ink of the least likely tokens, 0 to 1. |
| mode | "probability" | "plain" | "probability" | "plain" sets every token at full ink, for when probabilities would only distract. |
| caret | boolean | true | A soft caret leading the stream. |
| loop | boolean | false | Start again a moment after finishing. Ignored for a live stream. |
| size | number | string | 32 | Font size in px, or any CSS length such as "clamp(28px, 6vw, 56px)". |
| color | string | "" | Ink colour, any CSS colour. Left unset, the theme's foreground (--mlui-fg), so dark mode just works. |
| caretColor | string | – | Caret colour. The ink colour by default. |
| onDone | () => void | – | Called once the last token has landed, each time round when looping. |
| seed | number | 1 | Seed for the simulated probabilities and timing. |
| className | string | – | Class on the root. |
| style | CSSProperties | – | Inline style on the root. |