@kweaver-ai/chatkit 0.1.1 → 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 +3 -2
@@ -1,5 +1,5 @@
1
1
  import { Component } from 'react';
2
- import { ChatMessage, ApplicationContext, ChatKitInterface, OnboardingInfo, WebSearchQuery, ExecuteCodeResult } from '../../types';
2
+ import { ChatMessage, ApplicationContext, ChatKitInterface, OnboardingInfo, WebSearchQuery, ExecuteCodeResult, Text2SqlResult, ChartDataSchema } from '../../types';
3
3
  /**
4
4
  * ChatKitBase 组件的属性接口
5
5
  */
@@ -93,9 +93,10 @@ export declare abstract class ChatKitBase<P extends ChatKitBaseProps = ChatKitBa
93
93
  * 该方法需要由开发者实现,以适配扣子、Dify 等 LLMOps 平台的接口
94
94
  * 成功返回会话 ID
95
95
  * 注意:该方法是一个无状态无副作用的函数,不允许修改 state
96
+ * @param title 会话标题,通常是用户发送的第一条消息内容
96
97
  * @returns 返回新创建的会话 ID
97
98
  */
98
- abstract generateConversation(): Promise<string>;
99
+ abstract generateConversation(title?: string): Promise<string>;
99
100
  /**
100
101
  * 向后端发送消息 (抽象方法,由子类实现)
101
102
  * 该方法需要由开发者实现,以适配扣子、Dify等 LLMOps 平台的接口
@@ -197,6 +198,20 @@ export declare abstract class ChatKitBase<P extends ChatKitBaseProps = ChatKitBa
197
198
  * @param result 代码执行的输入和输出结果
198
199
  */
199
200
  protected appendExecuteCodeBlock(messageId: string, result: ExecuteCodeResult): void;
201
+ /**
202
+ * 添加 Text2SQL 工具类型的消息块
203
+ * 该方法由子类调用,用于在消息中添加 Text2SQL 查询结果
204
+ * @param messageId 消息 ID
205
+ * @param result Text2SQL 的输入和输出结果
206
+ */
207
+ protected appendText2SqlBlock(messageId: string, result: Text2SqlResult): void;
208
+ /**
209
+ * 添加 JSON2Plot 图表类型的消息块
210
+ * 该方法由子类调用,用于在消息中添加 JSON2Plot 图表数据
211
+ * @param messageId 消息 ID
212
+ * @param chartData 图表数据 Schema
213
+ */
214
+ protected appendJson2PlotBlock(messageId: string, chartData: ChartDataSchema): void;
200
215
  /**
201
216
  * 创建新的会话
202
217
  * 内部会调用子类实现的 generateConversation() 和 getOnboardingInfo() 方法
@@ -1,13 +1,56 @@
1
- import { ChatKitBase, ChatKitBaseProps } from '../ChatKitBase';
1
+ import { ChatKitBase, ChatKitBaseProps, ChatKitBaseState } from '../ChatKitBase';
2
+ /**
3
+ * AssistantBase 组件的属性接口
4
+ * 扩展 ChatKitBaseProps,添加历史对话相关配置
5
+ */
6
+ export interface AssistantBaseProps extends ChatKitBaseProps {
7
+ /** 是否启用历史对话功能,默认为 true */
8
+ enableHistory?: boolean;
9
+ }
10
+ /**
11
+ * AssistantBase 组件的状态接口
12
+ * 扩展 ChatKitBaseState,添加历史对话显示状态
13
+ */
14
+ export interface AssistantBaseState extends ChatKitBaseState {
15
+ showHistory: boolean;
16
+ }
2
17
  /**
3
18
  * AssistantBase 基础组件
4
19
  * 作为主交互入口,是应用的主体
5
20
  *
6
21
  * 该类继承自 ChatKitBase,实现了 Assistant 模式的交互界面和交互逻辑
7
- * 区别于 CopilotBase,AssistantBase 是全屏主对话界面,不包含 Header
8
- * Header(历史对话、新对话等按钮)应由外部应用的侧边栏提供
22
+ * 区别于 CopilotBase,AssistantBase 是全屏主对话界面,包含 Header 和历史对话功能
9
23
  */
