Open sourceApache-2.0v1.0.0By Nakshi

Generative UI that stays an answer

GenUI lets a model answer with a component where the content has a shape: steps for a procedure, a chart for a series of numbers, a checklist to tick off. The reply stays Markdown, each component draws while it streams, and any model that streams text can write one.

npm i @nakshi/genui-blocks @nakshi/genui-react
components, ready to draw
11
components, ready to draw
packages around one core
4
packages around one core
of replies passed, best model
98%
of replies passed, best model
gpt-6.1-sol

Recipe for banana pancakes, please.

  • Waiting for the first token
0.0 s / 7.2 s

Real replies from the benchmark, replayed at the speed they streamed, with the wait for the first token cut. Switch to Markdown to see what the model wrote.

What it does

Components where the content has a shape, and text everywhere else

Many generative UI systems ask the model for a tree of components. GenUI asks for an answer, and lets the shape of the content pick the component.

  • Stays Markdown

    A reply is text with blocks in it, not a tree of JSON. Every block has a plain-text form, so the same reply reads well in Telegram, an SMS or a copy button.

  • Streams in place

    Finished steps, rows and items appear while the model is still writing the block. A chart waits for its last point, so it never draws a wrong line.

  • Forgives slips

    Unclosed brackets, a missing call, Bangla digits, an amount written “2,500”: repaired before the schema check. Long text is clipped rather than rejected.

  • One definition

    A zod schema, a streaming rule and a line on when to use it. From those the catalog writes the model's guide, the parser, the text form and the figure check.

  • Any model

    No tool calls, no JSON mode, no special API. Blocks are text, so any model that streams can write them, and the benchmark shows how well each does.

  • Checks the numbers

    Chart and stat figures are matched against the sources the turn read. ungroundedFigures lists every figure that no source states.

Components

Eleven components, ready to draw

Each is a block definition in @nakshi/genui-blocks and a view in its React entry. These are live: tick the checklist, change the servings, hover the chart. Restyle them with CSS variables, or write your own.

Full reference

Steps

ui:steps
Details

Descale a kettle

  1. Fill halfway
    Equal parts white vinegar and water.
  2. Boil, then wait · 20 min
    Switch it off and leave it to soak.
  3. Rinse twice
    Boil plain water once to clear the smell.
A procedure, or the stages of a process, in order.streams

Chart

ui:chart
Details
Time to the first block, median (s)
gpt-6-luna: First block 1.9 s. DeepSeek V4: First block 2 s. gpt-5.6-luna: First block 2.5 s. gpt-6.1-sol: First block 3.5 s. GLM 5.2: First block 4 s01234gpt-6-lunaDeepSeek V4gpt-5.6-lunagpt-6.1-solGLM 5.2gpt-6-lunaDeepSeek V4gpt-5.6-lunagpt-6.1-solGLM 5.2
Show the numbers
First block
gpt-6-luna1.9
DeepSeek V42
gpt-5.6-luna2.5
gpt-6.1-sol3.5
GLM 5.24

genui-bench, 96 replies each

A series of numbers as bars or lines, with the table behind it.whole

Checklist

ui:checklist
Details

Picnic

0 of 5 done

Food
Kit
Things to tick off, in groups. The ticks are kept.streams

Recipe

ui:recipe
Details

Overnight oats

Serves 1· 5 min
  • 50 g rolled oats
  • 120 ml milk
  • honey (to taste)
Ingredients that rescale with the servings.streams

Callout

ui:callout
Details
One real hazard, or the one tip not to miss.whole

Stats

ui:stats
Details
Surveyed
1,250
By public transport
72%
Median commute
34 min
Satisfaction
+6 pts
on 2024

Commuter survey, 2025

The few figures an answer turns on.streams

Compare

ui:compare
Details
TrainBus
Time2 h 10 · best3 h 40
Fare$48$19 · best
Wi-FiYes · bestSome routes
Options on the same rows, with the best of each row marked.streams

Tabs

ui:tabs
Details

Run brew install node.

Separate views of one thing, when someone asks for them.streams

Cards

ui:cards
Details
Walk

Free, and about 25 minutes.

  • No waiting
  • Best on a dry day
Bike

Ten minutes door to door.

  • Racks at both ends
  • Lights after dark
Bus

Fifteen minutes, every eight.

  • Tap to pay
  • Stops outside
Options that each need their own words.streams

Accordion

ui:accordion
Details
How long does a refund take?

Within five working days of the item arriving.

Who pays for the postage?

We do, when the item is faulty.

Sections to open and close, like an FAQ.streams

Code

ui:code
Details
reply.tsx · tsx
export function Reply({ text }: { text: string }) {
  return <Answer catalog={catalog} text={text} views={defaultViews} />;
}
A file, when the file is what was asked for.whole

How it works

From a definition to a drawn reply

One catalog does the work on both sides of the model: it writes what the model reads, and reads what the model writes.

  1. 01

    The model streams text

    Markdown, with a fenced block where the content has a shape.

  2. 02

    Split

    Markdown and blocks, on any prefix of the stream.

  3. 03

    Repair

    Brackets mended, digits and amounts read, names restored.

  4. 04

    Check

    Against the block's zod schema: it fits, or it reads as text.

  5. 05

    Draw

    By the block's view, item by item; or as text where there are no views.

1

Define your blocks

Start from the eleven defaults and add your own. A block is a schema, a line on when to use it, and its text form; its signature for the guide is generated from the schema.

catalog.ts
import { createCatalog, defineBlock } from '@nakshi/genui';
import { defaultBlocks } from '@nakshi/genui-blocks';
import { z } from 'zod';

