组件
AI 会话 AI
AI 对话容器:Root 记录对话,Message 标记 role,Response、Reasoning、Tool、Sources 分别承载不同类型的回复片段。可交互折叠区复用共享 Collapsible,并加上 `data-ai` 标记,交互逻辑仍由状态机处理。部件不绑定任何客户端;使用者把自己的消息格式(例如此处重新导出的 `UIMessage` parts)映射到这些基础组件上。
#基础用法
The draft is ready — three sections, one summary.
The user asked for a draft outline. Keep it to three sections and close with a summary line.
<script setup lang="ts">
import { Ai } from "@bysages/vue";
</script>
<template>
<!-- One stable measure: the canvas shrink-wraps its children, so an
expanding fold would breathe the whole conversation wider. -->
<div class="w-full max-w-[46rem]">
<Ai.Conversation>
<Ai.Message role="assistant">
<Ai.Response content="The draft is ready — three sections, one summary." />
<Ai.Reasoning label="Thought for 2s">
The user asked for a draft outline. Keep it to three sections and close with a summary
line.
</Ai.Reasoning>
</Ai.Message>
</Ai.Conversation>
</div>
</template>
#属性
#AiConversation
对话日志容器:所有消息都渲染在这一栏中,并作为屏幕阅读器的地标。
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
autoScroll | Boolean | true | 回复流式生长时,读者停在底边就跟随滚动;向上回读即停止拽动,回到底边自动恢复 |
#AiContent
气泡内容区,用来放置两侧通用的内容。
纯造型的部件——自身没有属性,沿用部件结构的共享样式。
#AiActions
消息下方的操作区,通常包含复制、重试和反馈按钮。
纯造型的部件——自身没有属性,沿用部件结构的共享样式。
#AiLoader
AI 处理中的对话轮次显示的加载提示。
纯造型的部件——自身没有属性,沿用部件结构的共享样式。