@kweaver-ai/chatkit 0.1.7 → 0.1.9

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.
@@ -1,5 +1,5 @@
1
1
  import { Component } from 'react';
2
- import { ChatMessage, ApplicationContext, ChatKitInterface, OnboardingInfo, WebSearchQuery, ExecuteCodeResult, Text2SqlResult, Text2MetricResult, AfSailorResult, ChartDataSchema } from '../../types';
2
+ import { ChatMessage, ApplicationContext, ChatKitInterface, OnboardingInfo, WebSearchQuery, ExecuteCodeResult, Text2SqlResult, Text2MetricResult, AfSailorResult, DatasourceFilterResult, ChartDataSchema } from '../../types';
3
3
  /**
4
4
  * ChatKitBase 组件的属性接口
5
5
  */
@@ -226,6 +226,13 @@ export declare abstract class ChatKitBase<P extends ChatKitBaseProps = ChatKitBa
226
226
  * @param result AfSailor 的输入和输出结果
227
227
  */
228
228
  protected appendAfSailorBlock(messageId: string, result: AfSailorResult): void;
229
+ /**
230
+ * 添加 DatasourceFilter 工具类型的消息块
231
+ * 该方法由子类调用,用于在消息中添加 DatasourceFilter 查询结果
232
+ * @param messageId 消息 ID
233
+ * @param result DatasourceFilter 的输入和输出结果
234
+ */
235
+ protected appendDatasourceFilterBlock(messageId: string, result: DatasourceFilterResult): void;
229
236
  /**
230
237
  * 创建新的会话
231
238
  * 内部会调用子类实现的 generateConversation() 和 getOnboardingInfo() 方法
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ export interface AgentTitleProps {
3
+ /** Agent 名称 */
4
+ name?: string;
5
+ /** Agent 图标 URL */
6
+ icon?: string;
7
+ }
8
+ /**
9
+ * Agent 标题组件
10
+ * 显示 Agent 的名称和图标,无点击交互
11
+ */
12
+ declare const AgentTitle: React.FC<AgentTitleProps>;
13
+ export default AgentTitle;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { KnowledgeNetworkDetail, ObjectTypeListResponse } from './types';
3
+ export interface KnowledgeNetworksTreeProps {
4
+ /** 知识网络配置项(来自 config.data_source.knowledge_networks 的每一项) */
5
+ knowledgeNetwork: {
6
+ id: string;
7
+ name?: string;
8
+ };
9
+ /** API 调用方法 */
10
+ getKnowledgeNetworksDetail: (id: string) => Promise<KnowledgeNetworkDetail>;
11
+ getKnowledgeNetworkObjectTypes: (id: string) => Promise<ObjectTypeListResponse>;
12
+ }
13
+ /**
14
+ * 知识网络业务组件
15
+ * 负责数据转换和 API 调用,将知识网络数据转换为树组件所需格式
16
+ */
17
+ declare const KnowledgeNetworksTree: React.FC<KnowledgeNetworksTreeProps>;
18
+ export default KnowledgeNetworksTree;
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { KnowledgeNetworkDetail, ObjectTypeListResponse, MetricModel } from './types';
3
+ export interface KnowledgeSourceProps {
4
+ /** 知识网络列表数据 */
5
+ knowledgeNetworks?: Array<{
6
+ id: string;
7
+ name?: string;
8
+ }>;
9
+ /** 指标 ID 列表 */
10
+ metricIds?: string[];
11
+ /** API 调用方法(从 DIPBase 传入) */
12
+ apiMethods?: {
13
+ getKnowledgeNetworksDetail: (id: string) => Promise<KnowledgeNetworkDetail>;
14
+ getKnowledgeNetworkObjectTypes: (id: string) => Promise<ObjectTypeListResponse>;
15
+ getMetricInfoByIds: (ids: string[]) => Promise<MetricModel[]>;
16
+ };
17
+ }
18
+ /**
19
+ * 知识来源组件
20
+ * 作为知识来源的入口组件,提供点击展开/收起功能
21
+ */
22
+ declare const KnowledgeSource: React.FC<KnowledgeSourceProps>;
23
+ export default KnowledgeSource;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { MetricModel } from './types';
3
+ export interface MetricTreeProps {
4
+ /** 指标 ID 列表(来自 config.data_source.metric) */
5
+ metricIds: string[];
6
+ /** API 调用方法 */
7
+ getMetricInfoByIds: (ids: string[]) => Promise<MetricModel[]>;
8
+ }
9
+ /**
10
+ * 指标业务组件
11
+ * 负责数据转换和 API 调用,将指标数据按分组组织,转换为树组件所需格式
12
+ */
13
+ declare const MetricTree: React.FC<MetricTreeProps>;
14
+ export default MetricTree;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { TreeNode } from './types';
3
+ export interface TreeViewProps {
4
+ /** 树节点数据 */
5
+ data: TreeNode[];
6
+ /** 节点点击回调(可选) */
7
+ onNodeClick?: (node: TreeNode) => void;
8
+ /** 节点展开/收起回调(可选) */
9
+ onExpand?: (expandedKeys: string[], node: TreeNode) => void;
10
+ }
11
+ /**
12
+ * 通用树组件
13
+ * 纯展示组件,负责渲染树形结构,自动处理 key 和 id 生成
14
+ */
15
+ declare const TreeView: React.FC<TreeViewProps>;
16
+ export default TreeView;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { KnowledgeNetworkDetail, ObjectTypeListResponse, MetricModel } from './types';
3
+ export interface LeftHeaderToolProps {
4
+ /** DIPBase 的 agentInfo 对象 */
5
+ agentInfo: {
6
+ name?: string;
7
+ avatar?: string;
8
+ config?: {
9
+ data_source?: {
10
+ knowledge_network?: Array<{
11
+ knowledge_network_id: string;
12
+ name?: string;
13
+ }>;
14
+ metric?: Array<{
15
+ metric_model_id: string;
16
+ name?: string;
17
+ }>;
18
+ };
19
+ };
20
+ };
21
+ /** API 调用方法(从 DIPBase 传入) */
22
+ apiMethods?: {
23
+ getKnowledgeNetworksDetail: (id: string) => Promise<KnowledgeNetworkDetail>;
24
+ getKnowledgeNetworkObjectTypes: (id: string) => Promise<ObjectTypeListResponse>;
25
+ getMetricInfoByIds: (ids: string[]) => Promise<MetricModel[]>;
26
+ };
27
+ showAside?: boolean;
28
+ }
29
+ /**
30
+ * LeftHeaderTool 主入口组件
31
+ * 渲染到左侧顶栏位置,包含 AgentTitle 和 KnowledgeSource
32
+ */
33
+ declare const LeftHeaderTool: React.FC<LeftHeaderToolProps>;
34
+ export default LeftHeaderTool;
@@ -0,0 +1,78 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * 树节点数据结构
4
+ * 注意:使用 childrens(复数)作为子节点属性名
5
+ */
6
+ export interface TreeNode {
7
+ /** 节点标题 */
8
+ title: string;
9
+ /** 节点图标(React 节点) */
10
+ icon?: ReactNode;
11
+ /** 节点唯一标识(可选,组件会自动生成) */
12
+ key?: string;
13
+ /** 子节点列表(可选,使用 childrens 而非 children) */
14
+ childrens?: Array<{
15
+ title: string;
16
+ icon?: ReactNode;
17
+ key?: string;
18
+ childrens?: Array<TreeNode>;
19
+ }>;
20
+ }
21
+ /**
22
+ * 知识网络详情接口
23
+ * 参考 agent-app.schemas.yaml#/components/schemas/KnowledgeNetworkDetail
24
+ */
25
+ export interface KnowledgeNetworkDetail {
26
+ id: string;
27
+ name: string;
28
+ tags?: string[];
29
+ comment?: string;
30
+ icon?: string;
31
+ color?: string;
32
+ detail?: string;
33
+ branch?: string;
34
+ business_domain?: string;
35
+ [key: string]: any;
36
+ }
37
+ /**
38
+ * 对象类型列表响应接口
39
+ * 参考 agent-app.schemas.yaml#/components/schemas/ObjectTypeListResponse
40
+ */
41
+ export interface ObjectTypeListResponse {
42
+ entries: ObjectType[];
43
+ total_count: number;
44
+ }
45
+ /**
46
+ * 对象类型接口
47
+ * 参考 agent-app.schemas.yaml#/components/schemas/ObjectType
48
+ */
49
+ export interface ObjectType {
50
+ id: string;
51
+ name: string;
52
+ data_properties: DataProperty[];
53
+ [key: string]: any;
54
+ }
55
+ /**
56
+ * 数据属性接口
57
+ * 参考 agent-app.schemas.yaml#/components/schemas/DataProperty
58
+ */
59
+ export interface DataProperty {
60
+ name: string;
61
+ display_name?: string;
62
+ type: string;
63
+ comment?: string;
64
+ [key: string]: any;
65
+ }
66
+ /**
67
+ * 指标模型接口
68
+ * 参考 agent-app.schemas.yaml#/components/schemas/MetricModel
69
+ */
70
+ export interface MetricModel {
71
+ id: string;
72
+ name: string;
73
+ group_id?: string;
74
+ group_name?: string;
75
+ catalog_id?: string;
76
+ catalog_content?: string;
77
+ [key: string]: any;
78
+ }
@@ -318,6 +318,24 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
318
318
  cites?: any[];
