@ibiz-template-plugin/ai-chat 0.0.11 → 0.0.13
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 +1571 -1301
- package/dist/index.legacy.js +1 -1
- package/dist/polyfills.legacy.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/components/chat-back-bottom/chat-back-bottom.d.ts +28 -0
- package/dist/types/components/chat-container/chat-container.d.ts +62 -3
- package/dist/types/components/chat-topic-item/chat-topic-item.d.ts +2 -2
- package/dist/types/controller/ai-chat/ai-chat.controller.d.ts +43 -1
- package/dist/types/controller/chat/chat.controller.d.ts +11 -4
- package/dist/types/entity/chat-message/chat-message.d.ts +1 -0
- package/dist/types/icons/arrow-down-outline-svg.d.ts +3 -0
- package/dist/types/icons/index.d.ts +2 -0
- package/dist/types/icons/send-svg.d.ts +3 -1
- package/dist/types/icons/stop-circle-svg.d.ts +3 -0
- package/dist/types/interface/i-chat-container/i-chat-container.d.ts +8 -0
- package/dist/types/interface/i-chat-message/i-chat-message.d.ts +8 -0
- package/dist/types/interface/i-chat-options/i-chat-options.d.ts +19 -1
- package/package.json +1 -1
|
@@ -11,6 +11,14 @@ export interface ChatContainerProps {
|
|
|
11
11
|
* @type {('DEFAULT' | 'TOPIC')}
|
|
12
12
|
*/
|
|
13
13
|
mode: 'DEFAULT' | 'TOPIC';
|
|
14
|
+
/**
|
|
15
|
+
* 是否允许回填
|
|
16
|
+
*
|
|
17
|
+
* @author tony001
|
|
18
|
+
* @date 2025-03-10 16:03:08
|
|
19
|
+
* @type {boolean}
|
|
20
|
+
*/
|
|
21
|
+
enableBackFill?: boolean;
|
|
14
22
|
/**
|
|
15
23
|
* ai话题控制器
|
|
16
24
|
*
|
|
@@ -102,6 +110,7 @@ interface ChatContainerState {
|
|
|
102
110
|
}
|
|
103
111
|
interface ContainerContext {
|
|
104
112
|
zIndex: number;
|
|
113
|
+
enableBackFill: boolean;
|
|
105
114
|
}
|
|
106
115
|
export declare const ContainerContext: import("preact").Context<ContainerContext>;
|
|
107
116
|
/**
|
|
@@ -120,10 +129,10 @@ export declare class ChatContainer extends Component<ChatContainerProps, ChatCon
|
|
|
120
129
|
dragHandle: import("preact").RefObject<HTMLDivElement>;
|
|
121
130
|
minimizeRef: import("preact").RefObject<HTMLDivElement>;
|
|
122
131
|
data: {
|
|
123
|
-
x: number;
|
|
124
132
|
y: number;
|
|
125
|
-
width: number;
|
|
126
133
|
height: number;
|
|
134
|
+
width: number;
|
|
135
|
+
x: number;
|
|
127
136
|
minWidth: number;
|
|
128
137
|
minHeight: number;
|
|
129
138
|
};
|
|
@@ -156,8 +165,10 @@ export declare class ChatContainer extends Component<ChatContainerProps, ChatCon
|
|
|
156
165
|
calcWindowStyle(): {
|
|
157
166
|
left: string;
|
|
158
167
|
top: string;
|
|
159
|
-
height: string;
|
|
160
168
|
width: string;
|
|
169
|
+
height: string;
|
|
170
|
+
minWidth: string;
|
|
171
|
+
minHeight: string;
|
|
161
172
|
'z-index': string;
|
|
162
173
|
};
|
|
163
174
|
calcMinimizeStyle(): {
|
|
@@ -166,6 +177,54 @@ export declare class ChatContainer extends Component<ChatContainerProps, ChatCon
|
|
|
166
177
|
'z-index': string;
|
|
167
178
|
};
|
|
168
179
|
setStyle(): void;
|
|
180
|
+
/**
|
|
181
|
+
* 检查是否在窗口内部
|
|
182
|
+
*
|
|
183
|
+
* @param {{ x: number; y: number }} data
|
|
184
|
+
* @return {*} {boolean}
|
|
185
|
+
* @memberof ChatContainer
|
|
186
|
+
*/
|
|
187
|
+
isWithinBounds(data: {
|
|
188
|
+
x: number;
|
|
189
|
+
y: number;
|
|
190
|
+
}): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* 吸附边缘
|
|
193
|
+
* - 靠近窗口边缘(20px)自动吸附
|
|
194
|
+
* @memberof ChatContainer
|
|
195
|
+
*/
|
|
196
|
+
snapToEdge(): void;
|
|
197
|
+
/**
|
|
198
|
+
* 拖拽限制(边界问题)
|
|
199
|
+
*
|
|
200
|
+
* @param {number} left
|
|
201
|
+
* @param {number} top
|
|
202
|
+
* @param {number} width
|
|
203
|
+
* @param {number} height
|
|
204
|
+
* @memberof ChatContainer
|
|
205
|
+
*/
|
|
206
|
+
limitDraggable(left: number, top: number, width: number, height: number): {
|
|
207
|
+
x: number;
|
|
208
|
+
y: number;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* 注册最小化拖拽
|
|
212
|
+
*
|
|
213
|
+
* @memberof ChatContainer
|
|
214
|
+
*/
|
|
215
|
+
registerDragMinmize(): void;
|
|
216
|
+
/**
|
|
217
|
+
* 注册对话框拖拽
|
|
218
|
+
*
|
|
219
|
+
* @memberof ChatContainer
|
|
220
|
+
*/
|
|
221
|
+
registerDragDialog(): void;
|
|
222
|
+
/**
|
|
223
|
+
* 注册对话框边界拖拽
|
|
224
|
+
*
|
|
225
|
+
* @memberof ChatContainer
|
|
226
|
+
*/
|
|
227
|
+
registerDragDialogBorder(): void;
|
|
169
228
|
componentDidMount(): void;
|
|
170
229
|
componentWillUnmount(): void;
|
|
171
230
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChatTopic } from '../../entity';
|
|
2
|
+
import { AiTopicController } from '../../controller';
|
|
2
3
|
export interface ChatTopicItemProps {
|
|
3
|
-
|
|
4
|
-
active: boolean;
|
|
4
|
+
controller: AiTopicController;
|
|
5
5
|
topic: ChatTopic;
|
|
6
6
|
onClick: () => void;
|
|
7
7
|
onAction: (action: string, event: MouseEvent) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Signal } from '@preact/signals';
|
|
2
2
|
import { ChatMessage } from '../../entity';
|
|
3
|
-
import { IChatMessage, IChatOptions, IMaterial } from '../../interface';
|
|
3
|
+
import { IChatMessage, IChatOptions, IMaterial, ITopic } from '../../interface';
|
|
4
4
|
/**
|
|
5
5
|
* 聊天逻辑控制器
|
|
6
6
|
*
|
|
@@ -35,6 +35,14 @@ export declare class AiChatController {
|
|
|
35
35
|
* @type {Signal<string>}
|
|
36
36
|
*/
|
|
37
37
|
readonly input: Signal<string>;
|
|
38
|
+
/**
|
|
39
|
+
* 是否加载中
|
|
40
|
+
*
|
|
41
|
+
* @author tony001
|
|
42
|
+
* @date 2025-03-10 18:03:42
|
|
43
|
+
* @type {Signal<boolean>}
|
|
44
|
+
*/
|
|
45
|
+
readonly isLoading: Signal<boolean>;
|
|
38
46
|
/**
|
|
39
47
|
* 视图参数
|
|
40
48
|
*
|
|
@@ -67,6 +75,25 @@ export declare class AiChatController {
|
|
|
67
75
|
* @type {(string | undefined)}
|
|
68
76
|
*/
|
|
69
77
|
readonly topicId: string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* 话题数据
|
|
80
|
+
*
|
|
81
|
+
* @author tony001
|
|
82
|
+
* @date 2025-03-10 16:03:26
|
|
83
|
+
* @type {(ITopic | undefined)}
|
|
84
|
+
*/
|
|
85
|
+
readonly topic: ITopic | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* 聊天窗触发提问回调
|
|
88
|
+
*
|
|
89
|
+
* @author tony001
|
|
90
|
+
* @date 2025-02-24 14:02:51
|
|
91
|
+
* @param {object} context
|
|
92
|
+
* @param {object} params
|
|
93
|
+
* @param {object} otherParams
|
|
94
|
+
* @param {IChatMessage[]} question 提问历史内容(包含当前提问)
|
|
95
|
+
* @return {*} {Promise<boolean>} 等待回答
|
|
96
|
+
|
|
70
97
|
/**
|
|
71
98
|
* Creates an instance of AiChatController.
|
|
72
99
|
*
|
|
@@ -124,6 +151,14 @@ export declare class AiChatController {
|
|
|
124
151
|
* @param {IChatMessage} data
|
|
125
152
|
*/
|
|
126
153
|
replaceMessage(data: IChatMessage): void;
|
|
154
|
+
/**
|
|
155
|
+
* 终止消息
|
|
156
|
+
*
|
|
157
|
+
* @author tony001
|
|
158
|
+
* @date 2025-03-10 14:03:17
|
|
159
|
+
* @param {IChatMessage} data
|
|
160
|
+
*/
|
|
161
|
+
stopMessage(data: IChatMessage): void;
|
|
127
162
|
/**
|
|
128
163
|
* 数据对象转 XML 字符串
|
|
129
164
|
*
|
|
@@ -140,6 +175,13 @@ export declare class AiChatController {
|
|
|
140
175
|
* @return {*} {Promise<void>}
|
|
141
176
|
*/
|
|
142
177
|
question(input: string): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* 中断请求
|
|
180
|
+
*
|
|
181
|
+
* @author tony001
|
|
182
|
+
* @date 2025-03-10 14:03:48
|
|
183
|
+
*/
|
|
184
|
+
abortQuestion(): void;
|
|
143
185
|
/**
|
|
144
186
|
* 回填选中的消息
|
|
145
187
|
*
|
|
@@ -59,12 +59,19 @@ export declare class ChatController {
|
|
|
59
59
|
/**
|
|
60
60
|
* 聊天控制器
|
|
61
61
|
*
|
|
62
|
-
* @
|
|
63
|
-
* @date 2025-02-23 16:02:09
|
|
64
|
-
* @public
|
|
62
|
+
* @readonly
|
|
65
63
|
* @type {(AiChatController | undefined)}
|
|
64
|
+
* @memberof ChatController
|
|
65
|
+
*/
|
|
66
|
+
get aiChat(): AiChatController | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* 话题map
|
|
69
|
+
*
|
|
70
|
+
* @private
|
|
71
|
+
* @type {Map<string, AiChatController>}
|
|
72
|
+
* @memberof ChatController
|
|
66
73
|
*/
|
|
67
|
-
|
|
74
|
+
private aiTopicMap;
|
|
68
75
|
/**
|
|
69
76
|
* Creates an instance of ChatController.
|
|
70
77
|
* @author tony001
|
|
@@ -14,6 +14,7 @@ export declare class ChatMessage implements IChatMessage {
|
|
|
14
14
|
get state(): IChatMessage['state'];
|
|
15
15
|
get role(): IChatMessage['role'];
|
|
16
16
|
get type(): IChatMessage['type'];
|
|
17
|
+
get realcontent(): IChatMessage['realcontent'];
|
|
17
18
|
get content(): IChatMessage['content'];
|
|
18
19
|
get completed(): IChatMessage['completed'];
|
|
19
20
|
get _origin(): IChatMessage;
|
|
@@ -21,3 +21,5 @@ export { PaperclipSvg } from './paperclip-svg';
|
|
|
21
21
|
export { FileSvg } from './upload-svg';
|
|
22
22
|
export { MaterialRemoveSvg } from './material-remove-svg';
|
|
23
23
|
export { DefaultMaterialSvg } from './default-material-svg';
|
|
24
|
+
export { StopCircleSvg } from './stop-circle-svg';
|
|
25
|
+
export { ArrowDownOutlineSvg } from './arrow-down-outline-svg';
|
|
@@ -64,6 +64,14 @@ export interface IChatMessage {
|
|
|
64
64
|
* @type {string}
|
|
65
65
|
*/
|
|
66
66
|
content: string;
|
|
67
|
+
/**
|
|
68
|
+
* 内容(排除排除think、resources、suggesions内容)
|
|
69
|
+
*
|
|
70
|
+
* @author tony001
|
|
71
|
+
* @date 2025-03-10 16:03:12
|
|
72
|
+
* @type {string}
|
|
73
|
+
*/
|
|
74
|
+
realcontent?: string;
|
|
67
75
|
/**
|
|
68
76
|
* 消息数据
|
|
69
77
|
*
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { AiChatController } from '../../controller';
|
|
1
2
|
import { IChatMessage } from '../i-chat-message/i-chat-message';
|
|
2
3
|
import { IChatToolbarItem } from '../i-chat-toolbar-item/i-chat-toolbar-item';
|
|
3
4
|
import { FileUploaderOptions } from '../i-file-uploader-options/i-file-uploader-options';
|
|
5
|
+
import { ITopic } from '../i-topic-options/i-topic-options';
|
|
4
6
|
/**
|
|
5
7
|
* 聊天数据
|
|
6
8
|
*
|
|
@@ -89,6 +91,14 @@ export interface IChatOptions extends IChat {
|
|
|
89
91
|
* @type {string}
|
|
90
92
|
*/
|
|
91
93
|
topicId?: string;
|
|
94
|
+
/**
|
|
95
|
+
*话题数据
|
|
96
|
+
*
|
|
97
|
+
* @author tony001
|
|
98
|
+
* @date 2025-03-10 16:03:46
|
|
99
|
+
* @type {ITopic}
|
|
100
|
+
*/
|
|
101
|
+
topic?: ITopic;
|
|
92
102
|
/**
|
|
93
103
|
* 聊天窗触发提问回调
|
|
94
104
|
*
|
|
@@ -100,7 +110,15 @@ export interface IChatOptions extends IChat {
|
|
|
100
110
|
* @param {IChatMessage[]} question 提问历史内容(包含当前提问)
|
|
101
111
|
* @return {*} {Promise<boolean>} 等待回答,用于显示 loading 并获取最终成功与否
|
|
102
112
|
*/
|
|
103
|
-
question(context: object, params: object, otherParams: object, question: IChatMessage[]): Promise<boolean>;
|
|
113
|
+
question(aiChat: AiChatController, context: object, params: object, otherParams: object, question: IChatMessage[]): Promise<boolean>;
|
|
114
|
+
/**
|
|
115
|
+
* 中断消息
|
|
116
|
+
*
|
|
117
|
+
* @author tony001
|
|
118
|
+
* @date 2025-03-10 14:03:37
|
|
119
|
+
* @param {AiChatController} aiChat
|
|
120
|
+
*/
|
|
121
|
+
abortQuestion(aiChat: AiChatController): void;
|
|
104
122
|
/**
|
|
105
123
|
* 聊天窗历史记录获取
|
|
106
124
|
*
|