@kweaver-ai/chatkit 0.1.0 → 0.1.2

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.
Files changed (38) hide show
  1. package/README.md +3 -3
  2. package/dist/chatkit.cjs.js +377 -22
  3. package/dist/chatkit.es.js +72448 -2015
  4. package/dist/components/base/ChatKitBase.d.ts +17 -2
  5. package/dist/components/base/assistant/AssistantBase.d.ts +47 -4
  6. package/dist/components/base/assistant/ConversationHistory.d.ts +26 -0
  7. package/dist/components/base/assistant/MessageItem.d.ts +2 -0
  8. package/dist/components/base/assistant/MessageList.d.ts +2 -0
  9. package/dist/components/base/assistant/Prologue.d.ts +2 -0
  10. package/dist/components/base/assistant/blocks/CodeViewTool/CodeViewTool.d.ts +22 -0
  11. package/dist/components/base/assistant/blocks/CodeViewTool/SqlFormatter.d.ts +24 -0
  12. package/dist/components/base/assistant/blocks/CodeViewTool/index.d.ts +4 -0
  13. package/dist/components/base/assistant/blocks/Json2PlotBlock/EChartsView.d.ts +25 -0
  14. package/dist/components/base/assistant/blocks/Json2PlotBlock/Json2PlotContentView.d.ts +21 -0
  15. package/dist/components/base/assistant/blocks/Json2PlotBlock/Json2PlotModal.d.ts +21 -0
  16. package/dist/components/base/assistant/blocks/Json2PlotBlock/TableView.d.ts +21 -0
  17. package/dist/components/base/assistant/blocks/Json2PlotBlock/index.d.ts +9 -0
  18. package/dist/components/base/assistant/blocks/Json2PlotBlock/utils.d.ts +14 -0
  19. package/dist/components/base/assistant/blocks/Json2PlotBlock.d.ts +20 -0
  20. package/dist/components/base/assistant/blocks/MarkdownBlock.d.ts +4 -0
  21. package/dist/components/base/assistant/blocks/index.d.ts +3 -0
  22. package/dist/components/base/copilot/MessageItem.d.ts +2 -0
  23. package/dist/components/base/copilot/MessageList.d.ts +2 -0
  24. package/dist/components/base/copilot/blocks/MarkdownBlock.d.ts +4 -0
  25. package/dist/components/dip/DIPBase.d.ts +73 -35
  26. package/dist/components/icons/AssistantIcon.d.ts +6 -0
  27. package/dist/components/icons/ColumnIcon.d.ts +6 -0
  28. package/dist/components/icons/ExpandIcon.d.ts +6 -0
  29. package/dist/components/icons/JsonPlotIcon.d.ts +6 -0
  30. package/dist/components/icons/LineIcon.d.ts +6 -0
  31. package/dist/components/icons/MoreIcon.d.ts +6 -0
  32. package/dist/components/icons/NewIcon.d.ts +6 -0
  33. package/dist/components/icons/PieIcon.d.ts +6 -0
  34. package/dist/components/icons/TableIcon.d.ts +6 -0
  35. package/dist/components/icons/Text2SqlIcon.d.ts +6 -0
  36. package/dist/components/icons/index.d.ts +10 -0
  37. package/dist/types/index.d.ts +86 -3
  38. package/package.json +4 -3
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * 折线图图标组件
4
+ */
5
+ export declare const LineIcon: React.FC<React.SVGProps<SVGSVGElement>>;
6
+ export default LineIcon;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * 更多图标组件
4
+ */
5
+ export declare const MoreIcon: React.FC<React.SVGProps<SVGSVGElement>>;
6
+ export default MoreIcon;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * 新建图标组件
4
+ */
5
+ export declare const NewIcon: React.FC<React.SVGProps<SVGSVGElement>>;
6
+ export default NewIcon;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * 饼图图标组件
4
+ */
5
+ export declare const PieIcon: React.FC<React.SVGProps<SVGSVGElement>>;
6
+ export default PieIcon;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * 表格图标组件
4
+ */
5
+ export declare const TableIcon: React.FC<React.SVGProps<SVGSVGElement>>;
6
+ export default TableIcon;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * Text2Plot 图标组件
4
+ */
5
+ export declare const Text2SqlIcon: React.FC<React.SVGProps<SVGSVGElement>>;
6
+ export default Text2SqlIcon;
@@ -5,3 +5,13 @@ export { CloseIcon } from './CloseIcon';
5
5
  export { StopIcon } from './StopIcon';
6
6
  export { SendIcon } from './SendIcon';
7
7
  export { ClockIcon } from './ClockIcon';
8
+ export { PieIcon } from './PieIcon';
9
+ export { LineIcon } from './LineIcon';
10
+ export { ColumnIcon } from './ColumnIcon';
11
+ export { TableIcon } from './TableIcon';
12
+ export { JsonPlotIcon } from './JsonPlotIcon';
13
+ export { Text2SqlIcon } from './Text2SqlIcon';
14
+ export { AssistantIcon } from './AssistantIcon';
15
+ export { MoreIcon } from './MoreIcon';
16
+ export { NewIcon } from './NewIcon';
17
+ export { ExpandIcon } from './ExpandIcon';
@@ -32,7 +32,11 @@ export declare enum BlockType {
32
32
  /** Web 搜索类型 */
33
33
  WEB_SEARCH = "WebSearch",
34
34
  /** 工具调用类型 */
35
- TOOL = "Tool"
35
+ TOOL = "Tool",
36
+ /** JSON2Plot 图表类型 */
37
+ JSON2PLOT = "Json2Plot",
38
+ /** Text2SQL 类型 */
39
+ Text2Sql = "Text2Sql"
36
40
  }
