Chat state and commands with rendered UI messages.
API
interface UiChatResult<Tools extends Chat.AnyTool, State = unknown> extends Omit<UseStructuredChatResult<UiChatSchema, Tools, State>, 'messages' | 'lastAssistantMessage'> {readonly components: UiKitInput<ExposedComponent<any>>[];lastAssistantMessage: UiAssistantMessage <Tools> |
undefined;messages: UiChatMessage < Tools > [];setComponents: Dispatch <
SetStateAction <
UiKitInput <
ExposedComponent <any>
>[]
>
>;}UiChatResult
@typeToolsChat.AnyTool@typeStatecomponents
UiKitInput<ExposedComponent<any>>[]The components offered to the model on the next request: the
components option until setComponents replaces them.
lastAssistantMessage
UiAssistantMessage<Tools> | undefinedThe most recent assistant response, including its rendered UI.
messages
UiChatMessage<Tools>[]The messages with rendered UI attached to assistant responses.
setComponents
Dispatch<SetStateAction<UiKitInput<ExposedComponent<any>>[]>>Replace the components offered to the model on the next request.
The chat keeps every component it has ever offered, one per name, with the newest definition of a name replacing older ones. Messages render with that set, so earlier answers still render after the list narrows, and new responses are parsed against it too: a provider that does not enforce the response schema strictly can still render a component that was removed.