319
319
  result_cache_key?: string;
320
320
  } | null;
321
+ /**
322
+ * 从 skill_info.args 和 answer 中提取 DatasourceFilter 结果
323
+ * 用于处理 datasource_filter 工具的输入和输出
324
+ * 根据 OpenAPI 规范,DatasourceFilterResult 包含 result
325
+ * - result: DatasourceFilterResultData(包含 result、result_cache_key)
326
+ * - result.result: DataCatalogMatch[](数据目录匹配结果列表)
327
+ * @param _args skill_info.args 数组,包含查询参数(当前未使用,保留以保持接口一致性)
328
+ * @param answer 技能执行的 answer 字段,包含数据源过滤结果
329
+ * @returns DatasourceFilterResult 对象,包含 result、result_cache_key 等信息
330
+ */
331
+ extractDatasourceFilterResult(_args: Array<{
332
+ name?: string;
333
+ type?: string;
334
+ value?: string;
335
+ }> | undefined, answer: any): {
336
+ result: Array<any>;
337
+ result_cache_key?: string;
338
+ } | null;
321
339
  /**
322
340
  * 将技能调用或 LLM 回答的内容追加到消息中
323
341
  * 用于历史消息解析,根据 stage 和 skill_info 将内容添加到 ChatMessage.content 数组
@@ -394,6 +412,35 @@ export declare function DIPBaseMixin<TBase extends Constructor>(Base: TBase): {
394
412
  * @returns 返回 Promise,成功时 resolve,失败时 reject
395
413
  */
