Redouble AI Nucleo documentation
Part 10 · Beyond the process

Building a chat endpoint

ai.redouble.nucleo.chat · nucleo-core

A chat is a person talking to an agent in a browser, the answer streaming in as the agent works. In most applications a chat is about something: a project, a support ticket, a case. This package holds the parts of such a chat that are the same in every application, so one compiled chat frontend can serve all of them: the message a browser sends, the shapes the frontend lists scopes and conversations with, and the title a stored conversation is shown under. The messages the server pushes back are in Chat messages.

Nucleo ships no chat endpoint of its own. The application writes one, a websocket endpoint over these shapes, and binds each conversation to its own entity, which this package calls the conversation's scope. The conversation itself, its history and its persistence are the runtime's (Conversations).

The shapes

What the endpoint does

The endpoint is a view onto a durable conversation, and the conversation outlives it. The contracts an endpoint implements against this package:

Naming a conversation

ConversationTitle.PROMPT is what every store asks a model for, and ConversationTitle.clean is what makes the answer displayable: the first non-empty line, markdown emphasis and wrapping quotes stripped, whitespace collapsed, and null when nothing usable is left, so a caller stores no title rather than an empty one. The prompt asks for plain text and the cleanup enforces it, because a prompt is a request and a model may answer with markdown anyway.

How it works inside

The tests that pin the title cleanup and the CONNECTED frame are listed in Inside the chat surface, for those working on the runtime itself.

^