AiResponse <pm-ai-response>
An AI answer drawn as interface: Markdown and typed components (cards, tables, charts, forms), safe while it streams.
Overview
Set value to the answer so far, as often as text arrives: only what changed is redrawn, so a chart that is finished does not flicker while the next paragraph is written. Components are JSON in a fenced block with the language ui, or the input of the show_ui tool in ui; uiPrompt() from @prismora/elements/ai tells a model how to write them.
The answer is treated as untrusted: nothing in it becomes HTML, only catalogue components and their props are drawn, and links and images must be http(s) (links also mailto, tel and this site). Buttons, suggestions and forms do nothing themselves: they fire pm-action and the app decides.
The content is in the light DOM, so the page's Prismora styles and theme apply to it.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
value | string | — | The answer so far: Markdown, with components as JSON in fenced blocks of the language ui. Text inside the element is used when it is not set. |
ui | Record<string, unknown>[] | Record<string, unknown> | string | — | Components as data: the input of the show_ui tool ({ ui: [...] }), a list of components, or their JSON text while it still arrives. Drawn after value. |
streaming | boolean | — | The answer is still arriving: unfinished blocks are drawn as far as they are, and a caret follows the text. |
images | 'on' | 'off' | — | off leaves images out: an image address can carry data to another server. |
heading-levelprop: headingLevel | number | — | Heading level of a # heading in the answer (default 3). |
Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.
Events
| Event | React / Svelte prop | Description |
|---|---|---|
pm-action | onPmAction | A button, a suggestion or a form of the answer was used. detail.text is a message to send to the model as the user's next turn. A sent form is then locked, unless the event is cancelled. |
Methods
write()