396
414
  deleteConversation(conversationID: string): Promise<void>;
415
+ /**
416
+ * 获取知识网络详情
417
+ * 调用 DIP 的 GET /api/ontology-manager/v1/knowledge-networks/{id} 接口
418
+ * API 端点: GET /api/ontology-manager/v1/knowledge-networks/{id}
419
+ * 注意:该方法是一个无状态无副作用的函数,不允许修改 state
420
+ * @param id 知识网络 ID
421
+ * @returns 返回知识网络详情
422
+ */
423
+ getKnowledgeNetworksDetail(id: string): Promise<any>;
424
+ /**
425
+ * 获取知识网络的对象类型
426
+ * 调用 DIP 的 GET /api/ontology-manager/v1/knowledge-networks/{id}/object-types 接口
427
+ * API 端点: GET /api/ontology-manager/v1/knowledge-networks/{id}/object-types
428
+ * 注意:该方法是一个无状态无副作用的函数,不允许修改 state
429
+ * @param id 知识网络 ID
430
+ * @param offset 偏移量,默认 0
431
+ * @param limit 每页返回条数,默认 -1(全部)
432
+ * @returns 返回对象类型列表
433
+ */
434
+ getKnowledgeNetworkObjectTypes(id: string, offset?: number, limit?: number): Promise<any>;
435
+ /**
436
+ * 根据指标 ID 获取指标信息
437
+ * 调用 DIP 的 GET /api/mdl-data-model/v1/metric-models/{ids} 接口
438
+ * API 端点: GET /api/mdl-data-model/v1/metric-models/{ids}
439
+ * 注意:该方法是一个无状态无副作用的函数,不允许修改 state
440
+ * @param ids 指标 ID 列表,多个用逗号隔开
441
+ * @returns 返回指标信息列表
442
+ */
443
+ getMetricInfoByIds(ids: string[]): Promise<any[]>;
397
444
  };
