@ibiz-template-plugin/ai-chat 0.0.96 → 0.0.98
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 +3019 -2808
- package/dist/index.legacy.js +1 -1
- package/dist/types/components/chat-editor/chat-editor.d.ts +6 -1
- package/dist/types/controller/ai-chat/ai-chat.controller.d.ts +14 -6
- package/dist/types/controller/ai-topic/ai-topic.controller.d.ts +27 -4
- package/dist/types/entity/chat-message/chat-message.d.ts +1 -0
- package/dist/types/interface/i-chat-message/i-chat-message.d.ts +15 -4
- package/dist/types/interface/i-chat-options/i-chat-options.d.ts +5 -2
- package/dist/types/interface/i-remote-resource/i-remote-resource.d.ts +8 -0
- package/dist/types/interface/i-topic-options/i-topic-options.d.ts +4 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/util/util.d.ts +11 -0
- package/package.json +1 -1
|
@@ -42,4 +42,9 @@ export interface ChatEditorProps {
|
|
|
42
42
|
*/
|
|
43
43
|
onKeyDown: (e: KeyboardEvent) => boolean | void;
|
|
44
44
|
}
|
|
45
|
-
export
|
|
45
|
+
export interface ChatEditorHandle {
|
|
46
|
+
toggleCollapse: (status: boolean) => void;
|
|
47
|
+
}
|
|
48
|
+
export declare const ChatEditor: import('preact').FunctionalComponent<import('preact/compat').PropsWithoutRef<ChatEditorProps> & {
|
|
49
|
+
ref?: import('preact').Ref<ChatEditorHandle> | undefined;
|
|
50
|
+
}>;
|
|
@@ -13,9 +13,9 @@ import { AiTopicController } from '../ai-topic/ai-topic.controller';
|
|
|
13
13
|
* @class AiChatController
|
|
14
14
|
*/
|
|
15
15
|
export declare class AiChatController {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
opts: IChatOptions;
|
|
17
|
+
resourceOptions: IResourceOptions | undefined;
|
|
18
|
+
topicOptions: ITopicOptions | undefined;
|
|
19
19
|
/**
|
|
20
20
|
* 事件触发器
|
|
21
21
|
* @type {QXEvent}
|
|
@@ -173,6 +173,10 @@ export declare class AiChatController {
|
|
|
173
173
|
* 摘要是否正在处理完成
|
|
174
174
|
*/
|
|
175
175
|
private isDigestProcessed;
|
|
176
|
+
/**
|
|
177
|
+
* 是否需要更新元数据
|
|
178
|
+
*/
|
|
179
|
+
private needUpdateMetaData;
|
|
176
180
|
/**
|
|
177
181
|
* 知识库列表
|
|
178
182
|
*/
|
|
@@ -215,6 +219,10 @@ export declare class AiChatController {
|
|
|
215
219
|
* 当前话题标题
|
|
216
220
|
*/
|
|
217
221
|
get sessionDefaultCaption(): string;
|
|
222
|
+
/**
|
|
223
|
+
* 当前会话元数据
|
|
224
|
+
*/
|
|
225
|
+
get sessionMeta(): ITopic | undefined;
|
|
218
226
|
/**
|
|
219
227
|
* Creates an instance of AiChatController.
|
|
220
228
|
*
|
|
@@ -229,7 +237,7 @@ export declare class AiChatController {
|
|
|
229
237
|
* 更新会话数据(当前若存在正在处理的消息则不做处理,不存在则重新构建相关数据)
|
|
230
238
|
* @returns
|
|
231
239
|
*/
|
|
232
|
-
updateAIChat(): void;
|
|
240
|
+
updateAIChat(opts: IChatOptions): void;
|
|
233
241
|
/**
|
|
234
242
|
* 初始化
|
|
235
243
|
*/
|
|
@@ -543,9 +551,9 @@ export declare class AiChatController {
|
|
|
543
551
|
*/
|
|
544
552
|
switchKnowledgeEnableState(): void;
|
|
545
553
|
/**
|
|
546
|
-
*
|
|
554
|
+
* 更新当前话题
|
|
547
555
|
*/
|
|
548
|
-
|
|
556
|
+
updateTopic(enableCaptionUpdate?: boolean): Promise<void>;
|
|
549
557
|
/**
|
|
550
558
|
* @description 消息点赞
|
|
551
559
|
* @param {IChatMessage} message
|
|
@@ -76,6 +76,14 @@ export declare class AiTopicController {
|
|
|
76
76
|
* 资源选项
|
|
77
77
|
*/
|
|
78
78
|
private resourceOptions;
|
|
79
|
+
/**
|
|
80
|
+
* 配置列表
|
|
81
|
+
*/
|
|
82
|
+
private configList;
|
|
83
|
+
/**
|
|
84
|
+
* AI话题存储模式,DEFAULT:默认值,会话数据基于config和远程session配合存储; REMOTESESSION:远程,会话仅远程session存储
|
|
85
|
+
*/
|
|
86
|
+
storageMode: 'DEFAULT' | 'REMOTESESSION';
|
|
79
87
|
/**
|
|
80
88
|
* Creates an instance of AiTopicController.
|
|
81
89
|
* @author tony001
|
|
@@ -102,10 +110,9 @@ export declare class AiTopicController {
|
|
|
102
110
|
*/
|
|
103
111
|
fetchHistory(options: ITopicOptions): Promise<void>;
|
|
104
112
|
/**
|
|
105
|
-
* 同步远程会话
|
|
106
|
-
* @param configList config存储数据
|
|
113
|
+
* 同步远程会话(以远程会话为准)
|
|
107
114
|
*/
|
|
108
|
-
asyncRemoteSession(
|
|
115
|
+
asyncRemoteSession(): Promise<void>;
|
|
109
116
|
/**
|
|
110
117
|
* 同步当前话题
|
|
111
118
|
*
|
|
@@ -139,6 +146,14 @@ export declare class AiTopicController {
|
|
|
139
146
|
* @return {*} {Promise<void>}
|
|
140
147
|
*/
|
|
141
148
|
removeTopic(options: ITopicOptions, context: object, params: object, data: ITopic, event: MouseEvent): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* 删除远程会话数据
|
|
151
|
+
* 存在真实id,则删除远程session数据;不存在真实id,先基于sessionid查询,如果存在则删除,不存在视为删除成功
|
|
152
|
+
*
|
|
153
|
+
* @param {ITopic} data 话题数据
|
|
154
|
+
* @return {*} {Promise<boolean>}
|
|
155
|
+
*/
|
|
156
|
+
private deleteRemoteSession;
|
|
142
157
|
/**
|
|
143
158
|
* 处理选中变化
|
|
144
159
|
*
|
|
@@ -173,6 +188,14 @@ export declare class AiTopicController {
|
|
|
173
188
|
* @memberof AiTopicController
|
|
174
189
|
*/
|
|
175
190
|
clearTopic(): Promise<void>;
|
|
191
|
+
/**
|
|
192
|
+
* 清空远程会话数据(排除指定会话)
|
|
193
|
+
* 激活会话存在会话标识时,清空其余会话;不存在时视为成功
|
|
194
|
+
*
|
|
195
|
+
* @param {ChatTopic} actived 激活话题
|
|
196
|
+
* @return {*} {Promise<boolean>}
|
|
197
|
+
*/
|
|
198
|
+
private clearRemoteSession;
|
|
176
199
|
/**
|
|
177
200
|
* 更新话题标题
|
|
178
201
|
* @param topicId
|
|
@@ -186,7 +209,7 @@ export declare class AiTopicController {
|
|
|
186
209
|
* @return {*} {Promise<void>}
|
|
187
210
|
* @memberof AiTopicController
|
|
188
211
|
*/
|
|
189
|
-
|
|
212
|
+
updateTopicConfig(options: ITopicOptions): Promise<void>;
|
|
190
213
|
/**
|
|
191
214
|
* 计算话题侧边栏宽度
|
|
192
215
|
*/
|
|
@@ -47,6 +47,7 @@ export declare class ChatMessage implements IChatMessage {
|
|
|
47
47
|
get feedbackcontent(): IChatMessage['feedbackcontent'];
|
|
48
48
|
get realmessageid(): IChatMessage['realmessageid'];
|
|
49
49
|
get metadata(): IChatMessage['metadata'];
|
|
50
|
+
get agent_tag(): IChatMessage['agent_tag'];
|
|
50
51
|
constructor(msg: IChatMessage);
|
|
51
52
|
/**
|
|
52
53
|
* 更新消息
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IChatMessageUsage } from '../i-chat-message-usage/i-chat-message-usage';
|
|
1
2
|
import { IChatStep } from '../i-chat-step/i-chat-step';
|
|
2
3
|
import { IChatSuggestion } from '../i-chat-suggestion/i-chat-suggestion';
|
|
3
4
|
import { IChatThink } from '../i-chat-think/i-chat-think';
|
|
@@ -172,10 +173,20 @@ export interface IChatMessage {
|
|
|
172
173
|
errorText?: string;
|
|
173
174
|
/**
|
|
174
175
|
* @description 元数据
|
|
175
|
-
* @type {
|
|
176
|
+
* @type {object}
|
|
176
177
|
* @memberof IChatMessage
|
|
177
178
|
*/
|
|
178
|
-
metadata?:
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
metadata?: object;
|
|
180
|
+
/**
|
|
181
|
+
* @description 当前消息智能体标记
|
|
182
|
+
* @type {string}
|
|
183
|
+
* @memberof IChatMessage
|
|
184
|
+
*/
|
|
185
|
+
agent_tag?: string;
|
|
186
|
+
/**
|
|
187
|
+
* @description 资源使用量
|
|
188
|
+
* @type {IChatMessageUsage}
|
|
189
|
+
* @memberof IChatMessage
|
|
190
|
+
*/
|
|
191
|
+
usage?: IChatMessageUsage;
|
|
181
192
|
}
|
|
@@ -287,7 +287,7 @@ export interface IChatOptions extends IChat {
|
|
|
287
287
|
* @param {IChatMessage[]} question 提问历史内容(包含当前提问)
|
|
288
288
|
* @return {*} {Promise<boolean>} 等待回答,用于显示 loading 并获取最终成功与否
|
|
289
289
|
*/
|
|
290
|
-
question(aiChat: AiChatController, context: object, params: object, otherParams: object, question: IChatMessage[], sessionid: string, srfaiagent: string | undefined, srfmode: string | undefined, srfscope: string | undefined, srfaiknowledgebases: string | undefined, srfaiagentconfig: IAIAgentConfig | undefined, appendcurdata: object | undefined, srfmcpservers: string | undefined): Promise<boolean>;
|
|
290
|
+
question(aiChat: AiChatController, context: object, params: object, otherParams: object, question: IChatMessage[], sessionid: string, srfaiagent: string | undefined, srfmode: string | undefined, srfscope: string | undefined, srfaiknowledgebases: string | undefined, srfaiagentconfig: IAIAgentConfig | undefined, appendcurdata: object | undefined, srfmcpservers: string | undefined, srfsessionmeta: object | undefined): Promise<boolean>;
|
|
291
291
|
/**
|
|
292
292
|
* 中断消息
|
|
293
293
|
* @param aiChat
|
|
@@ -346,7 +346,10 @@ export interface IChatOptions extends IChat {
|
|
|
346
346
|
* @date 2025-02-28 14:02:41
|
|
347
347
|
* @type {FileUploaderOptions<object>}
|
|
348
348
|
*/
|
|
349
|
-
fetchAgentList?: (
|
|
349
|
+
fetchAgentList?: (args?: {
|
|
350
|
+
query?: string;
|
|
351
|
+
agentid?: string;
|
|
352
|
+
}) => Promise<IAIAgent[]>;
|
|
350
353
|
/**
|
|
351
354
|
* 获取AI知识库列表
|
|
352
355
|
*
|
|
@@ -24,6 +24,10 @@ export interface IRemoteSession {
|
|
|
24
24
|
* @memberof IRemoteSession
|
|
25
25
|
*/
|
|
26
26
|
is_top: 0 | 1;
|
|
27
|
+
/**
|
|
28
|
+
* @description 会话元数据
|
|
29
|
+
*/
|
|
30
|
+
ui_meta: string;
|
|
27
31
|
}
|
|
28
32
|
/**
|
|
29
33
|
* @description 远程消息接口
|
|
@@ -69,4 +73,8 @@ export interface IRemoteMessage {
|
|
|
69
73
|
* 消息元数据
|
|
70
74
|
*/
|
|
71
75
|
metadata: string | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* 当前智能体标记
|
|
78
|
+
*/
|
|
79
|
+
agent_tag: string | undefined;
|
|
72
80
|
}
|
|
@@ -123,6 +123,10 @@ export interface ITopicOptions extends ITopic {
|
|
|
123
123
|
* 忽略同步话题,默认不忽略
|
|
124
124
|
*/
|
|
125
125
|
ingnoreAsyncTopic: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* AI话题存储模式,DEFAULT:默认值,会话数据基于config和远程session配合存储; REMOTESESSION:远程,会话仅远程session存储
|
|
128
|
+
*/
|
|
129
|
+
storageMode: 'DEFAULT' | 'REMOTESESSION';
|
|
126
130
|
/**
|
|
127
131
|
* 删除之前
|
|
128
132
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Namespace } from '@ibiz-template/scss-utils';
|
|
2
2
|
export { PluginStaticResource } from './plugin-static-resource/plugin-static-resource';
|
|
3
|
-
export { createUUID, isSvg, parsePredefProtocol, html2md, md2html, } from './util/util';
|
|
3
|
+
export { createUUID, isSvg, parsePredefProtocol, html2md, md2html, parseJavaToString, } from './util/util';
|
|
4
4
|
export { IndexedDBUtil } from './util/indexdb-util';
|
|
5
5
|
export { FileUploader } from './util/file-uploader';
|
|
6
6
|
export { MaterialResourceParser } from './util/material-resource-parser';
|
|
@@ -62,6 +62,17 @@ export declare function html2md(html: string): string;
|
|
|
62
62
|
* @returns
|
|
63
63
|
*/
|
|
64
64
|
export declare function md2html(md: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* 将 Java toString() 格式的字符串安全地转换为 JS 对象
|
|
67
|
+
*
|
|
68
|
+
* 支持嵌套 Map({key=value})、List([a, b])结构;true/false/null 还原为对应类型;
|
|
69
|
+
* 纯数字还原为 number,但前导零(如 000000)视为原始字符串;
|
|
70
|
+
* 值本身为合法 JSON 时(如 avatar=[{"name":"xx"}])优先按 JSON 解析。
|
|
71
|
+
*
|
|
72
|
+
* @param str - 待转换的原始字符串
|
|
73
|
+
* @returns 解析后的 JavaScript 对象,格式非法时返回空对象
|
|
74
|
+
*/
|
|
75
|
+
export declare function parseJavaToString(str: string): Record<string, any>;
|
|
65
76
|
export declare class TextUtil {
|
|
66
77
|
/**
|
|
67
78
|
* @description textarea元素,用于存储拷贝的文本
|