10
- export declare abstract class AssistantBase<P extends ChatKitBaseProps = ChatKitBaseProps> extends ChatKitBase<P> {
24
+ export declare abstract class AssistantBase<P extends AssistantBaseProps = AssistantBaseProps> extends ChatKitBase<P> {
25
+ /**
26
+ * 组件状态,包含历史对话显示状态
27
+ */
28
+ state: AssistantBaseState;
29
+ constructor(props: P);
30
+ /**
31
+ * 处理查看历史对话
32
+ */
33
+ handleHistory: () => void;
34
+ /**
35
+ * 处理关闭历史对话列表
36
+ */
37
+ handleCloseHistory: () => void;
38
+ /**
39
+ * 处理新建对话
40
+ */
41
+ handleNewChat: () => void;
42
+ /**
43
+ * 处理加载指定会话
44
+ */
45
+ handleLoadConversation: (conversationId: string) => Promise<void>;
46
+ /**
47
+ * 处理删除指定会话
48
+ */
49
+ handleDeleteConversation: (conversationId: string) => Promise<void>;
50
+ /**
51
+ * 处理获取历史会话列表
52
+ */
53
+ handleGetConversations: (page?: number, size?: number) => Promise<import("../../..").ConversationHistory[]>;
11
54
  /**
12
55
  * 实现 React.Component.render() 方法
13
56
  * 渲染 Assistant 模式的界面
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { ConversationHistory as ConversationHistoryType } from '../../../types';
3
+ /**
4
+ * 历史会话列表组件的属性接口
5
+ */
6
+ interface ConversationHistoryProps {
7
+ /** 是否显示历史会话列表 */
8
+ visible: boolean;
9
+ /** 关闭历史会话列表的回调函数 */
10
+ onClose: () => void;
11
+ /** 获取历史会话列表的函数 */
12
+ onGetConversations: (page?: number, size?: number) => Promise<ConversationHistoryType[]>;
13
+ /** 加载指定会话的回调函数 */
14
+ onLoadConversation: (conversationId: string) => void;
15
+ /** 删除指定会话的回调函数 */
16
+ onDeleteConversation: (conversationId: string) => Promise<void>;
17
+ /** Agent Name (agent 名称) */
18
+ agentName?: string;
19
+ }
20
+ /**
21
+ * 历史会话列表组件
22
+ * 右侧滑出面板,展示用户的历史会话记录,支持加载和删除操作
23
+ * 设计参考:https://www.figma.com/design/AnGlsx50RkpJgY9irtMtwr/chatkit-max?node-id=14-1901
24
+ */
25
+ export declare const ConversationHistory: React.FC<ConversationHistoryProps>;
26
+ export default ConversationHistory;
@@ -6,6 +6,8 @@ import { ChatMessage } from '../../../types';
6
6
  interface MessageItemProps {
7
7
  /** 消息对象 */
8
8
  message: ChatMessage;
9
+ /** 是否正在流式更新 */
10
+ isStreaming?: boolean;
9
11
  }
10
12
  /**
11
13
  * MessageItem 组件
@@ -6,6 +6,8 @@ import { ChatMessage } from '../../../types';
6
6
  interface MessageListProps {
7
7
  /** 消息列表 */
8
8
  messages: ChatMessage[];
9
+ /** 当前正在流式更新的消息 ID */
10
+ streamingMessageId?: string | null;
9
11
  }
10
12
  /**
11
13
  * MessageList 组件
@@ -3,6 +3,8 @@ import React from 'react';
3
3
  * Prologue 组件的属性接口
4
4
  */
5
5
  interface PrologueProps {
6
+ /** Agent 信息 */
7
+ agentInfo?: any;
6
8
  /** 点击推荐问题时的回调函数 */
7
9
  onQuestionClick?: (question: string) => void;
8
10
  /** 开场白文案 */
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ /**
3
+ * CodeViewTool 组件的属性接口
4
+ */
5
+ export interface CodeViewToolProps {
6
+ /** 代码内容 */
7
+ code: string;
8
+ /** 代码语言类型(python、sql、javascript等) */
9
+ language?: string;
10
+ /** 编辑器宽度 */
11
+ width?: string | number;
12
+ /** 编辑器高度 */
13
+ height?: string | number;
14
+ /** 自定义样式类名 */
15
+ className?: string;
16
+ }
17
+ /**
18
+ * CodeViewTool 组件
19
+ * 用于在 ToolDrawer 中展示代码(Python、SQL等)的代码查看组件
20
+ */
21
+ declare const CodeViewTool: React.FC<CodeViewToolProps>;
22
+ export default CodeViewTool;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * SQL 格式化选项
3
+ */
4
+ export interface SqlFormatOptions {
5
+ /** 缩进字符,默认为2个空格 */
6
+ indent?: string;
7
+ /** 是否大写关键字,默认为true */
8
+ uppercase?: boolean;
9
+ /** SQL 语言类型,默认为 'sql' */
10
+ language?: string;
11
+ }
12
+ /**
13
+ * 格式化 SQL 代码
14
+ *
15
+ * @param sql - 需要格式化的 SQL 代码
16
+ * @param options - 格式化选项
17
+ * @returns 格式化后的 SQL 代码,格式化失败时返回原始代码
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const formatted = formatSql('SELECT * FROM users WHERE id=1');
22
+ * ```
23
+ */
24
+ export declare const formatSql: (sql: string, options?: SqlFormatOptions) => string;
@@ -0,0 +1,4 @@
1
+ export { default as CodeViewTool } from './CodeViewTool';
2
+ export type { CodeViewToolProps } from './CodeViewTool';
3
+ export { formatSql } from './SqlFormatter';
4
+ export type { SqlFormatOptions } from './SqlFormatter';
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import type { ChartDataSchema, ChartType } from '../../../../../types';
3
+ /**
4
+ * EChartsView 组件的属性接口
5
+ */
6
+ export interface EChartsViewProps {
7
+ /** 图表数据 Schema */
8
+ data: ChartDataSchema;
9
+ /** 图表类型 */
10
+ chartType: ChartType;
11
+ /** 图表宽度 */
12
+ width?: string | number;
13
+ /** 图表高度 */
14
+ height?: string | number;
15
+ /** 是否可点击(用于打开弹窗) */
16
+ clickable?: boolean;
17
+ /** 点击回调 */
18
+ onClick?: () => void;
19
+ }
20
+ /**
21
+ * EChartsView 组件
22
+ * 纯图表渲染组件,负责使用 ECharts 渲染图表
23
+ */
24
+ declare const EChartsView: React.FC<EChartsViewProps>;
25
+ export default EChartsView;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { ChartDataSchema } from '../../../../../types';
3
+ /**
4
+ * Json2PlotContentView 组件的属性接口
5
+ */
6
+ export interface Json2PlotContentViewProps {
7
+ /** 图表数据 Schema */
8
+ data: ChartDataSchema;
9
+ /** 图表宽度 */
10
+ width?: string | number;
11
+ /** 图表高度 */
12
+ height?: string | number;
13
+ /** 点击图表回调(用于打开弹窗) */
14
+ onChartClick?: () => void;
15
+ }
16
+ /**
17
+ * Json2PlotContentView 组件
18
+ * 包含标题栏和内容区域,整合 EChartsView 和 TableView
19
+ */
20
+ declare const Json2PlotContentView: React.FC<Json2PlotContentViewProps>;
21
+ export default Json2PlotContentView;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import type { ChartDataSchema, ChartType } from '../../../../../types';
3
+ /**
4
+ * Json2PlotModal 组件的属性接口
5
+ */
6
+ export interface Json2PlotModalProps {
7
+ /** 是否显示弹窗 */
8
+ open: boolean;
9
+ /** 关闭弹窗回调 */
10
+ onClose: () => void;
11
+ /** 图表数据 Schema */
12
+ data: ChartDataSchema;
13
+ /** 初始视图类型:'table' 或图表类型 */
14
+ initialViewType?: 'table' | ChartType;
15
+ }
16
+ /**
17
+ * Json2PlotModal 组件
18
+ * 弹窗组件,包含菜单栏和内容区域,整合 EChartsView 和 TableView
19
+ */
20
+ declare const Json2PlotModal: React.FC<Json2PlotModalProps>;
21
+ export default Json2PlotModal;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import type { ChartDataSchema } from '../../../../../types';
3
+ /**
4
+ * TableView 组件的属性接口
5
+ */
6
+ export interface TableViewProps {
7
+ /** 图表数据 Schema */
8
+ data: ChartDataSchema;
9
+ /** 表格最大高度 */
10
+ maxHeight?: string | number;
11
+ /** 是否启用分页,默认 false */
12
+ pagination?: boolean;
13
+ /** 每页显示条数,默认 10 */
14
+ pageSize?: number;
15
+ }
16
+ /**
17
+ * TableView 组件
18
+ * 纯表格渲染组件,负责渲染数据表格
19
+ */
20
+ declare const TableView: React.FC<TableViewProps>;
21
+ export default TableView;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Json2PlotBlock 组件导出文件
3
+ */
4
+ export { default as EChartsView } from './EChartsView';
5
+ export { default as TableView } from './TableView';
6
+ export { default as Json2PlotModal } from './Json2PlotModal';
7
+ export type { EChartsViewProps } from './EChartsView';
8
+ export type { TableViewProps } from './TableView';
9
+ export type { Json2PlotModalProps } from './Json2PlotModal';
@@ -0,0 +1,14 @@
1
+ import type { EChartsOption } from 'echarts';
2
+ import { ChartDataSchema, ChartType } from '../../../../../types';
3
+ /**
4
+ * 格式化日期
5
+ */
6
+ export declare function formatDate(value: any): string;
7
+ /**
8
+ * 验证数据是否可以转换为指定图表类型
9
+ */
10
+ export declare function validateChartType(data: ChartDataSchema, targetType: ChartType): string | null;
11
+ /**
12
+ * 转换 ChartDataSchema 到 ECharts Option
13
+ */
14
+ export declare function convertToEChartsOption(data: ChartDataSchema, chartType: ChartType): EChartsOption | null;
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { Json2PlotBlock as Json2PlotBlockType } from '../../../../types';
3
+ /**
4
+ * Json2PlotBlock 组件的属性接口
5
+ */
6
+ export interface Json2PlotBlockProps {
7
+ /** JSON2Plot 图表块数据 */
8
+ block: Json2PlotBlockType;
9
+ /** 图表宽度 */
10
+ width?: string | number;
11
+ /** 图表高度 */
12
+ height?: string | number;
13
+ }
14
+ /**
15
+ * Json2PlotBlock 组件
16
+ * 主组件,包含标题栏和菜单栏,整合 EChartsView 和 TableView
17
+ */
18
+ declare const Json2PlotBlock: React.FC<Json2PlotBlockProps>;
19
+ export default Json2PlotBlock;
20
+ export { Json2PlotBlock };
@@ -6,6 +6,10 @@ import { MarkdownBlock as MarkdownBlockType } from '../../../../types';
6
6
  export interface MarkdownBlockProps {
7
7
  /** Markdown 块数据 */
8
8
  block: MarkdownBlockType;
9
+ /** 基础字号,单位 px,默认为 14 */
10
+ fontSize?: number;
11
+ /** 基础字体颜色,默认为 rgba(0, 0, 0, 0.85) */
12
+ fontColor?: string;
9
13
  }
10
14
  /**
11
15
  * MarkdownBlock 组件
@@ -7,3 +7,6 @@ export { default as MarkdownBlock } from './MarkdownBlock';
7
7
  export { default as WebSearchBlock } from './WebSearchBlock';
8
8
  export { default as ToolBlock } from './ToolBlock';
9
9
  export { default as ToolDrawer } from './ToolDrawer';
10
+ export { default as Json2PlotBlock } from './Json2PlotBlock';
11
+ export { CodeViewTool } from './CodeViewTool';
12
+ export type { CodeViewToolProps } from './CodeViewTool';
@@ -6,6 +6,8 @@ import { ChatMessage } from '../../../types';
6
6
  interface MessageItemProps {
7
7
  /** 消息对象 */
8
8
  message: ChatMessage;
9
+ /** 是否正在流式更新 */
10
+ isStreaming?: boolean;
9
11
  }
10
12
  /**
11
13
  * MessageItem 组件
@@ -6,6 +6,8 @@ import { ChatMessage } from '../../../types';
6
6
  interface MessageListProps {
7
7
  /** 消息列表 */
8
8
  messages: ChatMessage[];
9
+ /** 当前正在流式更新的消息 ID */
10
+ streamingMessageId?: string | null;
9
11
  }