37
41
  /**
38
42
  * 角色接口
@@ -79,6 +83,11 @@ export interface WebSearchBlock extends ContentBlock<BlockType.WEB_SEARCH, WebSe
79
83
  */
80
84
  export interface ToolBlock extends ContentBlock<BlockType.TOOL, ToolCallData> {
81
85
  }
86
+ /**
87
+ * JSON2Plot 图表类型的消息块
88
+ */
89
+ export interface Json2PlotBlock extends ContentBlock<BlockType.JSON2PLOT, ChartDataSchema> {
90
+ }
82
91
  /**
83
92
  * 消息接口
84
93
  * 展示在消息区消息列表中的一条消息
@@ -91,7 +100,7 @@ export interface ChatMessage {
91
100
  /** 该条消息的类型(已废弃,保留用于向后兼容) */
92
101
  type?: ChatMessageType;
93
102
  /** 该条消息的内容。一条消息可以由许多不同类型的消息块组成 */
94
- content: Array<TextBlock | MarkdownBlock | WebSearchBlock | ToolBlock>;
103
+ content: Array<TextBlock | MarkdownBlock | WebSearchBlock | ToolBlock | Json2PlotBlock>;
95
104
  /** 与该消息关联的应用上下文(可选),仅用户消息可能包含此字段 */
96
105
  applicationContext?: ApplicationContext;
97
106
  }
@@ -161,6 +170,19 @@ export interface ExecuteCodeResult {
161
170
  /** 代码执行后转为自然语言的输出结果,以 Markdown 格式显示 */
162
171
  output: string;
163
172
  }
173
+ /**
174
+ * Text2SQL 结果接口
175
+ * Text2SQL 工具的输入和输出信息
176
+ * 根据 OpenAPI 规范,answer 包含 result 和 full_result
177
+ * - result: Text2SqlResultData(包含 data_desc,但可能只有数据样本)
178
+ * - full_result: Text2SqlFullResultData(包含完整数据,但没有 data_desc)
179
+ */
180
+ export interface Text2SqlResult {
181
+ /** 输入的查询文本 */
182
+ title: string;
183
+ data: Array<Record<string, any>>;
184
+ sql: string;
185
+ }
164
186
  /**
165
187
  * 工具调用数据接口
166
188
  * 工具调用的输入和输出信息
@@ -213,9 +235,10 @@ export interface ChatKitInterface {
213
235
  * 该方法需要由子类继承并重写,以适配扣子、Dify 等 LLMOps 平台的接口
214
236
  * 成功返回会话 ID
215
237
  * 注意:该方法是一个无状态无副作用的函数,不允许修改 state
238
+ * @param title 会话标题,通常是用户发送的第一条消息内容
216
239
  * @returns 返回新创建的会话 ID
217
240
  */
218
- generateConversation(): Promise<string>;
241
+ generateConversation(title?: string): Promise<string>;
219
242
  /**
220
243
  * 向后端发送消息
221
244
  * 该方法需要由开发者实现,以适配扣子、Dify等 LLMOps 平台的接口
@@ -283,3 +306,63 @@ export interface ChatKitInterface {
283
306
  */
284
307
  deleteConversation(conversationID: string): Promise<void>;
285
308
  }
309
+ /**
310
+ * 图表类型枚举
311
+ * 支持的图表类型
312
+ */
313
+ export type ChartType = 'Line' | 'Column' | 'Pie' | 'Circle';
314
+ /**
315
+ * 数据行
316
+ */
317
+ export type DataRow = Record<string, any>;
318
+ /**
319
+ * 维度接口
320
+ */
321
+ export interface Dimension {
322
+ /** 字段名 */
323
+ name: string;
324
+ /** 显示名称 */
325
+ displayName: string;
326
+ /** 数据类型 */
327
+ dataType: 'string' | 'number' | 'date' | 'boolean';
328
+ }
329
+ /**
330
+ * 度量接口
331
+ */
332
+ export interface Measure {
333
+ /** 字段名 */
334
+ name: string;
335
+ /** 显示名称 */
336
+ displayName: string;
337
+ /** 数据类型 */
338
+ dataType: 'number' | 'string';
339
+ /** 聚合方式 */
340
+ aggregation?: 'sum' | 'avg' | 'count' | 'max' | 'min';
341
+ }
342
+ /**
343
+ * 图表数据 Schema
344
+ */
345
+ export interface ChartDataSchema {
346
+ /** 图表类型 */
347
+ chartType: ChartType;
348
+ /** 图表名称/标题(可选) */
349
+ title?: string;
350
+ /** 维度列表 */
351
+ dimensions: Dimension[];
352
+ /** 度量列表 */
353
+ measures: Measure[];
354
+ /** 数据行列表 */
355
+ rows: DataRow[];
356
+ }
357
+ /**
358
+ * 日期范围枚举
359
+ */
360
+ export declare enum DateRange {
361
+ Minute = "minute",
362
+ Hour = "hour",
363
+ ToDay = "toDay",
364
+ Yesterday = "yesterday",
365
+ SixDay = "sixDay",
366
+ Month = "month",
367
+ Year = "year"
368
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kweaver-ai/chatkit",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -24,7 +24,8 @@
24
24
  "build": "npm run build:lib && npm run build:types",
25
25
  "build:lib": "vite build --config vite.config.lib.ts",
26
26
  "build:types": "tsc --project tsconfig.lib.json",
27
- "preview": "vite preview"
27
+ "preview": "vite preview",
28
+ "prepare": "npm run build"
28
29
  },
29
30
  "keywords": [
30
31
  "chat",
@@ -63,4 +64,4 @@
63
64
  "vite": "^6.0.3",
64
65
  "vite-plugin-css-injected-by-js": "^3.5.2"
65
66
  }
66
- }
67
+ }