@ibiz-template-plugin/ai-chat 0.0.30 → 0.0.32
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/index.es.js +2919 -2617
- package/dist/index.legacy.js +1 -1
- package/dist/polyfills.legacy.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/app.d.ts +1 -0
- package/dist/types/components/chat-back-bottom/chat-back-bottom.d.ts +1 -0
- package/dist/types/components/chat-container/chat-container.d.ts +19 -4
- package/dist/types/components/chat-input/chat-input.d.ts +2 -1
- package/dist/types/components/chat-input-material/chat-input-material.d.ts +1 -0
- package/dist/types/components/chat-input-material-item/chat-input-material-item.d.ts +1 -0
- package/dist/types/components/chat-input-material-item/common-material/common-material.d.ts +1 -0
- package/dist/types/components/chat-input-material-item/ossfile-material/ossfile-material.d.ts +1 -0
- package/dist/types/components/chat-message-item/chat-message-item.d.ts +1 -0
- package/dist/types/components/chat-message-item/error-message/error-message.d.ts +1 -0
- package/dist/types/components/chat-message-item/markdown-message/markdown-message.d.ts +1 -0
- package/dist/types/components/chat-message-item/unknown-message/unknown-message.d.ts +1 -0
- package/dist/types/components/chat-message-item/user-message/user-message.d.ts +1 -0
- package/dist/types/components/chat-messages/chat-messages.d.ts +1 -0
- package/dist/types/components/chat-minimize/chat-minimize.d.ts +1 -0
- package/dist/types/components/chat-search/chat-search.d.ts +1 -0
- package/dist/types/components/chat-suggestions/chat-suggestions.d.ts +1 -0
- package/dist/types/components/chat-thought-chain/chat-thought-chain.d.ts +1 -0
- package/dist/types/components/chat-tool-call/chat-tool-call.d.ts +1 -0
- package/dist/types/components/chat-tool-call-item/chat-tool-call-item.d.ts +1 -0
- package/dist/types/components/chat-toolbar/chat-toolbar-item/chat-toolbar-item.d.ts +1 -0
- package/dist/types/components/chat-toolbar/chat-toolbar.d.ts +1 -0
- package/dist/types/components/chat-topic-item/chat-topic-item.d.ts +1 -0
- package/dist/types/components/chat-topics/chat-topics.d.ts +1 -0
- package/dist/types/components/popup/popup.d.ts +6 -5
- package/dist/types/controller/ai-chat/ai-chat.controller.d.ts +17 -12
- package/dist/types/controller/ai-material/ai-material-factory.d.ts +1 -0
- package/dist/types/controller/ai-material/common-helper.d.ts +1 -0
- package/dist/types/controller/ai-material/file-helper.d.ts +1 -0
- package/dist/types/controller/ai-material/material-helper.d.ts +1 -0
- package/dist/types/controller/ai-topic/ai-topic.controller.d.ts +1 -0
- package/dist/types/controller/chat/chat.controller.d.ts +1 -0
- package/dist/types/entity/chart-material/chart-material.d.ts +1 -0
- package/dist/types/entity/chart-topic/chart-topic.d.ts +1 -0
- package/dist/types/entity/chat-message/chat-message.d.ts +14 -0
- package/dist/types/entity/chat-suggestion/chat-suggestion.d.ts +1 -0
- package/dist/types/global.d.ts +1 -0
- package/dist/types/icons/more-svg.d.ts +2 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/interface/i-chat-message/i-chat-message.d.ts +1 -0
- package/dist/types/interface/i-chat-options/i-chat-options.d.ts +49 -0
- package/dist/types/interface/i-chat-toolbar-item/i-chat-toolbar-item.d.ts +1 -0
- package/dist/types/interface/i-container-options/i-container-options.d.ts +1 -0
- package/dist/types/interface/i-topic-options/i-topic-options.d.ts +1 -0
- package/dist/types/interface/index.d.ts +1 -1
- package/dist/types/utils/util/chat-suggestion-parser.d.ts +1 -0
- package/dist/types/utils/util/chat-tool-call-parser.d.ts +1 -0
- package/dist/types/utils/util/file-uploader.d.ts +1 -0
- package/dist/types/utils/util/material-resource-parser.d.ts +1 -0
- package/package.json +5 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Component } from 'preact';
|
|
2
2
|
import { Namespace } from '../../utils';
|
|
3
3
|
import { AiChatController, AiTopicController } from '../../controller';
|
|
4
|
-
import { IChatToolbarItem, IChatContainerOptions } from '../../interface';
|
|
4
|
+
import { IChatToolbarItem, IChatContainerOptions, IAutoClose } from '../../interface';
|
|
5
|
+
|
|
5
6
|
export interface ChatContainerProps {
|
|
6
7
|
/**
|
|
7
8
|
* 呈现模式
|
|
@@ -91,6 +92,20 @@ export interface ChatContainerProps {
|
|
|
91
92
|
* @type {IChatContainerOptions}
|
|
92
93
|
*/
|
|
93
94
|
containerOptions?: IChatContainerOptions;
|
|
95
|
+
/**
|
|
96
|
+
* 自动关闭
|
|
97
|
+
*
|
|
98
|
+
* @type {IAutoClose}
|
|
99
|
+
* @memberof ChatContainerProps
|
|
100
|
+
*/
|
|
101
|
+
autoClose?: IAutoClose;
|
|
102
|
+
/**
|
|
103
|
+
* @description AI窗口的打开模式
|
|
104
|
+
* - default:默认;minimize:最小化;autoexpand:自动展开
|
|
105
|
+
* @type {('default' | 'minimize' | 'autoexpand')}
|
|
106
|
+
* @memberof IChat
|
|
107
|
+
*/
|
|
108
|
+
openMode?: 'default' | 'minimize' | 'autoexpand';
|
|
94
109
|
}
|
|
95
110
|
interface ChatContainerState {
|
|
96
111
|
/**
|
|
@@ -113,7 +128,7 @@ interface ContainerContext {
|
|
|
113
128
|
enableBackFill: boolean;
|
|
114
129
|
newTopic: Function;
|
|
115
130
|
}
|
|
116
|
-
export declare const ContainerContext: import(
|
|
131
|
+
export declare const ContainerContext: import('preact').Context<ContainerContext>;
|
|
117
132
|
/**
|
|
118
133
|
* 聊天窗口容器,可拖拽,可缩放
|
|
119
134
|
*
|
|
@@ -126,8 +141,8 @@ export declare const ContainerContext: import("preact").Context<ContainerContext
|
|
|
126
141
|
export declare class ChatContainer extends Component<ChatContainerProps, ChatContainerState> {
|
|
127
142
|
constructor(props: ChatContainerProps | undefined);
|
|
128
143
|
ns: Namespace;
|
|
129
|
-
containerRef: import(
|
|
130
|
-
dragHandle: import(
|
|
144
|
+
containerRef: import('preact').RefObject<HTMLDivElement>;
|
|
145
|
+
dragHandle: import('preact').RefObject<HTMLDivElement>;
|
|
131
146
|
/**
|
|
132
147
|
* 窗口样式数据
|
|
133
148
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AiChatController } from '../../controller';
|
|
2
2
|
import { IChatToolbarItem } from '../../interface';
|
|
3
|
+
|
|
3
4
|
export interface ChatInputProps {
|
|
4
5
|
/**
|
|
5
6
|
* 单实例聊天总控
|
|
@@ -18,4 +19,4 @@ export interface ChatInputProps {
|
|
|
18
19
|
*/
|
|
19
20
|
questionToolbarItems?: IChatToolbarItem[];
|
|
20
21
|
}
|
|
21
|
-
export declare const ChatInput: (props: ChatInputProps) => import("preact
|
|
22
|
+
export declare const ChatInput: (props: ChatInputProps) => import("preact").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VNode } from 'preact';
|
|
2
|
+
|
|
2
3
|
type Position = 'top' | 'bottom' | 'left' | 'right' | 'top-left';
|
|
3
4
|
interface ActionItem {
|
|
4
5
|
id: string;
|
|
@@ -7,11 +8,11 @@ interface ActionItem {
|
|
|
7
8
|
}
|
|
8
9
|
export declare const Popup: ({ children, actions, content, position, isOpen: isOpenProp, onToggleOpen, onAction, }: {
|
|
9
10
|
children: import('preact').ComponentChildren;
|
|
10
|
-
actions?: ActionItem[]
|
|
11
|
+
actions?: ActionItem[];
|
|
11
12
|
content?: import('preact').ComponentChildren;
|
|
12
|
-
position?: Position
|
|
13
|
-
isOpen?: boolean
|
|
14
|
-
onToggleOpen?: (
|
|
15
|
-
onAction?: (
|
|
13
|
+
position?: Position;
|
|
14
|
+
isOpen?: boolean;
|
|
15
|
+
onToggleOpen?: (isOpen: boolean) => void;
|
|
16
|
+
onAction?: (actionId: string, event: MouseEvent) => void;
|
|
16
17
|
}) => import("preact").JSX.Element;
|
|
17
18
|
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Signal } from '@preact/signals';
|
|
2
|
+
import { QXEvent } from 'qx-util';
|
|
2
3
|
import { ChatMessage } from '../../entity';
|
|
3
|
-
import {
|
|
4
|
+
import { ITopic, IMaterial, IChatMessage, IChatOptions, IChatSuggestion } from '../../interface';
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* 聊天逻辑控制器
|
|
6
8
|
*
|
|
@@ -11,6 +13,13 @@ import { IChatMessage, IChatOptions, IChatSuggestion, IMaterial, ITopic } from '
|
|
|
11
13
|
*/
|
|
12
14
|
export declare class AiChatController {
|
|
13
15
|
readonly opts: IChatOptions;
|
|
16
|
+
/**
|
|
17
|
+
* 事件触发器
|
|
18
|
+
* @type {EventBase}
|
|
19
|
+
*/
|
|
20
|
+
evt: QXEvent<{
|
|
21
|
+
[p: string]: (...args: any[]) => any;
|
|
22
|
+
}>;
|
|
14
23
|
/**
|
|
15
24
|
* 聊天记录
|
|
16
25
|
*
|
|
@@ -89,17 +98,6 @@ export declare class AiChatController {
|
|
|
89
98
|
* @memberof AiChatController
|
|
90
99
|
*/
|
|
91
100
|
chatSessionid: string;
|
|
92
|
-
/**
|
|
93
|
-
* 聊天窗触发提问回调
|
|
94
|
-
*
|
|
95
|
-
* @author tony001
|
|
96
|
-
* @date 2025-02-24 14:02:51
|
|
97
|
-
* @param {object} context
|
|
98
|
-
* @param {object} params
|
|
99
|
-
* @param {object} otherParams
|
|
100
|
-
* @param {IChatMessage[]} question 提问历史内容(包含当前提问)
|
|
101
|
-
* @return {*} {Promise<boolean>} 等待回答
|
|
102
|
-
|
|
103
101
|
/**
|
|
104
102
|
* Creates an instance of AiChatController.
|
|
105
103
|
*
|
|
@@ -282,4 +280,11 @@ export declare class AiChatController {
|
|
|
282
280
|
* @return {*} {Promise<void>}
|
|
283
281
|
*/
|
|
284
282
|
handleSuggestionClick(message: IChatMessage, suggestion: IChatSuggestion, event: MouseEvent): Promise<void>;
|
|
283
|
+
/**
|
|
284
|
+
* 销毁
|
|
285
|
+
*
|
|
286
|
+
* @return {*} {Promise<void>}
|
|
287
|
+
* @memberof AiChatController
|
|
288
|
+
*/
|
|
289
|
+
destroyed(): Promise<void>;
|
|
285
290
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AiChatController } from '../ai-chat/ai-chat.controller';
|
|
2
2
|
import { CommonHelper } from './common-helper';
|
|
3
3
|
import { FileHelper } from './file-helper';
|
|
4
|
+
|
|
4
5
|
export declare class AIMaterialFactory {
|
|
5
6
|
static getMaterialHelper(type: string, aiChat: AiChatController): CommonHelper | FileHelper;
|
|
6
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IChatMessage } from '../../interface';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* 消息实体
|
|
4
5
|
*
|
|
@@ -11,6 +12,13 @@ import { IChatMessage } from '../../interface';
|
|
|
11
12
|
export declare class ChatMessage implements IChatMessage {
|
|
12
13
|
protected msg: IChatMessage;
|
|
13
14
|
toolcalls: IChatMessage['toolcalls'];
|
|
15
|
+
/**
|
|
16
|
+
* @description 消息的所有原始内容
|
|
17
|
+
* - 用于维护工具调用消息数据
|
|
18
|
+
* @type {string}
|
|
19
|
+
* @memberof ChatMessage
|
|
20
|
+
*/
|
|
21
|
+
allcontent: string;
|
|
14
22
|
get messageid(): IChatMessage['messageid'];
|
|
15
23
|
get state(): IChatMessage['state'];
|
|
16
24
|
get role(): IChatMessage['role'];
|
|
@@ -29,6 +37,12 @@ export declare class ChatMessage implements IChatMessage {
|
|
|
29
37
|
* @param {IChatMessage} msg
|
|
30
38
|
*/
|
|
31
39
|
update(msg: IChatMessage): void;
|
|
40
|
+
/**
|
|
41
|
+
* @description 替换消息
|
|
42
|
+
* @param {IChatMessage} msg
|
|
43
|
+
* @memberof ChatMessage
|
|
44
|
+
*/
|
|
45
|
+
replace(msg: IChatMessage): void;
|
|
32
46
|
/**
|
|
33
47
|
* 更新消息完成状态
|
|
34
48
|
*
|
package/dist/types/global.d.ts
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -3,6 +3,27 @@ import { IChatMessage } from '../i-chat-message/i-chat-message';
|
|
|
3
3
|
import { IChatToolbarItem } from '../i-chat-toolbar-item/i-chat-toolbar-item';
|
|
4
4
|
import { FileUploaderOptions } from '../i-file-uploader-options/i-file-uploader-options';
|
|
5
5
|
import { ITopic } from '../i-topic-options/i-topic-options';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 自动关闭窗口,用于在提问完成时配置窗口关闭模式
|
|
9
|
+
*
|
|
10
|
+
* @export
|
|
11
|
+
* @interface IAutoClose
|
|
12
|
+
*/
|
|
13
|
+
export interface IAutoClose {
|
|
14
|
+
/**
|
|
15
|
+
* @description 模式
|
|
16
|
+
* - minimize:最小化;close:直接关闭;closetime:定时关闭
|
|
17
|
+
* @type {('minimize' | 'closetime' | 'close')}
|
|
18
|
+
*/
|
|
19
|
+
mode: 'minimize' | 'close' | 'closetime';
|
|
20
|
+
/**
|
|
21
|
+
* @description 自动关闭延时时间,该值单位为秒(s),当 mode 值为closetime时生效
|
|
22
|
+
* @default 3
|
|
23
|
+
* @type {number}
|
|
24
|
+
*/
|
|
25
|
+
duration?: number;
|
|
26
|
+
}
|
|
6
27
|
/**
|
|
7
28
|
* 聊天数据
|
|
8
29
|
*
|
|
@@ -43,6 +64,34 @@ export interface IChat {
|
|
|
43
64
|
* @type {string}
|
|
44
65
|
*/
|
|
45
66
|
appDataEntityId: string;
|
|
67
|
+
/**
|
|
68
|
+
* @description 自动提问
|
|
69
|
+
* - 历史数据最后一个项是user时是否自动提问,默认开启
|
|
70
|
+
* @type {boolean}
|
|
71
|
+
* @memberof IChat
|
|
72
|
+
*/
|
|
73
|
+
autoQuestion?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* 自动关闭窗口,用于在提问完成时配置窗口关闭模式
|
|
76
|
+
*
|
|
77
|
+
* @type {IAutoClose}
|
|
78
|
+
* @memberof IChat
|
|
79
|
+
*/
|
|
80
|
+
autoClose?: IAutoClose;
|
|
81
|
+
/**
|
|
82
|
+
* @description AI窗口的打开模式
|
|
83
|
+
* - default:默认;minimize:默认最小化窗口;autoexpand:默认最小化窗口,当提问完成时自动展开窗口
|
|
84
|
+
* @type {('default' | 'minimize' | 'autoexpand')}
|
|
85
|
+
* @memberof IChat
|
|
86
|
+
*/
|
|
87
|
+
openMode?: 'default' | 'minimize' | 'autoexpand';
|
|
88
|
+
/**
|
|
89
|
+
* @description 是否自动回填
|
|
90
|
+
* - AI回答完成之后是否触发回填,默认关闭
|
|
91
|
+
* @type {boolean}
|
|
92
|
+
* @memberof IChat
|
|
93
|
+
*/
|
|
94
|
+
autoFill?: boolean;
|
|
46
95
|
/**
|
|
47
96
|
* 传入对象参数(如果外部传入,在请求历史记录,需要附加当前参数)
|
|
48
97
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { IChatMessage } from './i-chat-message/i-chat-message';
|
|
2
|
-
export type { IChat, IChatOptions } from './i-chat-options/i-chat-options';
|
|
2
|
+
export type { IChat, IChatOptions, IAutoClose, } from './i-chat-options/i-chat-options';
|
|
3
3
|
export type { IMessageItemProvider } from './i-message-item-provider/i-message-item-provider';
|
|
4
4
|
export type { IPortalAsyncAction } from './i-portal-async-action/i-portal-async-action';
|
|
5
5
|
export type { IChatToolbarItem } from './i-chat-toolbar-item/i-chat-toolbar-item';
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiz-template-plugin/ai-chat",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"description": "iBiz AI交互框插件",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "dist/index.es.js",
|
|
6
7
|
"module": "dist/index.es.js",
|
|
7
8
|
"types": "dist/types/index.d.ts",
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
"autosize": "^6.0.1",
|
|
33
34
|
"cherry-markdown": "^0.8.26",
|
|
34
35
|
"interactjs": "^1.10.19",
|
|
36
|
+
"qx-util": "^0.4.8",
|
|
35
37
|
"path-browserify": "^1.0.1",
|
|
36
38
|
"preact": "^10.18.1",
|
|
37
39
|
"react-tabs": "^6.0.2",
|
|
@@ -76,7 +78,8 @@
|
|
|
76
78
|
},
|
|
77
79
|
"peerDependencies": {
|
|
78
80
|
"cherry-markdown": "^0.8.26",
|
|
79
|
-
"interactjs": "^1.10.19"
|
|
81
|
+
"interactjs": "^1.10.19",
|
|
82
|
+
"qx-util": "^0.4.8"
|
|
80
83
|
},
|
|
81
84
|
"lint-staged": {
|
|
82
85
|
"*.ts": "eslint --fix",
|