@ibiz-template/vue3-components 0.7.41-alpha.42 → 0.7.41-alpha.43

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 (40) hide show
  1. package/dist/ibiz-markdown-editor-DJ662N4_.js +1 -0
  2. package/dist/{index-CaWTEUU1.js → index-CG3sQH0b.js} +1 -1
  3. package/dist/index-D3x_MFr-.js +11 -0
  4. package/dist/{index-CD2XM6M6.js → index-kZrZndeH.js} +1 -1
  5. package/dist/index.min.css +1 -1
  6. package/dist/index.system.min.js +1 -1
  7. package/dist/wang-editor-DDSO3Ha9.js +1 -0
  8. package/dist/{xlsx-util-B1eGfH7d.js → xlsx-util-8YSXhmdI.js} +1 -1
  9. package/es/control/toolbar/export-excel/export-excel.mjs +19 -4
  10. package/es/editor/code/monaco-editor/monaco-editor.mjs +6 -194
  11. package/es/editor/html/wang-editor/module/ai-module.mjs +1 -1
  12. package/es/editor/html/wang-editor/wang-editor.mjs +20 -201
  13. package/es/editor/markdown/ibiz-markdown-editor/custom-menu.mjs +7 -223
  14. package/es/editor/text-box/input/input.mjs +9 -197
  15. package/es/locale/en/index.mjs +24 -1
  16. package/es/locale/zh-CN/index.mjs +24 -1
  17. package/es/panel-component/panel-app-title/panel-app-title.mjs +19 -42
  18. package/es/util/ai-chat-util/ai-chat-util.mjs +637 -7
  19. package/es/util/ai-chat-util/ai-feedback/ai-feedback.css +1 -0
  20. package/es/util/ai-chat-util/ai-feedback/ai-feedback.mjs +130 -0
  21. package/es/util/app-util/app-util.mjs +24 -246
  22. package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.mjs +5 -1
  23. package/lib/control/toolbar/export-excel/export-excel.cjs +18 -3
  24. package/lib/editor/code/monaco-editor/monaco-editor.cjs +6 -194
  25. package/lib/editor/html/wang-editor/module/ai-module.cjs +1 -1
  26. package/lib/editor/html/wang-editor/wang-editor.cjs +19 -200
  27. package/lib/editor/markdown/ibiz-markdown-editor/custom-menu.cjs +7 -223
  28. package/lib/editor/text-box/input/input.cjs +8 -196
  29. package/lib/locale/en/index.cjs +24 -1
  30. package/lib/locale/zh-CN/index.cjs +24 -1
  31. package/lib/panel-component/panel-app-title/panel-app-title.cjs +18 -41
  32. package/lib/util/ai-chat-util/ai-chat-util.cjs +635 -5
  33. package/lib/util/ai-chat-util/ai-feedback/ai-feedback.cjs +132 -0
  34. package/lib/util/ai-chat-util/ai-feedback/ai-feedback.css +1 -0
  35. package/lib/util/app-util/app-util.cjs +23 -245
  36. package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.cjs +5 -1
  37. package/package.json +7 -7
  38. package/dist/ibiz-markdown-editor-pEdb_gS_.js +0 -1
  39. package/dist/index-BObZTN7-.js +0 -11
  40. package/dist/wang-editor-Ck-JCWqK.js +0 -1
@@ -1,10 +1,25 @@
1
1
  'use strict';
2
2
 
3
+ var vue = require('vue');
4
+ var qxUtil = require('qx-util');
3
5
  var runtime = require('@ibiz-template/runtime');
4
6
  var core = require('@ibiz-template/core');
7
+ var aiFeedback = require('./ai-feedback/ai-feedback.cjs');
5
8
 
6
9
  "use strict";
