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