@somecat/ai-assist-sdk 1.1.2 → 1.1.8

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.
@@ -11,18 +11,20 @@ interface UseChatActionsParams {
11
11
  scrollToBottom: () => void;
12
12
  STATUS: Record<string, MessageStatus>;
13
13
  cfg: AiAssistConfig;
14
+ onTitleGenerated?: (title: string) => void;
14
15
  }
15
16
  /**
16
17
  * 对话操作:发送消息 / 重新生成 / 停止 / 加载历史会话
17
18
  *
18
19
  * 内部管理两个 AbortController(first / again)用于中断 SSE 连接。
19
20
  */
20
- export declare function useChatActions({ messages, userInput, isGenerating, lastUserMessage, conversationId, doStreamRequest, issTop, scrollToBottom, STATUS, cfg, }: UseChatActionsParams): {
21
+ export declare function useChatActions({ messages, userInput, isGenerating, lastUserMessage, conversationId, doStreamRequest, issTop, scrollToBottom, STATUS, cfg, onTitleGenerated, }: UseChatActionsParams): {
21
22
  sendMessage: () => Promise<void>;
22
23
  regenerateResponse: () => Promise<void>;
23
24
  toggleStop: () => Promise<void>;
24
25
  goHistoryMessage: (appConversationId: string) => Promise<void>;
25
26
  initConversation: () => Promise<void>;
27
+ resetConversation: () => void;
26
28
  controllers: {
27
29
  first: {
28
30
  readonly signal: {
@@ -3,8 +3,10 @@ import { ChatMessage, MessageSegment, MessageStatus } from '../../../../core/typ
3
3
  /**
4
4
  * 打字机效果:对正在流式输出(ANSWERING)的 AI 消息做逐字/渐进显示动画。
5
5
  *
6
+ * 采用「字符/秒」时间驱动模型 + 每条消息独立的小数累加器,根据积压量平滑分配显示时间:
6
7
  * - displayedContent: 每条 AI 消息当前已渲染的内容(可能是 content 的子串)
7
8
  * - streamingIndexRef: 每条消息已显示到的字符位置
9
+ * - fracRef: 每条消息的小数字符累加器(跨帧保留,保证低速率均匀推进)
8
10
  * - getSegmentDisplayContent: 对 segments 模式下最后一个 answer segment 应用打字机截断
9
11
  *
10
12
  * @param messages 消息列表 ref