A walkthrough of building generative UI in a Rails chat application using RubyLLM, where the LLM selects and composes UI components rather than generating HTML directly. Covers three approaches: rendering tool results as UI, per-component tools as render signals, and a single general-purpose `generate_ui` tool that accepts a full component tree. Introduces the GenerativeUI gem, which defines a catalog DSL to derive LLM descriptions, JSON Schema, tree validation, and render targets from a single source of truth. Includes code examples for catalog definition, tool setup, Rails partials for leaf and container components, and handling edge cases like models adding redundant prose after UI tool calls.

14m read timeFrom msg.samsonov.io
Post cover image
Table of contents
Plain chat: textGenerative UI with Per-Component ToolsThe Limits of Per-Component ToolsOne Tool to Compose Them AllThe GenerativeUI gemWhere this leaves us

Sort: