Chatbot
new 7.4 kB<hk-chatbot>A complete assistant surface with the vendor left out. The component draws the transcript, the composer, tool-call rows and voice; what talks to a model is yours — an engine with send, abort and reset, whose messages and busy state you feed back in. The demo runs on a local engine with no key and no network, so going live is one swap. Voice is both directions — dictation into the composer, synthesis out of it — and both are feature-detected, so a browser without them simply does not show the button.
#ai#chat#assistant#voice#tools
In the package
npm i hellskitchen-ui Import hk-chatbot and use it directly. Live demo
Running in this page — interact with it.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| engine | HkChatbotEngine | null | null | The send / abort / reset logic — { send(text), abort(), reset() }. The only thing that knows about a model. |
| messages | HkChatbotMessage[] | [] | The transcript to render, including streaming state and tool calls. System messages are never shown. |
| busy | boolean | false | A turn is in flight: shows Stop, disables Send, and Esc aborts. |
| tools | HkChatbotTool[] | [] | Registered tools ({ name, icon? }) — counted in the toolbar; icon is a class from your icon font. |
| speakReplies | boolean | false | Read replies aloud as they stream, a sentence at a time. Two-way bindable. |
| logHeight | string | null | null | Transcript height; falls back to --hk-chat-log-height. |
| showToolbar | boolean | true | The status / Speak / Clear row. |
| suggestions | string[] | [] | Prompts offered while the transcript is empty. |
| emptyMessage | string | 'Ask something to get started.' | Shown while the transcript is empty. |
Outputs
speakRepliesChangebooleanEmits when the Speak toggle flips.
Methods
focusComposer()() => voidMoves focus to the message box.
Keyboard
- Enter Send
- Shift + Enter Newline
- Esc Stop the in-flight reply
Theming
Component tokens, each falling back to a global one:
| Property | Default | Controls |
|---|---|---|
| --hk-chat-bubble-user | var(--hk-accent) | User bubble fill. |
| --hk-chat-bubble-bot | #ffffff | Assistant bubble fill. |
| --hk-chat-log-height | 20rem | Transcript height before it scrolls. |
Accessibility
- The transcript is role="log" with aria-live="polite", so a reply is announced without interrupting.
- Dictation and speech are feature-detected: an unsupported browser gets no dead button.
- Recording is signalled by colour, an animated ring and aria-pressed together, never colour alone.
- Every animation here — the caret, the tool spinner, the mic ring — stops under prefers-reduced-motion.