@fv-ui/ai-chat 1.2.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -528,6 +528,7 @@ Markdown 渲染(Sanitized by DOMPurify),内置 Prism 代码高亮与 KaTeX。
528
528
  | update:messages | (MessageNode[]) 全量消息链(去抖后) |
529
529
  | send | (text, files?) 用户发送(allowAttachments 开启时 files 为降维后的 ChatFile[]) |
530
530
  | suggestion-select | (item) 点击空态建议项(先于 send 触发;label 为空的项不发) |
531
+ | followup-select | (item, message) 点击回答尾部追问建议 chip(先于 send 触发;组件内部已接住转 send 开启新一轮,事件仅供消费方可观测/埋点;仅链尾 assistant 消息渲染 chips,流式 message_end 前禁用防误点) |
531
532
  | message-complete | (message) 链尾 assistant 生成完成 |
532
533
  | error | (err, message?) 生成出错 |
533
534
  | branch-change | (dir, message) 分支切换 |
@@ -632,6 +633,7 @@ Markdown 渲染(Sanitized by DOMPurify),内置 Prism 代码高亮与 KaTeX。
632
633
  | --- | --- | --- | --- |
633
634
  | message | MessageNode | —(必填) | 消息节点 |
634
635
  | branch | AiMessageBranchInfo | undefined | 分支元数据 { count, index };缺省视为单分支 |
636
+ | isLast | boolean | false | 是否当前链最后一条消息(由 AiMessages 注入);追问建议 chips 仅链尾消息渲染——此前消息即使留有 suggestions 也不显示 |
635
637
  | showActions | boolean | true | 显示复制/重生成(仅 assistant) |
636
638
  | showBranchSwitch | boolean | true | 显示分支切换器(branch.count > 1 时) |
637
639
  | showUserAvatar | boolean | false | 显示用户头像(默认隐藏;false 时用户消息不渲染头像块) |
@@ -658,6 +660,7 @@ Markdown 渲染(Sanitized by DOMPurify),内置 Prism 代码高亮与 KaTeX。
658
660
  | Event | 说明 |
659
661
  | --- | --- |
660
662
  | copy / regenerate / branch-change | (message) / (message) / (dir, message) |
663
+ | followup-select | (item, message) 点击追问建议 chip(item 为建议文本;仅链尾 assistant 消息渲染 chips,status 落 done 后可点;AiChat 内部已接住转 send,直接用 AiMessage 时的消费方需自行接管发送) |
661
664
 
662
665
  | Slot | 说明 |
663
666
  | --- | --- |
@@ -740,6 +743,7 @@ const adapter = FvCommonAdapter({
740
743
  - 同步段失败(Content-Type 非 `text/event-stream`)按 JSON 错误 `{code,message}` 走 `onError`;命中 `errorMessages` 时用映射文案(带 `code` 的 `FvCommonError`)
741
744
  - `message_end` 的 `messageId`(最终文本行 id)经 `onBackendMessageId` 回填到 `MessageNode.backendId`——多轮工具循环下与 `message_start` 的首轮 id 不同,UI 落库/对账以它为准
742
745
  - `tool` 事件经 `onTool` → `useChat.onToolEvent` → `AiChat @tool-event` 上抛,消费方展示「正在查询库存…」等中间态
746
+ - 追问建议(V58+):`suggestions` 事件(流式收尾 0..1 次,最后一个 delta 后、message_end 前,载荷 `{items: string[]}`)经可选 `onSuggestions` 上抛,`useChat` 回写 `MessageNode.suggestions`,AiMessage 在链尾消息渲染追问 chips;开关关闭/模型未产出/中断/失败无此事件;历史恢复用导出的 `parseSuggestions(raw)` 安全解析 `FvCommonMessage.suggestions`(JSON 数组原文透传,脏数据按无建议)
743
747
  - 配套 DTO 类型:`FvCommonSessionItem` / `FvCommonMessage` / `FvCommonSessionDetail` / `FvCommonMessagePage`(消费方直接调会话管理端点时用)
744
748
 
745
749
  ### useMessages(initial?)