10
12
  /**
11
13
  * MessageList 组件
@@ -6,6 +6,10 @@ import { MarkdownBlock as MarkdownBlockType } from '../../../../types';
6
6
  export interface MarkdownBlockProps {
7
7
  /** Markdown 块数据 */
8
8
  block: MarkdownBlockType;
9
+ /** 基础字号,单位 px,默认为 14 */
10
+ fontSize?: number;
11
+ /** 基础字体颜色,默认为 rgba(0, 0, 0, 0.85) */
12
+ fontColor?: string;
9
13
  }
10
14
  /**
11
15
  * MarkdownBlock 组件
@@ -1,4 +1,4 @@
1
- import { ApplicationContext, ChatMessage, OnboardingInfo, WebSearchQuery, ConversationHistory } from '../../types';
1
+ import { ApplicationContext, ChatMessage, OnboardingInfo, WebSearchQuery, ChartDataSchema, ConversationHistory } from '../../types';
2
2
  import { Constructor } from '../../utils/mixins';
3
3
  /**
4
4
  * DIP 的 AssistantMessage 接口
@@ -10,13 +10,6 @@ interface AssistantMessage {
10
10
  conversation_id?: string;
11
11
  role?: string;
12
12
  content?: {
13
- final_answer?: {
14
- thinking?: string;
15
- answer?: {
16
- text?: string;
17
- };
18
- answer_type_other?: OtherTypeAnswer;
19
- };
20
13
  middle_answer?: {
21
14
  progress?: Progress[];
22
15
  };
@@ -71,8 +64,8 @@ interface EventMessage {
71
64
  * DIPBase 的 props 接口
72
65
  */
