@kweaver-ai/chatkit 0.1.3 → 0.1.4
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 +1 -0
- package/dist/chatkit.cjs.js +234 -100
- package/dist/chatkit.es.js +41484 -34487
- package/dist/components/base/ChatKitBase.d.ts +13 -6
- package/dist/components/base/assistant/TaskInProgress.d.ts +14 -0
- package/dist/components/dip/DIPBase.d.ts +20 -0
- package/dist/components/icons/CopyIcon.d.ts +6 -0
- package/dist/components/icons/Text2MetricIcon.d.ts +6 -0
- package/dist/components/icons/index.d.ts +2 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/utils/copyMessage.d.ts +23 -0
- package/package.json +6 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
import { ChatMessage, ApplicationContext, ChatKitInterface, OnboardingInfo, WebSearchQuery, ExecuteCodeResult, Text2SqlResult, ChartDataSchema } from '../../types';
|
|
2
|
+
import { ChatMessage, ApplicationContext, ChatKitInterface, OnboardingInfo, WebSearchQuery, ExecuteCodeResult, Text2SqlResult, Text2MetricResult, ChartDataSchema } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* ChatKitBase 组件的属性接口
|
|
5
5
|
*/
|
|
@@ -206,11 +206,18 @@ export declare abstract class ChatKitBase<P extends ChatKitBaseProps = ChatKitBa
|
|
|
206
206
|
*/
|
|
207
207
|
protected appendText2SqlBlock(messageId: string, result: Text2SqlResult): void;
|
|
208
208
|
/**
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
209
|
+
* 添加 Text2Metric 工具类型的消息块
|
|
210
|
+
* 该方法由子类调用,用于在消息中添加 Text2Metric 查询结果
|
|
211
|
+
* @param messageId 消息 ID
|
|
212
|
+
* @param result Text2Metric 的输入和输出结果
|
|
213
|
+
*/
|
|
214
|
+
protected appendText2MetricBlock(messageId: string, result: Text2MetricResult): void;
|
|
215
|
+
/**
|
|
216
|
+
* 添加 JSON2Plot 图表类型的消息块
|
|
217
|
+
* 该方法由子类调用,用于在消息中添加 JSON2Plot 图表数据
|
|
218
|
+
* @param messageId 消息 ID
|
|
219
|
+
* @param chartData 图表数据 Schema
|
|
220
|
+
*/
|
|
214
221
|
protected appendJson2PlotBlock(messageId: string, chartData: ChartDataSchema): void;
|
|
215
222
|
/**
|
|
216
223
|
* 创建新的会话
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* TaskInProgress 组件的属性接口
|
|
4
|
+
*/
|
|
5
|
+
interface TaskInProgressProps {
|
|
6
|
+
/** 可选的自定义类名 */
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* TaskInProgress 组件
|
|
11
|
+
* 显示任务进行中的加载动画
|
|
12
|
+
*/
|
|
13
|
+
declare const TaskInProgress: React.FC<TaskInProgressProps>;
|
|
14
|
+
export default TaskInProgress;
|
|
@@ -267,6 +267,26 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
|
|
|
267
267
|
};
|
|
268
268
|
explanation?: any;
|
|
269
269
|
} | null;
|
|
270
|
+
/**
|
|
271
|
+
* 从 skill_info.args 和 answer 中提取 Text2Metric 结果
|
|
272
|
+
* 用于处理 text2metric 工具的输入和输出
|
|
273
|
+
* 根据 OpenAPI 规范,Text2MetricResult 包含 result 和 full_result
|
|
274
|
+
* - result: Text2MetricResultData(包含 data_desc,但可能只有数据样本)
|
|
275
|
+
* - full_result: Text2MetricFullResultData(包含完整数据,但没有 data_desc)
|
|
276
|
+
* 优先使用 full_result,如果没有则使用 result
|
|
277
|
+
* @param args skill_info.args 数组,包含查询参数
|
|
278
|
+
* @param answer 技能执行的 answer 字段,包含指标查询结果
|
|
279
|
+
* @returns Text2MetricResult 对象,包含 title、args、data 等信息
|
|
280
|
+
*/
|
|
281
|
+
extractText2MetricResult(args: Array<{
|
|
282
|
+
name?: string;
|
|
283
|
+
type?: string;
|
|
284
|
+
value?: string;
|
|
285
|
+
}> | undefined, answer: any): {
|
|
286
|
+
title: string;
|
|
287
|
+
args: any;
|
|
288
|
+
data?: Array<Record<string, any>>;
|
|
289
|
+
} | null;
|
|
270
290
|
/**
|
|
271
291
|
* 将技能调用或 LLM 回答的内容追加到消息中
|
|
272
292
|
* 用于历史消息解析,根据 stage 和 skill_info 将内容添加到 ChatMessage.content 数组
|
|
@@ -11,7 +11,9 @@ export { ColumnIcon } from './ColumnIcon';
|
|
|
11
11
|
export { TableIcon } from './TableIcon';
|
|
12
12
|
export { JsonPlotIcon } from './JsonPlotIcon';
|
|
13
13
|
export { Text2SqlIcon } from './Text2SqlIcon';
|
|
14
|
+
export { Text2MetricIcon } from './Text2MetricIcon';
|
|
14
15
|
export { AssistantIcon } from './AssistantIcon';
|
|
15
16
|
export { MoreIcon } from './MoreIcon';
|
|
16
17
|
export { NewIcon } from './NewIcon';
|
|
17
18
|
export { ExpandIcon } from './ExpandIcon';
|
|
19
|
+
export { CopyIcon } from './CopyIcon';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -183,6 +183,21 @@ export interface Text2SqlResult {
|
|
|
183
183
|
data: Array<Record<string, any>>;
|
|
184
184
|
sql: string;
|
|
185
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Text2Metric 结果接口
|
|
188
|
+
* Text2Metric 工具的输入和输出信息
|
|
189
|
+
* 根据 OpenAPI 规范,answer 包含 result 和 full_result
|
|
190
|
+
* - result: Text2MetricResultData(包含 data_desc,但可能只有数据样本)
|
|
191
|
+
* - full_result: Text2MetricFullResultData(包含完整数据,但没有 data_desc)
|
|
192
|
+
*/
|
|
193
|
+
export interface Text2MetricResult {
|
|
194
|
+
/** 结果标题 */
|
|
195
|
+
title: string;
|
|
196
|
+
/** 查询结果数据 */
|
|
197
|
+
data: Array<Record<string, any>>;
|
|
198
|
+
/** 查询参数(args) */
|
|
199
|
+
args: any;
|
|
200
|
+
}
|
|
186
201
|
/**
|
|
187
202
|
* 工具调用数据接口
|
|
188
203
|
* 工具调用的输入和输出信息
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ChatMessage } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 生成 Word 兼容的 HTML
|
|
4
|
+
*/
|
|
5
|
+
export declare const generateWordCompatibleHTML: (html: string) => string;
|
|
6
|
+
/**
|
|
7
|
+
* 从 ChatMessage 中提取 Markdown 格式的内容
|
|
8
|
+
*/
|
|
9
|
+
export declare const extractMarkdownContent: (message: ChatMessage) => string;
|
|
10
|
+
/**
|
|
11
|
+
* 从 Markdown 内容中提取纯文本内容
|
|
12
|
+
*/
|
|
13
|
+
export declare const extractTextContent: (markdown: string) => string;
|
|
14
|
+
/**
|
|
15
|
+
* 将 Markdown 转换为 HTML
|
|
16
|
+
*/
|
|
17
|
+
export declare const markdownToHtml: (markdown: string) => Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* 复制消息内容(支持富文本和纯文本)
|
|
20
|
+
* @param message ChatMessage 对象
|
|
21
|
+
* @returns Promise<boolean> 复制是否成功
|
|
22
|
+
*/
|
|
23
|
+
export declare const copyMessageContent: (message: ChatMessage) => Promise<boolean>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kweaver-ai/chatkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -45,10 +45,14 @@
|
|
|
45
45
|
"rehype-highlight": "^7.0.2",
|
|
46
46
|
"rehype-katex": "^7.0.1",
|
|
47
47
|
"rehype-raw": "^7.0.0",
|
|
48
|
+
"rehype-stringify": "^9.0.3",
|
|
48
49
|
"remark-breaks": "^4.0.0",
|
|
49
50
|
"remark-gfm": "^4.0.1",
|
|
50
51
|
"remark-math": "^6.0.0",
|
|
51
|
-
"
|
|
52
|
+
"remark-parse": "^11.0.0",
|
|
53
|
+
"remark-rehype": "^11.1.1",
|
|
54
|
+
"sql-formatter-plush": "^1.1.3",
|
|
55
|
+
"unified": "^11.0.5"
|
|
52
56
|
},
|
|
53
57
|
"devDependencies": {
|
|
54
58
|
"@types/node": "^22.10.2",
|