const flight = defineBlock({
  type: 'flight',
  schema: z.object({
    from: z.string(),
    to: z.string(),
    departs: z.string(),
  }),
  guide: { use: 'one flight the person asked about.' },
  toText: (f) => `${f.from} → ${f.to}, ${f.departs}`,
});

export const catalog = createCatalog({
  prefix: 'ui',
  blocks: [...defaultBlocks, flight],
});
2

Give the model its guide

The guide holds one line per block, worked examples, and a check to run before answering. Put it in the system prompt, and the short reminder last in the turn, where a long thread cannot bury it.

prompt.ts
import { defaultGuide } from '@nakshi/genui-blocks';

const messages = [
  { role: 'system', content: defaultGuide(catalog) },
  ...conversation,
  { role: 'system', content: catalog.reminder() },
];
3

Draw the reply as it streams

Re-render with more text as tokens arrive. Each block is drawn by its view as soon as it has something true to show; the Markdown around it goes to your renderer.

reply.tsx
import { Answer } from '@nakshi/genui-react';
import { defaultViews } from '@nakshi/genui-blocks/react';

export function Reply({ text }: { text: string }) {
  return (
    <Answer
      catalog={catalog}
      text={text}
      views={{ ...defaultViews, flight: FlightView }}
    />
  );
}
4

Use the same reply everywhere else

Channels without components get the reply as text. Before you show figures, check them against what the turn read.

channels.ts
import { ungroundedFigures } from '@nakshi/genui';

// Telegram, SMS, a voice answer
const text = catalog.toText(reply);

// Chart and stat figures that no source states
const figures = catalog.figures(reply);
const unsupported = ungroundedFigures(figures, sources);

Benchmark

Measured on five models

genui-bench runs the 32 public cases in @nakshi/genui-eval three times per model: how-tos, processes, checklists, recipes, figures with their sources, comparisons, options, warnings, sections, and seven questions that should get no component at all. A reply passes when it uses the component the case calls for (or none), every block reads and closes, and it does not open with a block.

Replies that passed · % of 96 per model
  • gpt-6.1-sol98%
  • gpt-6-luna94%
  • GLM 5.291%
  • gpt-5.6-luna88%
  • DeepSeek V4 Flash84%
genui-bench results by model
ModelPassedBroken blockFirst wordsFirst blockCost
gpt-6.1-sol98%0%1.4 s3.5 s$0.34
gpt-6-luna94%1%1.3 s1.9 s$0.02
GLM 5.291%1%2.8 s4.0 s$0.06
gpt-5.6-luna88%1%1.1 s2.5 s$0.04
DeepSeek V4 Flash84%0%0.6 s2.0 s$0.05

27 November 2026. The default blocks and guide, each model at its default sampling; 96 replies per model. Times are medians from the request; cost is for all 96. Claude models are not in this run.

What the runs taught us

32% → 1%

Examples beat rules

Blocks from gpt-6-luna that needed a repair, without the guide's worked examples and with them. Models copy the shape of an example more than they follow a rule, so the default guide ships three, one of them with no block at all.

49%

Repairs keep blocks on screen

Of GLM 5.2's blocks read only because a repair fixed a slip first: an unclosed bracket, a missing call, a list without its name. It still passed 91%. Without repairs, half its blocks would have shown as text.

14% → 1%

Clip, don't reject

Replies from gpt-5.6-luna with a broken block, when schemas rejected text over a length and when they clipped it. The same replies, scored twice: the only difference is the schemas.

Packages

Four packages, one core

Take only what you need. The core has no framework in it; React is one binding, and the components and the benchmark sit on top.

  • Core

    @nakshi/genui

    npm

    Define a block once. The catalog writes the guide, splits a streaming reply, reads each block with repairs, gives the answer as text, and lists its figures for checking. No framework, any model.

    • defineBlock
    • createCatalog
    • ungroundedFigures
    npm install @nakshi/genui
  • React

    @nakshi/genui-react

    npm

    Draws a reply as it streams: Markdown by your renderer, each block by its view, finished items while the block is still open.

    • <Answer>
    • useBlock
    • useBlockState
    npm install @nakshi/genui-react
  • Components

    @nakshi/genui-blocks

    npm

    Eleven blocks with plain, accessible views that take their look from your page, and the guide with worked examples.

    • createDefaultCatalog
    • defaultGuide
    • defaultViews
    npm install @nakshi/genui-blocks
  • Benchmark

    @nakshi/genui-eval

    npm

    The public cases and the scorer: whether a model picks the right block, whether every block reads, and how soon the first one can be drawn.

    • cases
    • runEval
    • scoreAnswer
    npm install @nakshi/genui-eval

In production

Every Nakshi reply runs on it

Nakshi's own catalog holds 31 block types under the nakshi: prefix, from diagrams to maps and calculators, and the guide its models read is compiled from it. When we moved Nakshi onto the core, we checked that it read every block exactly as before, at every point of every stream.

Generative UI in Nakshi
Block types in Nakshi's catalog
31
block types in Nakshi's catalog
Differences found when Nakshi moved onto the core
0
differences in 606,794 reads, before and after

Research

Open, so the numbers can be checked

The cases and the scorer ship as @nakshi/genui-eval. Run them against your model, your guide or your own catalog, and you get the same measures as the table above.

bench.ts
import { cases, runEval } from '@nakshi/genui-eval';

const { summary } = await runEval({
  catalog,
  cases, // the 32 public cases
  repeat: 3,
  // Your model: any AsyncIterable<string> of the reply
  generate: (prompt) => yourModel.stream(prompt),
});

console.log(summary.overall);