Skip to content

refactor(cookbooks): answer with the chat library - #1264

Merged
vishxrad merged 3 commits into
mainfrom
visharad/cookbooks-chat-library
Sep 30, 2026
Merged

vishxrad merged 3 commits into
mainfrom
visharad/cookbooks-chat-library

Conversation

@vishxrad

@vishxrad vishxrad commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #1258. The cookbooks' component libraries were built on the wrong base, so this switches all three to openuiChatLibrary.

Summary

  • Chat library instead of an openuiLibrary subset. Each cookbook built its library from string lookups into openuiLibrary (["Stack", "Table", …].map((name) => openuiLibrary.components[name])), with a Stack root and FollowUpBlock/FollowUpItem borrowed from the chat library. The chat library is the one made for Agent Interface answers, and it already has every component the cookbooks picked.
    • Document comparison and conversational analytics export it unchanged: export { openuiChatLibrary as library } from "@openuidev/react-ui/genui-lib".
    • Booking assistant keeps its DatePicker override on top of it: Object.values({ ...openuiChatLibrary.components, DatePicker }), with the chat library's root and component groups.
  • No custom Sources component. The chat Card takes sources ({ title, sourceName, url }[]) as its second argument and renders the same CardSourceProvider + Sources strip that sources.tsx wrapped, so sources.tsx is deleted.
  • Prompts. Examples use root = Card([...]) (document comparison: Card([...], sources)), and the rules that named Stack or the Sources component now name the Card.
  • Docs. Step 3 of each cookbook, the prompt bullets, the README file tables, and the References lists describe the chat library. Document comparison's step 3 shows the OpenUI Lang Card([...], sources) example in place of the sources.tsx sample. One line of that example is about 180 characters and scrolls sideways, since OpenUI Lang statements can't wrap.

Why

  • String lookups aren't type-checked. components is a Record<string, …>, so a typo compiles and then throws Cannot read properties of undefined (reading 'props') when the module loads.
  • Stack's children is any[]. The spec told the model nothing about what an answer can contain.
  • Subsetting the chat library doesn't work cleanly. A subset still advertises all 38 child types in Card's signature, including components outside the subset. Keeping the chat library's component groups makes generateSystemPrompt({ cloud: true }) throw, because the groups name components outside the subset. So using the whole library is the clean option.

What changes in behavior

  • Answers are one chat Card, not a bare Stack.
  • Sources appear below the follow-ups. The Card always renders its sources strip last.
  • Repeated pages are handled by the prompt. onePerPage merged two quotes from the same page because the strip keys its cards by URL. A prompt rule now asks for one item per page.
  • Larger prompt. The library grows from 14 to 84 components. Gateway builds the system prompt from the spec that generateSystemPrompt({ cloud: true, library }) sends, and for a one-line question with no cookbook rules it reports 2,059 prompt tokens with the old document-comparison library and 7,249 with the chat library (usage.prompt_tokens). The spec sent with each request grows from about 6 KB to 55 KB. runTools() sends the system prompt with every completion, so a question that searches once pays the difference at least twice. The cookbook rules still name the components each answer uses and rule out forms and queries.

Test plan

  • npm ci and npm run verify (spec generation and next build with type checking) in all three cookbooks at this PR's head, rebased on main
  • Every prompt example parses against its library with no errors and a Card root, and generateSystemPrompt({ cloud: true, library }) accepts all three specs
  • Document comparison, in the browser: “Compare revenue and growth” renders a Card with the table, two charts, the fiscal-year callout, follow-ups, and a sources strip with one card per page (NVIDIA p. 37, AMD p. 50, Intel p. 76). No console errors.
  • Analytics, in the browser: the Norris/Verstappen starter renders the gap line chart, a fastest-lap table, and follow-ups. No console errors.
  • Booking assistant, in the browser: the Goa starter renders the trip form with both dates prefilled (Fri Oct 2 to Sun Oct 4), so the DatePicker override still works. Submitting it renders the stay cards with photos. One transient src="" warning appeared while an Image streamed; both libraries use the same Image component, so it isn't from this change.
  • Docs site, locally: the three cookbook pages render with no console or server errors, and only the OpenUI Lang line above scrolls sideways

🤖 Generated with Claude Code

@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openui-docs Ready Ready Preview Sep 30, 2026 2:07pm UTC

Request Review

@vishxrad
vishxrad added this pull request to stack #1262 September 29, 2026 08:51
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from fdd5171 to 8fa29a7 Compare September 29, 2026 09:37
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from 8fa29a7 to b78c1b8 Compare September 29, 2026 09:43
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from b78c1b8 to dbdd078 Compare September 29, 2026 09:58
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from dbdd078 to 352b1f4 Compare September 29, 2026 10:01
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from 352b1f4 to 09f8ed4 Compare September 29, 2026 10:11
Base automatically changed from visharad/cookbooks-run-tools to visharad/cookbooks-gateway-conversations September 29, 2026 10:11
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from 09f8ed4 to b3d8b90 Compare September 29, 2026 11:12
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch 2 times, most recently from 350c26e to d21b89f Compare September 29, 2026 11:28
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from 350c26e to d21b89f Compare September 29, 2026 11:28
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from d21b89f to fe8af4c Compare September 29, 2026 12:49
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from fe8af4c to b129b60 Compare September 29, 2026 14:12

@bobo617 bobo617 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loku UF koquitelofqwuincyrt

@bobo617

bobo617 commented Sep 29, 2026

Copy link
Copy Markdown

Asгнней

@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from a40d872 to a48d83b Compare September 30, 2026 07:46
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from a48d83b to 4563cef Compare September 30, 2026 07:58
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from 4563cef to 0a3bbdc Compare September 30, 2026 08:48
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from 0a3bbdc to e1ce4cb Compare September 30, 2026 09:06
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from e1ce4cb to b10846e Compare September 30, 2026 09:12
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from b10846e to 76f8841 Compare September 30, 2026 09:21
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from 76f8841 to 49c904c Compare September 30, 2026 09:49
@vishxrad
vishxrad force-pushed the visharad/cookbooks-chat-library branch from 49c904c to f270566 Compare September 30, 2026 12:25
abhithesys
abhithesys previously approved these changes Sep 30, 2026
Base automatically changed from visharad/cookbooks-gateway-conversations to main September 30, 2026 14:03
vishxrad and others added 3 commits September 30, 2026 19:33
The cookbooks built each library from string lookups into openuiLibrary,
with a Stack root, plus FollowUpBlock and FollowUpItem borrowed from
openuiChatLibrary. The chat library is the one made for Agent Interface
answers and already has every component the cookbooks picked, so:

- Document comparison and conversational analytics export
  openuiChatLibrary unchanged.
- Booking assistant uses the chat library with its DatePicker replaced.
- Document comparison drops its custom Sources component and passes the
  sources as the chat Card's second argument, which renders the same
  source strip.
- Prompt examples and rules use a Card root instead of Stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The example now exports React UI's chat library instead of building one
with createLibrary(), so drop the @openuidev/react-lang reference and
name the chat library under @openuidev/react-ui.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… chat library

Document comparison now exports React UI's chat library, so drop its
@openuidev/react-lang reference. Both pages name the chat library under
@openuidev/react-ui; booking still uses react-lang for createLibrary()
and its DatePicker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vishxrad
vishxrad merged commit 0567366 into main Sep 30, 2026
5 checks passed
@vishxrad
vishxrad deleted the visharad/cookbooks-chat-library branch September 30, 2026 14:11

This branch was successfully deployed

1 active deployment
Preview — 6f2fa8de Deployed Sep 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants