Skip to content

AiChat

Provides an out-of-the-box AI conversational interface container. Features a pre-built suggestions array, context clear button, and seamless scrolling.

Basic Usage

Renders the conversation flow based on the messages array.

Hello! I am your AI assistant, how can I help you?

Basic Chat Flow

Advanced Interactions

With support for suggestions and clear functions, you can display what users might want to ask initially on a blank slate. Also, once messages hold history, the header clear button offers an easy way to reset memory.

Advanced Model

Generative UI (Dynamic Component Mounting)

AiChat possesses an exceptionally robust internal state isolation, meaning you can fully drive Generative UI directly through metadata in the dialogue context utilizing the #message slot. Based on metadata—such as triggered tool calls or deep reasoning steps—the <yh-ai-bubble> component empowers seamless integration of any external component logic inside its natural flow structure (e.g., embedding the AiThoughtChain).

Experiment by sending a message below to witness the seamless internal transition between rendering a logic chain UI and textual markdown.

I am capable of executing complex generative structure tasks for you.

Generative Component Rendering

Use in Nuxt

This container wrapper perfectly embraces Nuxt 3/4 SSR and lazy hydrated behaviors. Works flawlessly under Nuxt's auto-importing environments.

For detail configurations, please check Nuxt Usage.

SSR Notes:

  • ✅ Inner sub-components isomorphic generation supported
  • ✅ Events bindings operate correctly

SSR Safety

AiChat wrapper natively passes SSR compliance checks across major frameworks.

API

Props

NameDescriptionTypeDefault
messagesMessage ListArray<{id: string, role: string, content: string, status?: string, time?: string}>[]
loadingIndicates if the AI is replyingbooleanfalse
suggestionsBottom default suggestion pillsstring[][]

Events

NameDescriptionParameter
sendEmitted on message sent(message: string) => void
clearEmitted on clearing history() => void

Slots

NameDescriptionParameter
messageCustomize message rendering per item{ message: Record<string, unknown>, index: number }
senderCustomize the bottom sender block
headerCustomize the top toolbar header

Theme Variables

Variable NameDescriptionDefault Value
--yh-ai-chat-bgChat container background colorvar(--yh-bg-color)
--yh-ai-chat-header-bgTop header toolbar background colorvar(--yh-bg-color-page)
--yh-ai-chat-footer-bgBottom sender area background colorvar(--yh-bg-color)

Released under the MIT License.