Chat
A conversation with no dependency, in five shapes from a plain thread to an agent with its tool calls, with answers that stream in place.
Import
import { Chat } from '@vitral/vue';Default
Ask it something. The answer arrives a token at a time, with a caret after the last character, and is announced once it settles. Attach a file with the paperclip; Enter sends and Shift+Enter breaks the line.
Two people
`variant="messenger"`: both sides get a bubble and an avatar, and a run of messages from one person is grouped under one name.
An agent and its tools
`variant="agent"`: each tool the assistant reached for is a step that can be opened — what it was asked and what it answered — and one still running says so. That is the whole reason to show the steps at all.
A copilot beside the work
`variant="copilot"`: a narrow column, no bubbles and no avatars, for a panel that sits next to what is being written.
Captions
`variant="captions"`: a running transcript rather than a conversation — no bubbles, no sides, the speaker's name in front, and the line still being recognised carrying the caret.
A widget
`variant="widget"`: a launcher, and the thread in a panel that opens over the page. The launcher says whether the panel is open, and names itself either way.
When an answer fails
A message with an `error` takes its place in the thread, and `retryable` puts the ask-again button under it.
API
Read from packages/vue/src/components/Chat/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| messages | ChatMessage[] | The thread. `v-model:messages` is not offered: what is said is the application's to decide. |
| variant | ChatVariant | — |
| placeholder | string | — |
| suggestions | string[] | Prompt starters, shown while the thread is empty. |
| emptyMessage | string | — |
| typing | boolean | string | `true` for the three dots, or the words to show instead. |
| disabled | boolean | — |
| readonly | boolean | No composer at all: a transcript. |
| allowAttachments | boolean | — |
| accept | string | — |
| maxRows | number | Rows the composer grows to before it scrolls. Defaults to 6. |
| sendOnEnter | boolean | Enter sends and Shift+Enter breaks the line. False swaps them. |
| height | string | Height of the thread's scroller. Defaults to `'28rem'`. |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Slots
| Name | Slot props | Description |
|---|---|---|
| header | — | Over the thread: a title, a model picker, a close button. |
| footer | — | Under the composer: a disclaimer, a token count. |
| message | (props: { message: ChatMessage; index: number }) | Replaces the whole of one message's body. |
| empty | — | Replaces what is shown while nothing has been said. |
| launcher | (props: { open: boolean }) | The widget's launcher. |
| default | — | The parts written as children. |