The chat is everything between your users and a model. Create a NuiChatSession with a respond function, and <nui-chat> does the rest: it streams the reply as Markdown, follows it down the page until the reader scrolls up, and turns the send button into a stop button while it arrives.
respond returns text, a promise, an async function* or an Observable, so any API fits. Beyond text, a reply can carry the model’s reasoning, its tool calls (drawn by templates of yours), and the sources it used. nuiEventStream reads the server-sent events most model APIs stream.
Nothing is lost: a retried reply or an edited question becomes a new version beside the old one, and the conversation keeps every branch. Screen readers hear each reply once it’s complete, not word by word.
An assistant
Suggestions start the conversation. Replies stream in as Markdown; stop them, retry them, rate them, or edit your question. attach takes files picked, pasted or dropped.
Reasoning, tools and sources
Deltas add the model’s reasoning, tool calls and sources to the reply. nuiChatTool draws the weather tool as a card; other tools fold away with their input and output.
Streaming from a server
nuiEventStream reads an OpenAI-style event stream, and a NuiChatError shows its message. all() saves the conversation, versions and all.