398
445
  } & TBase;
399
446
  export {};
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * 知识源图标组件
4
+ */
5
+ export declare const KnowledgeSourceIcon: React.FC<React.SVGProps<SVGSVGElement>>;
6
+ export default KnowledgeSourceIcon;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * 知识网络图标组件
4
+ */
5
+ export declare const KownledgeNetworkIcon: React.FC<React.SVGProps<SVGSVGElement>>;
6
+ export default KownledgeNetworkIcon;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * 指标图标组件
4
+ */
5
+ export declare const MetricIcon: React.FC<React.SVGProps<SVGSVGElement>>;
6
+ export default MetricIcon;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ /**
3
+ * 树节点展开/收起图标(收起态,右箭头 chevron)
4
+ * 展开时由使用方顺时针旋转 90°,收起时逆时针旋转回去
5
+ */
6
+ export declare const TreeExpandIcon: React.FC<React.SVGProps<SVGSVGElement>>;
7
+ export default TreeExpandIcon;
@@ -19,3 +19,6 @@ export { NewIcon } from './NewIcon';
19
19
  export { ExpandIcon } from './ExpandIcon';
20
20
  export { CopyIcon } from './CopyIcon';
21
21
  export { RefreshIcon } from './RefreshIcon';
22
+ export { KnowledgeSourceIcon } from './KnowledgeSourceIcon';
23
+ export { MetricIcon } from './MetricIcon';
24
+ export { TreeExpandIcon } from './TreeExpandIcon';
@@ -244,6 +244,33 @@ export interface AfSailorResult {
244
244
  /** 结果缓存key */
245
245
  result_cache_key?: string;
246
246
  }
247
+ /**
248
+ * 数据目录匹配结果接口
249
+ * 根据 OpenAPI 规范定义
250
+ */
251
+ export interface DataCatalogMatch {
252
+ /** 引用类型 */
253
+ type: 'data_catalog';
254
+ /** 数据目录标题 */
255
+ title: string;
256
+ /** 数据目录ID */
257
+ id: string;
258
+ /** 匹配原因 */
259
+ reason?: string;
260
+ /** 匹配的列信息,键为字段技术名称,值为字段值 */
261
+ matched_columns?: Array<Record<string, string>>;
262
+ }
263
+ /**
264
+ * DatasourceFilter 结果接口
265
+ * DatasourceFilter 工具的输入和输出信息
266
+ * 根据 OpenAPI 规范和设计文档定义
267
+ */
268
+ export interface DatasourceFilterResult {
269
+ /** 数据目录匹配结果列表 */
270
+ result: DataCatalogMatch[];
271
+ /** 结果缓存key */
272
+ result_cache_key?: string;
273
+ }
247
274
  /**
248
275
  * 工具调用数据接口
249
276
  * 工具调用的输入和输出信息
@@ -23,11 +23,17 @@ export interface ToolBlockRegistration {
23
23
  export declare class BlockRegistry {
24
24
  private static registry;
25
25
  /**
26
- * 注册工具信息
26
+ * 注册单个工具信息
27
27
  * @param registration 工具注册信息,包含 name, Icon, onClick
28
- * @throws 如果工具名称已注册,将抛出错误
28
+ * 如果工具已注册,将直接覆盖原有注册信息
29
29
  */
30
30
  static registerTool(registration: ToolBlockRegistration): void;
31
+ /**
32
+ * 批量注册工具信息
33
+ * @param registrations 工具注册信息数组,包含 name, Icon, onClick
34
+ * 如果工具已注册,将直接覆盖原有注册信息
35
+ */
36
+ static registerTools(registrations: Array<ToolBlockRegistration>): void;
31
37
  /**
32
38
  * 取消注册
33
39
  * @param toolName 工具名称
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kweaver-ai/chatkit",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },