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

NameTypeDefaultDescription
engineHkChatbotEngine | nullnullThe send / abort / reset logic — { send(text), abort(), reset() }. The only thing that knows about a model.
messagesHkChatbotMessage[][]The transcript to render, including streaming state and tool calls. System messages are never shown.
busybooleanfalseA turn is in flight: shows Stop, disables Send, and Esc aborts.
toolsHkChatbotTool[][]Registered tools ({ name, icon? }) — counted in the toolbar; icon is a class from your icon font.
speakRepliesbooleanfalseRead replies aloud as they stream, a sentence at a time. Two-way bindable.
logHeightstring | nullnullTranscript height; falls back to --hk-chat-log-height.
showToolbarbooleantrueThe status / Speak / Clear row.
suggestionsstring[][]Prompts offered while the transcript is empty.
emptyMessagestring'Ask something to get started.'Shown while the transcript is empty.

Outputs

  • speakRepliesChangeboolean

    Emits when the Speak toggle flips.

Methods

  • focusComposer()() => void

    Moves 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:

PropertyDefaultControls
--hk-chat-bubble-uservar(--hk-accent)User bubble fill.
--hk-chat-bubble-bot#ffffffAssistant bubble fill.
--hk-chat-log-height20remTranscript 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.