73
66
  export interface DIPBaseProps {
74
- /** AISHU DIP 的 Agent ID,用作路径参数 */
75
- agentId: string;
67
+ /** AISHU DIP 的 Agent Key,用作路径参数 */
68
+ agentKey: string;
76
69
  /** 访问令牌,需要包含 Bearer 前缀 (已废弃,请使用 token 属性) */
77
70
  bearerToken?: string;
78
71
  /** 服务端基础地址,应包含 /api/agent-app/v1 前缀 */
@@ -106,8 +99,10 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
106
99
  new (...args: any[]): {
107
100
  /** 服务端基础地址 */
108
101
  dipBaseUrl: string;
109
- /** Agent ID */
110
- dipId: string;
102
+ /** Agent Key (agent 标识) */
103
+ dipKey: string;
104
+ /** Agent 信息 */
105
+ agentInfo: any;
111
106
  /** agent 版本 */
112
107
  dipVersion: string;
113
108
  /** 智能体执行引擎版本 */
@@ -121,7 +116,7 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
121
116
  /**
122
117
  * 获取开场白和预置问题
123
118
  * 调用 AISHU DIP 的 agent-factory API 获取智能体配置信息,提取开场白和预置问题
124
- * API 端点: GET /api/agent-factory/v3/agent-market/agent/{agent_id}/version/v0
119
+ * API 端点: GET /api/agent-factory/v3/agent-market/agent/{agent_key}/version/v0
125
120
  * 注意:该方法是一个无状态无副作用的函数,不允许修改 state
126
121
  * @returns 返回开场白信息,包含开场白文案和预置问题
127
122
  */
@@ -129,11 +124,12 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
129
124
  /**
130
125
  * 创建新的会话
131
126
  * 调用 DIP API 创建新的会话,返回会话 ID
132
- * API 端点: POST /app/{agent_id}/conversation
127
+ * API 端点: POST /app/{agent_key}/conversation
133
128
  * 注意:该方法是一个无状态无副作用的函数,不允许修改 state
129
+ * @param title 会话标题,通常是用户发送的第一条消息内容
134
130
  * @returns 返回新创建的会话 ID
135
131
  */
136
- generateConversation(): Promise<string>;
132
+ generateConversation(title?: string): Promise<string>;
137
133
  /**
138
134
  * 调用 DIP API 发送消息(流式)
139
135
  * 该方法实现了完整的消息发送逻辑,子类无需覆盖
@@ -158,8 +154,8 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
158
154
  parseEventMessage(raw: any): EventMessage;
159
155
  /**
160
156
  * 将 key 数组转换为 JSONPath 字符串
161
- * 例如: ["message", "content", "final_answer", "answer", "text"]
162
- * => "message.content.final_answer.answer.text"
157
+ * 例如: ["message", "content", "middle_answer", "progress", 0]
158
+ * => "message.content.middle_answer.progress[0]"
163
159
  */
164
160
  keyToJSONPath(key: Array<string | number>): string;
165
161
  /**
@@ -178,6 +174,19 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
178
174
  * tool_calls[0] 是 SearchIntent(输入),tool_calls[1] 是 SearchResult(输出)
179
175
  */
180
176
  extractWebSearchQuery(progress: any): WebSearchQuery | null;
177
+ /**
178
+ * 从 Progress 对象中提取 Json2Plot 图表数据
179
+ * 根据 OpenAPI 规范,Json2Plot 数据在 answer.choices[0].message.tool_calls 中
180
+ * tool_calls 中包含 Json2PlotAnswer,格式为 { result: Json2PlotResult, full_result: Json2PlotFullResult }
181
+ * Json2PlotResult 包含: data_sample, chart_config, title, text
182
+ * Json2PlotFullResult 包含: data, chart_config, title, text
183
+ * ChartConfig 包含: xField, yField, seriesField, chart_type, groupField, isStack, isGroup
184
+ */
185
+ extractJson2PlotData(progress: any): ChartDataSchema | null;
186
+ /**
187
+ * 推断数据类型
188
+ */
189
+ inferDataType(value: any): "string" | "number" | "date" | "boolean";
181
190
  /**
182
191
  * 处理技能调用的统一方法
183
192
  * 根据设计文档 3.2 Event Message 白名单中的后处理逻辑
@@ -186,13 +195,6 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
186
195
  * @param messageId 消息 ID
187
196
  */
188
197
  processSkillExecution(skillInfo: SkillInfo | undefined, answer: any, messageId: string): void;
189
- /**
190
- * 处理 final_answer.answer_type_other
191
- * 根据设计文档 3.2 Event Message 白名单中的后处理逻辑
192
- * @param content OtherTypeAnswer 对象
193
- * @param messageId 消息 ID
194
- */
195
- processFinalAnswerTypeOther(content: OtherTypeAnswer, messageId: string): void;
196
198
  /**
197
199
  * 处理 middle_answer.progress 中的一个元素
198
200
  * 根据设计文档 3.2 Event Message 白名单中的后处理逻辑
@@ -202,18 +204,21 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
202
204
  processMiddleAnswerProgress(content: Progress, messageId: string): void;
203
205
  /**
204
206
  * 从 answer.choices 中提取 Web 搜索查询
205
- * 用于处理 final_answer.answer_type_other 和 middle_answer.progress 中的搜索结果
207
+ * 用于处理 middle_answer.progress 中的搜索结果
206
208
  */
207
209
  extractWebSearchQueryFromAnswer(answer: any): WebSearchQuery | null;
208
210
  /**
209
- * 从 skill_info.args 中提取图表数据
211
+ * 从 skill_info.args 和 answer 中提取图表数据并转换为 ChartDataSchema
210
212
  * 用于处理 json2plot 工具的输出
213
+ * @param args 技能参数数组(保留用于 API 一致性,实际数据从 answer 中提取)
214
+ * @param answer 技能执行的 answer 字段,包含 result 或 full_result
215
+ * @returns ChartDataSchema 对象,如果解析失败则返回 null
211
216
  */
212
- extractChartDataFromArgs(args: Array<{
217
+ extractChartDataFromArgs(_args: Array<{
213
218
  name?: string;
214
219
  type?: string;
215
220
  value?: string;
216
- }> | undefined): any;
221
+ }> | undefined, answer: any): ChartDataSchema | null;
217
222
  /**
218
223
  * 从 skill_info.args 和 answer 中提取代码执行结果
219
224
  * 用于处理 execute_code 工具的输入和输出
@@ -229,6 +234,39 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
229
234
  input: string;
230
235
  output: string;
231
236
  } | null;
237
+ /**
238
+ * 从 skill_info.args 和 answer 中提取 Text2SQL 结果
239
+ * 用于处理 text2sql 工具的输入和输出
240
+ * 根据 OpenAPI 规范,Text2SqlResult 包含 result 和 full_result
241
+ * - result: Text2SqlResultData(包含 data_desc,但可能只有数据样本)
242
+ * - full_result: Text2SqlFullResultData(包含完整数据,但没有 data_desc)
243
+ * 优先使用 full_result,如果没有则使用 result
244
+ * @param args skill_info.args 数组,包含查询文本
245
+ * @param answer 技能执行的 answer 字段,包含 SQL 执行结果
246
+ * @returns Text2SqlResult 对象,包含 input、sql、data 等信息
247
+ */
248
+ extractText2SqlResult(args: Array<{
249
+ name?: string;
250
+ type?: string;
251
+ value?: string;
252
+ }> | undefined, answer: any): {
253
+ input: string;
254
+ sql: string;
255
+ data?: Array<Record<string, any>>;
256
+ cites?: Array<{
257
+ id: string;
258
+ name: string;
259
+ type: string;
260
+ description?: string;
261
+ }>;
262
+ title?: string;
263
+ message?: string;
264
+ dataDesc?: {
265
+ return_records_num?: number;
266
+ real_records_num?: number;
267
+ };
268
+ explanation?: any;
269
+ } | null;
232
270
  /**
233
271
  * 将技能调用或 LLM 回答的内容追加到消息中
234
272
  * 用于历史消息解析,根据 stage 和 skill_info 将内容添加到 ChatMessage.content 数组
@@ -265,7 +303,7 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
265
303
  shouldRefreshToken(status: number, _error: any): boolean;
266
304
  /**
267
305
  * 终止会话
268
- * 调用 DIP 的 /app/{agent_id}/chat/termination 接口终止指定会话
306
+ * 调用 DIP 的 /app/{agent_key}/chat/termination 接口终止指定会话
269
307
  * @param conversationId 要终止的会话 ID
270
308
  * @returns 返回 Promise,成功时 resolve,失败时 reject
271
309
  */
@@ -278,8 +316,8 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
278
316
  executeDataAgentWithTokenRefresh<T>(apiCall: () => Promise<T>): Promise<T>;
279
317
  /**
280
318
  * 获取历史会话列表
281
- * 调用 DIP 的 GET /app/{agent_id}/conversation 接口获取会话列表
282
- * API 端点: GET /app/{agent_id}/conversation?page={page}&size={size}
319
+ * 调用 DIP 的 GET /app/{agent_key}/conversation 接口获取会话列表
320
+ * API 端点: GET /app/{agent_key}/conversation?page={page}&size={size}
283
321
  * 注意:该方法是一个无状态无副作用的函数,不允许修改 state
284
322
  * @param page 分页页码,默认为 1
285
323
  * @param size 每页返回条数,默认为 10
@@ -288,9 +326,9 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
288
326
  getConversations(page?: number, size?: number): Promise<ConversationHistory[]>;
289
327
  /**
290
328
  * 获取指定会话 ID 的对话消息列表
291
- * 调用 DIP 的 GET /app/{agent_id}/conversation/{conversation_id} 接口获取会话详情
329
+ * 调用 DIP 的 GET /app/{agent_key}/conversation/{conversation_id} 接口获取会话详情
292
330
  * 如果对话消息是 AI 助手消息,则需要调用 reduceAssistantMessage() 解析消息
293
- * API 端点: GET /app/{agent_id}/conversation/{conversation_id}
331
+ * API 端点: GET /app/{agent_key}/conversation/{conversation_id}
294
332
  * 注意:该方法是一个无状态无副作用的函数,不允许修改 state
295
333
  * @param conversationId 会话 ID
296
334
  * @returns 返回对话消息列表
@@ -298,8 +336,8 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
298
336
  getConversationMessages(conversationId: string): Promise<ChatMessage[]>;
299
337
  /**
300
338
  * 删除指定 ID 的会话
301
- * 调用 DIP 的 DELETE /app/{agent_id}/conversation/{conversation_id} 接口删除会话
302
- * API 端点: DELETE /app/{agent_id}/conversation/{conversation_id}
339
+ * 调用 DIP 的 DELETE /app/{agent_key}/conversation/{conversation_id} 接口删除会话
340
+ * API 端点: DELETE /app/{agent_key}/conversation/{conversation_id}
303
341
  * 注意:该方法是一个无状态无副作用的函数,不允许修改 state
304
342
  * @param conversationID 会话 ID
305
343
  * @returns 返回 Promise,成功时 resolve,失败时 reject
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * Assistant 图标组件
4
+ */
5
+ export declare const AssistantIcon: React.FC<React.SVGProps<SVGSVGElement>>;
6
+ export default AssistantIcon;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * 柱状图图标组件
4
+ */
5
+ export declare const ColumnIcon: React.FC<React.SVGProps<SVGSVGElement>>;
6
+ export default ColumnIcon;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * 展开图标组件
4
+ */
5
+ export declare const ExpandIcon: React.FC<React.SVGProps<SVGSVGElement>>;
6
+ export default ExpandIcon;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * JSON Plot 图标组件
4
+ */
5
+ export declare const JsonPlotIcon: React.FC<React.SVGProps<SVGSVGElement>>;
6
+ export default JsonPlotIcon;