10
+ var __defProp = Object.defineProperty;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __publicField = (obj, key, value) => {
13
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
14
+ return value;
15
+ };
7
16
  class AIChatUtil {
17
+ constructor() {
18
+ __publicField(this, "TOPIC_CHAT_PREFIX", "topic");
19
+ __publicField(this, "INLINE_CHAT_SUFFIX", "inline");
20
+ __publicField(this, "TEMP_CHAT_SUFFIX", "temp");
21
+ __publicField(this, "UNKOWN_CHAT_SUFFIX", "unknow");
22
+ }
8
23
  /**
9
24
  * 获取AI聊天对象
10
25
  */
@@ -20,7 +35,7 @@ class AIChatUtil {
20
35
  * @param params
21
36
  * @param data
22
37
  */
23
- getEditorExAIChatParams(editorParams, context, params, data) {
38
+ async getEditorExAIChatParams(editorParams, context, params, data, deACMode, args) {
24
39
  const containerOptions = {};
25
40
  if (editorParams.enableaiminimize) {
26
41
  containerOptions.enableAIMinimize = editorParams.enableaiminimize === "true";
@@ -41,6 +56,7 @@ class AIChatUtil {
41
56
  ibiz.log.error(error);
42
57
  }
43
58
  }
59
+ const topicOptions = {};
44
60
  const chatOptions = {};
45
61
  if (editorParams.srfaiappendcurdata) {
46
62
  chatOptions.appendCurData = editorParams.srfaiappendcurdata === "true" ? data : void 0;
@@ -57,15 +73,246 @@ class AIChatUtil {
57
73
  if (editorParams.srfmode) {
58
74
  chatOptions.srfMode = editorParams.srfmode;
59
75
  }
60
- return { containerOptions, chatOptions };
76
+ if (editorParams.srfaiagent) {
77
+ chatOptions.activeAIAgentID = editorParams.srfaiagent;
78
+ }
79
+ const aiAgentlist = await this.getAIAgentList(
80
+ context,
81
+ params,
82
+ editorParams
83
+ );
84
+ chatOptions.aiAgentlist = aiAgentlist;
85
+ if (deACMode) {
86
+ const {
87
+ contentToolbarItems,
88
+ footerToolbarItems,
89
+ questionToolbarItems,
90
+ otherToolbarItems
91
+ } = this.calcAiToolbarItemsByAc(deACMode);
92
+ chatOptions.contentToolbarItems = contentToolbarItems;
93
+ chatOptions.footerToolbarItems = footerToolbarItems;
94
+ chatOptions.questionToolbarItems = questionToolbarItems;
95
+ chatOptions.otherToolbarItems = otherToolbarItems;
96
+ }
97
+ const sessionid = this.getChatSessionId("TEMP");
98
+ chatOptions.sessionid = sessionid;
99
+ let id = "";
100
+ let abortController;
101
+ const { chatInstance, view, ctrl } = args;
102
+ chatOptions.history = async (ctx, param, other) => {
103
+ const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
104
+ const historyRequestData = {};
105
+ if (other.appendCurData) {
106
+ Object.assign(historyRequestData, {
107
+ ...other.appendCurData
108
+ });
109
+ }
110
+ if (other.sessionid) {
111
+ Object.assign(historyRequestData, {
112
+ sessionid: other.sessionid
113
+ });
114
+ }
115
+ if (other.srfaiagent) {
116
+ Object.assign(historyRequestData, {
117
+ srfaiagent: other.srfaiagent
118
+ });
119
+ }
120
+ if (other.srfmode) {
121
+ Object.assign(historyRequestData, {
122
+ mode: other.srfmode
123
+ });
124
+ }
125
+ const result = await deService.aiChatHistory(
126
+ ctx,
127
+ param,
128
+ historyRequestData
129
+ );
130
+ if (result.data && Array.isArray(result.data)) {
131
+ let preMsg;
132
+ result.data.forEach((item) => {
133
+ if (item.role === "TOOL") {
134
+ if (preMsg && item.content) {
135
+ chatInstance.aiChat.updateRecommendPrompt(
136
+ preMsg,
137
+ item.content
138
+ );
139
+ }
140
+ } else {
141
+ const msg = {
142
+ messageid: qxUtil.createUUID(),
143
+ state: 30,
144
+ type: "DEFAULT",
145
+ role: item.role,
146
+ content: item.content,
147
+ completed: true
148
+ };
149
+ preMsg = msg;
150
+ chatInstance.aiChat.addMessage(msg);
151
+ }
152
+ });
153
+ }
154
+ return true;
155
+ };
156
+ chatOptions.question = async (aiChat, ctx, param, other, arr, sessionid2, srfaiagent, srfmode) => {
157
+ id = qxUtil.createUUID();
158
+ abortController = new AbortController();
159
+ const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
160
+ try {
161
+ const questionRequestData = {
162
+ messages: arr,
163
+ sessionid: sessionid2
164
+ };
165
+ if (srfaiagent) {
166
+ questionRequestData.srfaiagent = srfaiagent;
167
+ }
168
+ if (srfmode) {
169
+ questionRequestData.mode = srfmode;
170
+ }
171
+ await deService.aiChatSse(
172
+ (msg) => {
173
+ if (msg.actionstate === 20 && msg.actionresult) {
174
+ aiChat.addMessage({
175
+ messageid: id,
176
+ state: msg.actionstate,
177
+ type: "DEFAULT",
178
+ role: "ASSISTANT",
179
+ content: msg.actionresult
180
+ });
181
+ } else if (msg.actionstate === 30 && msg.actionresult) {
182
+ const result = JSON.parse(msg.actionresult);
183
+ const choices = result.choices;
184
+ if (choices && choices.length > 0) {
185
+ aiChat.replaceMessage({
186
+ messageid: id,
187
+ state: msg.actionstate,
188
+ type: "DEFAULT",
189
+ role: "ASSISTANT",
190
+ content: choices[0].content || ""
191
+ });
192
+ }
193
+ } else if (msg.actionstate === 40) {
194
+ aiChat.replaceMessage({
195
+ messageid: id,
196
+ state: msg.actionstate,
197
+ type: "ERROR",
198
+ role: "ASSISTANT",
199
+ content: msg.actionresult
200
+ });
201
+ }
202
+ },
203
+ abortController,
204
+ ctx,
205
+ param,
206
+ { ...questionRequestData }
207
+ );
208
+ } catch (error) {
209
+ aiChat.replaceMessage({
210
+ messageid: id,
211
+ state: 40,
212
+ type: "ERROR",
213
+ role: "ASSISTANT",
214
+ content: error.message || ibiz.i18n.t("app.aiError")
215
+ });
216
+ abortController == null ? void 0 : abortController.abort();
217
+ } finally {
218
+ aiChat.completeMessage(id, true);
219
+ return true;
220
+ }
221
+ };
222
+ chatOptions.abortQuestion = async (aiChat) => {
223
+ abortController == null ? void 0 : abortController.abort();
224
+ await aiChat.stopMessage({
225
+ messageid: id,
226
+ state: 30,
227
+ type: "DEFAULT",
228
+ role: "ASSISTANT",
229
+ content: ""
230
+ });
231
+ await aiChat.completeMessage(id, true);
232
+ };
233
+ chatOptions.recommendPrompt = async (ctx, param, other) => {
234
+ const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
235
+ const result = await deService.aiChatRecommendPrompt(
236
+ ctx,
237
+ param,
238
+ other.message
239
+ );
240
+ if (result.ok && result.data) {
241
+ const choices = result.data.choices;
242
+ if (choices && choices.length > 0) {
243
+ return choices[0];
244
+ }
245
+ return null;
246
+ }
247
+ return null;
248
+ };
249
+ chatOptions.uploader = {
250
+ onUpload: async (file, reportProgress, options) => {
251
+ const fileMeata = ibiz.util.file.calcFileUpDownUrl(
252
+ (options == null ? void 0 : options.context) || context,
253
+ (options == null ? void 0 : options.params) || params,
254
+ {}
255
+ );
256
+ const fielUploadHeaders = ibiz.util.file.getUploadHeaders();
257
+ const formData = new FormData();
258
+ formData.append("file", file);
259
+ const res = await ibiz.net.axios({
260
+ url: fileMeata.uploadUrl,
261
+ method: "post",
262
+ headers: fielUploadHeaders,
263
+ data: formData,
264
+ onUploadProgress: (progressEvent) => {
265
+ const percent = progressEvent.loaded / progressEvent.total * 100;
266
+ reportProgress(percent);
267
+ }
268
+ });
269
+ return res.data;
270
+ }
271
+ };
272
+ chatOptions.extendToolbarClick = async (event, source, context2, params2, data2) => {
273
+ var _a, _b;
274
+ const result = await runtime.UIActionUtil.exec(
275
+ source.id,
276
+ {
277
+ view,
278
+ ctrl,
279
+ context: core.IBizContext.create(context2),
280
+ params: params2,
281
+ data: [data2],
282
+ event
283
+ },
284
+ source.appId
285
+ );
286
+ if (result.closeView) {
287
+ view.closeView({ ok: true });
288
+ } else if (result.refresh) {
289
+ switch (result.refreshMode) {
290
+ case 1:
291
+ view.callUIAction(runtime.SysUIActionTag.REFRESH);
292
+ break;
293
+ case 2:
294
+ (_a = view.parentView) == null ? void 0 : _a.callUIAction(runtime.SysUIActionTag.REFRESH);
295
+ break;
296
+ case 3:
297
+ (_b = view.getTopView()) == null ? void 0 : _b.callUIAction(runtime.SysUIActionTag.REFRESH);
298
+ break;
299
+ default:
300
+ }
301
+ }
302
+ return result;
303
+ };
304
+ return { containerOptions, topicOptions, chatOptions };
61
305
  }
62
306
  /**
63
307
  * 获取界面行为扩展AI聊天参数
64
308
  * @param context
65
309
  * @param params
66
310
  * @param data
311
+ * @param deACMode
312
+ * @param args
313
+ * @returns
67
314
  */
68
- getUIActionExAIChatParams(context, params, data) {
315
+ async getUIActionExAIChatParams(context, params, data, deACMode, args) {
69
316
  const containerOptions = {};
70
317
  if (params.hasOwnProperty("enableaiminimize")) {
71
318
  containerOptions.enableAIMinimize = params.enableaiminimize === "true";
@@ -89,6 +336,34 @@ class AIChatUtil {
89
336
  ibiz.log.error(error);
90
337
  }
91
338
  }
339
+ const topicOptions = {};
340
+ if (params.hasOwnProperty("topiccaptionmode")) {
341
+ topicOptions.captionMode = params.topiccaptionmode;
342
+ delete params.topiccaptionmode;
343
+ } else {
344
+ topicOptions.captionMode = ibiz.config.common.aiChatTopicCaptionMode;
345
+ }
346
+ topicOptions.beforeDelete = async (...args2) => {
347
+ const isBatchRemove = args2[4];
348
+ const result = await ibiz.confirm.warning({
349
+ title: ibiz.i18n.t(
350
+ "util.appUtil.".concat(isBatchRemove ? "clearTopic" : "aiTitle")
351
+ ),
352
+ desc: ibiz.i18n.t(
353
+ "util.appUtil.".concat(isBatchRemove ? "clearTopicDesc" : "aiDesc")
354
+ )
355
+ });
356
+ return result;
357
+ };
358
+ topicOptions.action = async (action, context2, params2, data2, event) => {
359
+ if (action === "LINK") {
360
+ await ibiz.openView.push(data2.url);
361
+ }
362
+ return true;
363
+ };
364
+ topicOptions.configService = (appid, storageType, subType) => {
365
+ return new runtime.ConfigService(appid, storageType, subType);
366
+ };
92
367
  const chatOptions = {};
93
368
  if (context.srfaiappendcurdata === "true") {
94
369
  chatOptions.appendCurData = data;
@@ -122,7 +397,230 @@ class AIChatUtil {
122
397
  chatOptions.srfMode = params.srfmode;
123
398
  delete params.srfmode;
124
399
  }
125
- return { containerOptions, chatOptions };
400
+ if (params.hasOwnProperty("srfaiagent")) {
401
+ chatOptions.activeAIAgentID = params.srfaiagent;
402
+ delete params.srfaiagent;
403
+ }
404
+ const aiAgentlist = await this.getAIAgentList(context, params);
405
+ chatOptions.aiAgentlist = aiAgentlist;
406
+ if (deACMode) {
407
+ const {
408
+ contentToolbarItems,
409
+ footerToolbarItems,
410
+ questionToolbarItems,
411
+ otherToolbarItems
412
+ } = this.calcAiToolbarItemsByAc(deACMode);
413
+ chatOptions.contentToolbarItems = contentToolbarItems;
414
+ chatOptions.footerToolbarItems = footerToolbarItems;
415
+ chatOptions.questionToolbarItems = questionToolbarItems;
416
+ chatOptions.otherToolbarItems = otherToolbarItems;
417
+ }
418
+ let id = "";
419
+ let abortController;
420
+ const { chatInstance, view, ctrl } = args;
421
+ chatOptions.history = async (ctx, param, other) => {
422
+ const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
423
+ const historyRequestData = {};
424
+ if (other.appendCurData) {
425
+ Object.assign(historyRequestData, {
426
+ ...other.appendCurData
427
+ });
428
+ }
429
+ if (other.sessionid) {
430
+ Object.assign(historyRequestData, {
431
+ sessionid: other.sessionid
432
+ });
433
+ }
434
+ if (other.srfaiagent) {
435
+ Object.assign(historyRequestData, {
436
+ srfaiagent: other.srfaiagent
437
+ });
438
+ }
439
+ if (other.srfmode) {
440
+ Object.assign(historyRequestData, {
441
+ mode: other.srfmode
442
+ });
443
+ }
444
+ const result = await deService.aiChatHistory(
445
+ ctx,
446
+ param,
447
+ historyRequestData
448
+ );
449
+ if (result.data && Array.isArray(result.data)) {
450
+ let preMsg;
451
+ result.data.forEach((item) => {
452
+ if (item.role === "TOOL") {
453
+ if (preMsg && item.content) {
454
+ chatInstance.aiChat.updateRecommendPrompt(
455
+ preMsg,
456
+ item.content
457
+ );
458
+ }
459
+ } else {
460
+ const msg = {
461
+ messageid: qxUtil.createUUID(),
462
+ state: 30,
463
+ type: "DEFAULT",
464
+ role: item.role,
465
+ content: item.content,
466
+ completed: true
467
+ };
468
+ preMsg = msg;
469
+ chatInstance.aiChat.addMessage(msg);
470
+ }
471
+ });
472
+ }
473
+ return true;
474
+ };
475
+ chatOptions.question = async (aiChat, ctx, param, other, arr, sessionid, srfaiagent, srfmode) => {
476
+ id = qxUtil.createUUID();
477
+ abortController = new AbortController();
478
+ const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
479
+ try {
480
+ const questionRequestData = {
481
+ messages: arr,
482
+ sessionid
483
+ };
484
+ if (srfaiagent) {
485
+ questionRequestData.srfaiagent = srfaiagent;
486
+ }
487
+ if (srfmode) {
488
+ questionRequestData.mode = srfmode;
489
+ }
490
+ await deService.aiChatSse(
491
+ (msg) => {
492
+ if (msg.actionstate === 20 && msg.actionresult) {
493
+ aiChat.addMessage({
494
+ messageid: id,
495
+ state: msg.actionstate,
496
+ type: "DEFAULT",
497
+ role: "ASSISTANT",
498
+ content: msg.actionresult
499
+ });
500
+ } else if (msg.actionstate === 30 && msg.actionresult) {
501
+ const result = JSON.parse(msg.actionresult);
502
+ const choices = result.choices;
503
+ if (choices && choices.length > 0) {
504
+ aiChat.replaceMessage({
505
+ messageid: id,
506
+ state: msg.actionstate,
507
+ type: "DEFAULT",
508
+ role: "ASSISTANT",
509
+ content: choices[0].content || ""
510
+ });
511
+ }
512
+ } else if (msg.actionstate === 40) {
513
+ aiChat.replaceMessage({
514
+ messageid: id,
515
+ state: msg.actionstate,
516
+ type: "ERROR",
517
+ role: "ASSISTANT",
518
+ content: msg.actionresult
519
+ });
520
+ }
521
+ },
522
+ abortController,
523
+ ctx,
524
+ param,
525
+ { ...questionRequestData }
526
+ );
527
+ } catch (error) {
528
+ aiChat.replaceMessage({
529
+ messageid: id,
530
+ state: 40,
531
+ type: "ERROR",
532
+ role: "ASSISTANT",
533
+ content: error.message || ibiz.i18n.t("app.aiError")
534
+ });
535
+ abortController == null ? void 0 : abortController.abort();
536
+ } finally {
537
+ aiChat.completeMessage(id, true);
538
+ return true;
539
+ }
540
+ };
541
+ chatOptions.abortQuestion = async (aiChat) => {
542
+ abortController == null ? void 0 : abortController.abort();
543
+ await aiChat.stopMessage({
544
+ messageid: id,
545
+ state: 30,
546
+ type: "DEFAULT",
547
+ role: "ASSISTANT",
548
+ content: ""
549
+ });
550
+ await aiChat.completeMessage(id, true);
551
+ };
552
+ chatOptions.recommendPrompt = async (ctx, param, other) => {
553
+ const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
554
+ const result = await deService.aiChatRecommendPrompt(
555
+ ctx,
556
+ param,
557
+ other.message
558
+ );
559
+ if (result.ok && result.data) {
560
+ const choices = result.data.choices;
561
+ if (choices && choices.length > 0) {
562
+ return choices[0];
563
+ }
564
+ return null;
565
+ }
566
+ return null;
567
+ };
568
+ chatOptions.uploader = {
569
+ onUpload: async (file, reportProgress, options) => {
570
+ const { uploadUrl } = ibiz.util.file.calcFileUpDownUrl(
571
+ (options == null ? void 0 : options.context) || context,
572
+ (options == null ? void 0 : options.params) || params,
573
+ {}
574
+ );
575
+ const headers = ibiz.util.file.getUploadHeaders();
576
+ const formData = new FormData();
577
+ formData.append("file", file);
578
+ const res = await ibiz.net.axios({
579
+ url: uploadUrl,
580
+ method: "post",
581
+ headers,
582
+ data: formData,
583
+ onUploadProgress: (progressEvent) => {
584
+ const percent = progressEvent.loaded / progressEvent.total * 100;
585
+ reportProgress(percent);
586
+ }
587
+ });
588
+ return res.data;
589
+ }
590
+ };
591
+ chatOptions.extendToolbarClick = async (event, source, context2, params2, data2) => {
592
+ var _a, _b;
593
+ const result = await runtime.UIActionUtil.exec(
594
+ source.id,
595
+ {
596
+ view,
597
+ ctrl,
598
+ context: core.IBizContext.create(context2),
599
+ params: params2,
600
+ data: [data2],
601
+ event
602
+ },
603
+ source.appId
604
+ );
605
+ if (result.closeView) {
606
+ view.closeView({ ok: true });
607
+ } else if (result.refresh) {
608
+ switch (result.refreshMode) {
609
+ case 1:
610
+ view.callUIAction(runtime.SysUIActionTag.REFRESH);
611
+ break;
612
+ case 2:
613
+ (_a = view.parentView) == null ? void 0 : _a.callUIAction(runtime.SysUIActionTag.REFRESH);
614
+ break;
615
+ case 3:
616
+ (_b = view.getTopView()) == null ? void 0 : _b.callUIAction(runtime.SysUIActionTag.REFRESH);
617
+ break;
618
+ default:
619
+ }
620
+ }
621
+ return result;
622
+ };
623
+ return { containerOptions, topicOptions, chatOptions };
126
624
  }
127
625
  /**
128
626
  * 计算界面行为扩展AI聊天工具栏项
@@ -200,7 +698,7 @@ class AIChatUtil {
200
698
  return emptyList;
201
699
  }
202
700
  const utilService = new runtime.UtilService(aiAgentUtil);
203
- const resultParams = { ...params };
701
+ const resultParams = { ...params, page: 0, size: 1e3 };
204
702
  if (editorParams && editorParams.srfaiagentscope) {
205
703
  Object.assign(resultParams, {
206
704
  srfaiagentscope: editorParams.srfaiagentscope
@@ -212,6 +710,138 @@ class AIChatUtil {
212
710
  }
213
711
  return data;
214
712
  }
713
+ /**
714
+ * 获取会话标识(TOPIC:适用于多话题场景;INLINE:适用于ai行内会话场景;TEMP:适用于传统ai编辑器会话场景)
715
+ * @param sessionID
716
+ */
717
+ getChatSessionId(type, sessionID) {
718
+ let tempSessionID = "";
719
+ switch (type) {
720
+ case "TOPIC":
721
+ tempSessionID += this.TOPIC_CHAT_PREFIX;
722
+ break;
723
+ case "INLINE":
724
+ tempSessionID += this.INLINE_CHAT_SUFFIX;
725
+ break;
726
+ case "TEMP":
727
+ tempSessionID += this.TEMP_CHAT_SUFFIX;
728
+ break;
729
+ default:
730
+ tempSessionID += this.UNKOWN_CHAT_SUFFIX;
731
+ break;
732
+ }
733
+ tempSessionID += "@".concat(sessionID || qxUtil.createUUID(), "@").concat((/* @__PURE__ */ new Date()).getTime());
734
+ return tempSessionID;
735
+ }
736
+ /**
737
+ * 获取AI会话应用功能
738
+ * @returns
739
+ */
740
+ async getAIResourceUtil() {
741
+ const app = ibiz.hub.getApp(ibiz.env.appId);
742
+ const aiSessionUtil = app.getAppUtil("DYNAMICAISESSION", "CUSTOM");
743
+ return aiSessionUtil;
744
+ }
745
+ /**
746
+ * 获取AI资源参数
747
+ * @returns
748
+ */
749
+ async getAIResourceOptions(context, params) {
750
+ const resourceOptions = {};
751
+ if (ibiz.config.common.aiResourceMode) {
752
+ resourceOptions.resourceMode = ibiz.config.common.aiResourceMode;
753
+ return resourceOptions;
754
+ }
755
+ const aiSessionUtil = await this.getAIResourceUtil();
756
+ resourceOptions.resourceMode = aiSessionUtil ? "REMOTE" : "LOCAL";
757
+ if (!aiSessionUtil) {
758
+ return resourceOptions;
759
+ }
760
+ const utilService = new runtime.AIUtilService(aiSessionUtil);
761
+ resourceOptions.getSessionList = async () => {
762
+ const result = await utilService.getSessionList(context, params);
763
+ return result;
764
+ };
765
+ resourceOptions.updateSession = async (sessionID, data) => {
766
+ const result = await utilService.updateSession(
767
+ context,
768
+ params,
769
+ sessionID,
770
+ data
771
+ );
772
+ return result;
773
+ };
774
+ resourceOptions.deleteSession = async (sessionID) => {
775
+ const result = await utilService.deleteSession(
776
+ context,
777
+ params,
778
+ sessionID
779
+ );
780
+ return result;
781
+ };
782
+ resourceOptions.getMessages = async (sessionID) => {
783
+ const result = await utilService.getMessageList(
784
+ context,
785
+ params,
786
+ sessionID
787
+ );
788
+ return result;
789
+ };
790
+ resourceOptions.deleteMessage = async (sessionID, messageID) => {
791
+ const result = await utilService.deleteMessage(
792
+ context,
793
+ params,
794
+ sessionID,
795
+ messageID
796
+ );
797
+ return result;
798
+ };
799
+ resourceOptions.likeMessage = async (sessionID, messageID) => {
800
+ const result = await utilService.likeMessage(
801
+ context,
802
+ params,
803
+ sessionID,
804
+ messageID
805
+ );
806
+ return result;
807
+ };
808
+ resourceOptions.dislikeMessage = async (sessionID, messageID, feedbackContent) => {
809
+ var _a, _b;
810
+ const overlay = ibiz.overlay.createModal(
811
+ (modal) => {
812
+ return vue.h(aiFeedback.AIFeedback, {
813
+ modal,
814
+ content: feedbackContent
815
+ });
816
+ },
817
+ void 0,
818
+ { width: "520px", height: "auto", showClose: true }
819
+ );
820
+ overlay.present();
821
+ const result = await overlay.onWillDismiss();
822
+ if (!result.ok)
823
+ return false;
824
+ const content = (_b = (_a = result.data) == null ? void 0 : _a[0]) == null ? void 0 : _b.feedbackContent;
825
+ const _result = await utilService.dislikeMessage(
826
+ context,
827
+ params,
828
+ sessionID,
829
+ messageID,
830
+ content
831
+ );
832
+ return _result;
833
+ };
834
+ resourceOptions.cancelFeedback = async (sessionID, messageID) => {
835
+ const result = await utilService.cancelFeedback(
836
+ context,
837
+ params,
838
+ sessionID,
839
+ messageID
840
+ );
841
+ return result;
842
+ };
843
+ return resourceOptions;
844
+ }
215
845
  }
216
846
 
217
847
  exports.AIChatUtil = AIChatUtil;