@kweaver-ai/chatkit 0.1.16 → 0.1.17
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/dist/chatkit.cjs.js +55 -55
- package/dist/chatkit.es.js +5841 -5417
- package/dist/components/base/ChatKitBase.d.ts +24 -0
- package/dist/components/base/assistant/HistoryChunkPlaceholder.d.ts +13 -0
- package/dist/components/base/assistant/InputArea.d.ts +2 -2
- package/dist/components/base/assistant/MessageShell.d.ts +14 -0
- package/dist/components/base/assistant/hooks/useAnchoredMessageList.d.ts +23 -0
- package/dist/components/dip/DIPBase.d.ts +8 -0
- package/package.json +1 -1
|
@@ -258,6 +258,14 @@ export declare abstract class ChatKitBase<P extends ChatKitBaseProps = ChatKitBa
|
|
|
258
258
|
* @param consumeTime 耗时(毫秒),可选
|
|
259
259
|
*/
|
|
260
260
|
protected appendJson2PlotBlock(messageId: string, chartData: ChartDataSchema, consumeTime?: number): void;
|
|
261
|
+
/**
|
|
262
|
+
* 更新指定消息中最后一个 JSON2Plot 图表块的内容(用于流式工具 json2plot 的组装)
|
|
263
|
+
* 如果不存在 JSON2Plot 块,则在流式更新时创建一个新的图表块
|
|
264
|
+
* @param messageId 消息 ID
|
|
265
|
+
* @param chartData 最新的图表数据 Schema
|
|
266
|
+
* @param consumeTime 耗时(毫秒),可选
|
|
267
|
+
*/
|
|
268
|
+
protected updateJson2PlotBlock(messageId: string, chartData: ChartDataSchema, consumeTime?: number): void;
|
|
261
269
|
/**
|
|
262
270
|
* 添加 AfSailor 工具类型的消息块
|
|
263
271
|
* 该方法由子类调用,用于在消息中添加 AfSailor 查询结果
|
|
@@ -274,6 +282,14 @@ export declare abstract class ChatKitBase<P extends ChatKitBaseProps = ChatKitBa
|
|
|
274
282
|
* @param consumeTime 耗时(毫秒),可选
|
|
275
283
|
*/
|
|
276
284
|
protected appendDatasourceFilterBlock(messageId: string, result: DatasourceFilterResult, consumeTime?: number): void;
|
|
285
|
+
/**
|
|
286
|
+
* 更新指定消息中最后一个 DatasourceFilter 工具块的内容(用于流式工具 datasource_filter 的组装)
|
|
287
|
+
* 如果不存在 DatasourceFilter 块,则在流式更新时创建一个新的工具块
|
|
288
|
+
* @param messageId 消息 ID
|
|
289
|
+
* @param result 最新的 DatasourceFilterResult
|
|
290
|
+
* @param consumeTime 耗时(毫秒),可选
|
|
291
|
+
*/
|
|
292
|
+
protected updateDatasourceFilterBlock(messageId: string, result: DatasourceFilterResult, consumeTime?: number): void;
|
|
277
293
|
/**
|
|
278
294
|
* 添加 DatasourceRerank 工具类型的消息块
|
|
279
295
|
* 该方法由子类调用,用于在消息中添加 DatasourceRerank 查询结果,与 datasource_filter 处理方式一致
|
|
@@ -282,6 +298,14 @@ export declare abstract class ChatKitBase<P extends ChatKitBaseProps = ChatKitBa
|
|
|
282
298
|
* @param consumeTime 耗时(毫秒),可选
|
|
283
299
|
*/
|
|
284
300
|
protected appendDatasourceRerankBlock(messageId: string, result: DatasourceRerankResult, consumeTime?: number): void;
|
|
301
|
+
/**
|
|
302
|
+
* 更新指定消息中最后一个 DatasourceRerank 工具块的内容(用于流式工具 datasource_rerank 的组装)
|
|
303
|
+
* 如果不存在 DatasourceRerank 块,则在流式更新时创建一个新的工具块
|
|
304
|
+
* @param messageId 消息 ID
|
|
305
|
+
* @param result 最新的 DatasourceRerankResult
|
|
306
|
+
* @param consumeTime 耗时(毫秒),可选
|
|
307
|
+
*/
|
|
308
|
+
protected updateDatasourceRerankBlock(messageId: string, result: DatasourceRerankResult, consumeTime?: number): void;
|
|
285
309
|
/**
|
|
286
310
|
* 添加默认工具类型的消息块
|
|
287
311
|
* 用于那些没有单独渲染逻辑的通用工具
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface HistoryChunkPlaceholderProps {
|
|
3
|
+
/** 此占位块包含的消息条数,用于展示提示文案 */
|
|
4
|
+
messageCount: number;
|
|
5
|
+
/** 点击展开该历史段 */
|
|
6
|
+
onExpand: () => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 历史段占位块
|
|
10
|
+
* - 用于折叠更早的历史记录,减少真实 DOM 数量
|
|
11
|
+
*/
|
|
12
|
+
declare const HistoryChunkPlaceholder: React.FC<HistoryChunkPlaceholderProps>;
|
|
13
|
+
export default HistoryChunkPlaceholder;
|
|
@@ -8,8 +8,8 @@ interface InputAreaProps {
|
|
|
8
8
|
value: string;
|
|
9
9
|
/** 输入框值变化的回调 */
|
|
10
10
|
onChange: (value: string) => void;
|
|
11
|
-
/**
|
|
12
|
-
onSend: () => void
|
|
11
|
+
/** 发送消息的回调(支持异步) */
|
|
12
|
+
onSend: () => void | Promise<void>;
|
|
13
13
|
/** 当前的应用上下文 */
|
|
14
14
|
context?: ApplicationContext;
|
|
15
15
|
/** 移除上下文的回调 */
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface MessageShellProps {
|
|
3
|
+
messageId: string;
|
|
4
|
+
onHeightChange?: (messageId: string, height: number) => void;
|
|
5
|
+
className?: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* MessageShell
|
|
10
|
+
* - 包裹单条消息,负责通过 ResizeObserver 上报真实高度
|
|
11
|
+
* - 不关心消息内容与交互本身
|
|
12
|
+
*/
|
|
13
|
+
declare const MessageShell: React.FC<MessageShellProps>;
|
|
14
|
+
export default MessageShell;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface ScrollAnchor {
|
|
3
|
+
messageId: string;
|
|
4
|
+
offset: number;
|
|
5
|
+
}
|
|
6
|
+
export interface UseAnchoredMessageListOptions {
|
|
7
|
+
/** 消息按从上到下的顺序排列,用于根据高度表计算偏移(仅包含当前真实渲染的消息 ID) */
|
|
8
|
+
getOrderedMessageIds: () => string[];
|
|
9
|
+
/** 是否启用锚点恢复(例如在不贴底时才启用) */
|
|
10
|
+
shouldUseAnchor?: () => boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface UseAnchoredMessageListResult {
|
|
13
|
+
handleMessageHeightChange: (messageId: string, height: number) => void;
|
|
14
|
+
handleScroll: (e: React.UIEvent<HTMLDivElement>) => void;
|
|
15
|
+
registerScrollContainer: (el: HTMLDivElement | null) => void;
|
|
16
|
+
restoreScrollByAnchor: () => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 管理消息高度表与滚动锚点的 Hook
|
|
20
|
+
* - 使用 ResizeObserver 上报的高度增量,结合锚点信息,在高度变化或上方插入消息时做滚动修正
|
|
21
|
+
* - 内部使用 requestAnimationFrame 合并一帧内的多次高度变更,避免频繁 reflow
|
|
22
|
+
*/
|
|
23
|
+
export declare function useAnchoredMessageList(options: UseAnchoredMessageListOptions): UseAnchoredMessageListResult;
|
|
@@ -189,6 +189,14 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
|
|
|
189
189
|
getWhitelistEntry(action: string, jsonPath: string): {
|
|
190
190
|
postProcess?: (assistantMessage: AssistantMessage, content: any, messageId: string) => void;
|
|
191
191
|
} | null;
|
|
192
|
+
/**
|
|
193
|
+
* 在流式结束后,将完整的 AssistantMessage 结构一次性应用到指定 ChatMessage:
|
|
194
|
+
* - 遍历 middle_answer.progress,按顺序调用 appendSkillOrLLMContentToMessage 组装所有工具和 LLM 内容块
|
|
195
|
+
* - 基于 message.ext 同步 messageContext(相关问题、耗时、Token 等),与历史会话逻辑保持一致
|
|
196
|
+
*
|
|
197
|
+
* 作为受保护方法暴露,便于子类在特殊场景下自定义流式结果的应用逻辑。
|
|
198
|
+
*/
|
|
199
|
+
applyAssistantMessageFromStream(assistantMessage: AssistantMessage, messageId: string): void;
|
|
192
200
|
/**
|
|
193
201
|
* 从 Progress 对象中提取 Web 搜索查询
|
|
194
202
|
* 根据 OpenAPI 规范,搜索数据在 answer.choices[0].message.tool_calls 中
|