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

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 (82) hide show
  1. package/dist/ibiz-markdown-editor-CUzKkFER.js +1 -0
  2. package/dist/{index-CaWTEUU1.js → index-DgqTP4Vw.js} +1 -1
  3. package/dist/{index-CD2XM6M6.js → index-Dr0VM8iS.js} +1 -1
  4. package/dist/index-DtEaU3-5.js +11 -0
  5. package/dist/index.min.css +1 -1
  6. package/dist/index.system.min.js +1 -1
  7. package/dist/wang-editor-CRWSwyXY.js +1 -0
  8. package/dist/{xlsx-util-B1eGfH7d.js → xlsx-util-CMJON8Uq.js} +1 -1
  9. package/es/control/grid/grid-column/grid-field-column/attachment-column/attachment-column.mjs +2 -1
  10. package/es/control/grid/grid-column/grid-field-column/attachment-column/file-util.mjs +22 -11
  11. package/es/control/toolbar/export-excel/export-excel.mjs +19 -4
  12. package/es/editor/carousel/ibiz-carousel/ibiz-carousel.mjs +5 -2
  13. package/es/editor/code/monaco-editor/monaco-editor.mjs +8 -194
  14. package/es/editor/html/wang-editor/module/ai-module.mjs +1 -1
  15. package/es/editor/html/wang-editor/wang-editor.mjs +35 -207
  16. package/es/editor/markdown/ibiz-markdown-editor/custom-menu.mjs +11 -222
  17. package/es/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.css +1 -1
  18. package/es/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.mjs +23 -12
  19. package/es/editor/text-box/input/input.mjs +11 -197
  20. package/es/editor/text-box/signature/signature.mjs +28 -15
  21. package/es/editor/upload/upload-editor.controller.mjs +12 -1
  22. package/es/editor/upload/use/use-iview-upload.mjs +28 -13
  23. package/es/locale/en/index.mjs +29 -2
  24. package/es/locale/zh-CN/index.mjs +29 -2
  25. package/es/panel-component/coop-pos/coop-pos.controller.mjs +11 -1
  26. package/es/panel-component/panel-app-title/panel-app-title.controller.mjs +3 -1
  27. package/es/panel-component/panel-app-title/panel-app-title.mjs +22 -43
  28. package/es/util/ai-chat-util/ai-chat-util.mjs +672 -7
  29. package/es/util/ai-chat-util/ai-feedback/ai-feedback.css +1 -0
  30. package/es/util/ai-chat-util/ai-feedback/ai-feedback.mjs +130 -0
  31. package/es/util/app-util/app-util.mjs +26 -247
  32. package/es/util/inline-ai-util/inline-ai-textarea/common/ai-think/ai-think.css +1 -0
  33. package/es/util/inline-ai-util/inline-ai-textarea/common/ai-think/ai-think.mjs +56 -0
  34. package/es/util/inline-ai-util/inline-ai-textarea/common/ai-tool-call/ai-tool-call.css +1 -0
  35. package/es/util/inline-ai-util/inline-ai-textarea/common/ai-tool-call/ai-tool-call.mjs +52 -0
  36. package/es/util/inline-ai-util/inline-ai-textarea/common/ai-tool-call-item/ai-tool-call-item.css +1 -0
  37. package/es/util/inline-ai-util/inline-ai-textarea/common/ai-tool-call-item/ai-tool-call-item.mjs +143 -0
  38. package/es/util/inline-ai-util/inline-ai-textarea/common/index.mjs +4 -0
  39. package/es/util/inline-ai-util/inline-ai-textarea/icon.mjs +52 -1
  40. package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.css +1 -1
  41. package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.mjs +34 -4
  42. package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.mjs +32 -25
  43. package/es/util/inline-ai-util/inline-ai-textarea/interface.mjs +1 -0
  44. package/lib/control/grid/grid-column/grid-field-column/attachment-column/attachment-column.cjs +2 -1
  45. package/lib/control/grid/grid-column/grid-field-column/attachment-column/file-util.cjs +22 -11
  46. package/lib/control/toolbar/export-excel/export-excel.cjs +18 -3
  47. package/lib/editor/carousel/ibiz-carousel/ibiz-carousel.cjs +5 -2
  48. package/lib/editor/code/monaco-editor/monaco-editor.cjs +8 -194
  49. package/lib/editor/html/wang-editor/module/ai-module.cjs +1 -1
  50. package/lib/editor/html/wang-editor/wang-editor.cjs +34 -206
  51. package/lib/editor/markdown/ibiz-markdown-editor/custom-menu.cjs +11 -222
  52. package/lib/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.cjs +23 -12
  53. package/lib/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.css +1 -1
  54. package/lib/editor/text-box/input/input.cjs +10 -196
  55. package/lib/editor/text-box/signature/signature.cjs +28 -15
  56. package/lib/editor/upload/upload-editor.controller.cjs +12 -1
  57. package/lib/editor/upload/use/use-iview-upload.cjs +28 -13
  58. package/lib/locale/en/index.cjs +29 -2
  59. package/lib/locale/zh-CN/index.cjs +29 -2
  60. package/lib/panel-component/coop-pos/coop-pos.controller.cjs +11 -1
  61. package/lib/panel-component/panel-app-title/panel-app-title.cjs +21 -42
  62. package/lib/panel-component/panel-app-title/panel-app-title.controller.cjs +3 -1
  63. package/lib/util/ai-chat-util/ai-chat-util.cjs +670 -5
  64. package/lib/util/ai-chat-util/ai-feedback/ai-feedback.cjs +132 -0
  65. package/lib/util/ai-chat-util/ai-feedback/ai-feedback.css +1 -0
  66. package/lib/util/app-util/app-util.cjs +25 -246
  67. package/lib/util/inline-ai-util/inline-ai-textarea/common/ai-think/ai-think.cjs +58 -0
  68. package/lib/util/inline-ai-util/inline-ai-textarea/common/ai-think/ai-think.css +1 -0
  69. package/lib/util/inline-ai-util/inline-ai-textarea/common/ai-tool-call/ai-tool-call.cjs +54 -0
  70. package/lib/util/inline-ai-util/inline-ai-textarea/common/ai-tool-call/ai-tool-call.css +1 -0
  71. package/lib/util/inline-ai-util/inline-ai-textarea/common/ai-tool-call-item/ai-tool-call-item.cjs +145 -0
  72. package/lib/util/inline-ai-util/inline-ai-textarea/common/ai-tool-call-item/ai-tool-call-item.css +1 -0
  73. package/lib/util/inline-ai-util/inline-ai-textarea/common/index.cjs +9 -0
  74. package/lib/util/inline-ai-util/inline-ai-textarea/icon.cjs +54 -0
  75. package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.cjs +31 -24
  76. package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.css +1 -1
  77. package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.cjs +34 -4
  78. package/lib/util/inline-ai-util/inline-ai-textarea/interface.cjs +3 -0
  79. package/package.json +7 -7
  80. package/dist/ibiz-markdown-editor-pEdb_gS_.js +0 -1
  81. package/dist/index-BObZTN7-.js +0 -11
  82. 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,252 @@ 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
+ realmessageid: choices[0].messageid
192
+ });
193
+ }
194
+ } else if (msg.actionstate === 40) {
195
+ aiChat.replaceMessage({
196
+ messageid: id,
197
+ state: msg.actionstate,
198
+ type: "ERROR",
199
+ role: "ASSISTANT",
200
+ content: msg.actionresult
201
+ });
202
+ }
203
+ },
204
+ abortController,
205
+ ctx,
206
+ param,
207
+ { ...questionRequestData }
208
+ );
209
+ } catch (error) {
210
+ aiChat.replaceMessage({
211
+ messageid: id,
212
+ state: 40,
213
+ type: "ERROR",
214
+ role: "ASSISTANT",
215
+ content: error.message || ibiz.i18n.t("app.aiError")
216
+ });
217
+ abortController == null ? void 0 : abortController.abort();
218
+ } finally {
219
+ aiChat.completeMessage(id, true);
220
+ return true;
221
+ }
222
+ };
223
+ chatOptions.abortQuestion = async (aiChat) => {
224
+ abortController == null ? void 0 : abortController.abort();
225
+ await aiChat.stopMessage({
226
+ messageid: id,
227
+ state: 30,
228
+ type: "DEFAULT",
229
+ role: "ASSISTANT",
230
+ content: ""
231
+ });
232
+ await aiChat.completeMessage(id, true);
233
+ };
234
+ chatOptions.recommendPrompt = async (ctx, param, other) => {
235
+ const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
236
+ const tempParams = { ...param };
237
+ if (other.srfaiagent) {
238
+ tempParams.srfaiagent = other.srfaiagent;
239
+ }
240
+ const result = await deService.aiChatRecommendPrompt(
241
+ ctx,
242
+ tempParams,
243
+ other.message
244
+ );
245
+ if (result.ok && result.data) {
246
+ const choices = result.data.choices;
247
+ if (choices && choices.length > 0) {
248
+ return choices[0];
249
+ }
250
+ return null;
251
+ }
252
+ return null;
253
+ };
254
+ chatOptions.uploader = {
255
+ onUpload: async (file, reportProgress, options) => {
256
+ const fileMeata = ibiz.util.file.calcFileUpDownUrl(
257
+ (options == null ? void 0 : options.context) || context,
258
+ (options == null ? void 0 : options.params) || params,
259
+ {},
260
+ { enableNoAccess: true }
261
+ );
262
+ const fielUploadHeaders = ibiz.util.file.getUploadHeaders();
263
+ const formData = new FormData();
264
+ formData.append("file", file);
265
+ const res = await ibiz.net.axios({
266
+ url: fileMeata.uploadUrl,
267
+ method: "post",
268
+ headers: fielUploadHeaders,
269
+ data: formData,
270
+ onUploadProgress: (progressEvent) => {
271
+ const percent = progressEvent.loaded / progressEvent.total * 100;
272
+ reportProgress(percent);
273
+ }
274
+ });
275
+ return res.data;
276
+ }
277
+ };
278
+ chatOptions.extendToolbarClick = async (event, source, context2, params2, data2) => {
279
+ var _a, _b;
280
+ const result = await runtime.UIActionUtil.exec(
281
+ source.id,
282
+ {
283
+ view,
284
+ ctrl,
285
+ context: core.IBizContext.create(context2),
286
+ params: params2,
287
+ data: [data2],
288
+ event
289
+ },
290
+ source.appId
291
+ );
292
+ if (result.closeView) {
293
+ view.closeView({ ok: true });
294
+ } else if (result.refresh) {
295
+ switch (result.refreshMode) {
296
+ case 1:
297
+ view.callUIAction(runtime.SysUIActionTag.REFRESH);
298
+ break;
299
+ case 2:
300
+ (_a = view.parentView) == null ? void 0 : _a.callUIAction(runtime.SysUIActionTag.REFRESH);
301
+ break;
302
+ case 3:
303
+ (_b = view.getTopView()) == null ? void 0 : _b.callUIAction(runtime.SysUIActionTag.REFRESH);
304
+ break;
305
+ default:
306
+ }
307
+ }
308
+ return result;
309
+ };
310
+ return { containerOptions, topicOptions, chatOptions };
61
311
  }
62
312
  /**
63
313
  * 获取界面行为扩展AI聊天参数
64
314
  * @param context
65
315
  * @param params
66
316
  * @param data
317
+ * @param deACMode
318
+ * @param args
319
+ * @returns
67
320
  */
68
- getUIActionExAIChatParams(context, params, data) {
321
+ async getUIActionExAIChatParams(context, params, data, deACMode, args) {
69
322
  const containerOptions = {};
70
323
  if (params.hasOwnProperty("enableaiminimize")) {
71
324
  containerOptions.enableAIMinimize = params.enableaiminimize === "true";
@@ -89,6 +342,34 @@ class AIChatUtil {
89
342
  ibiz.log.error(error);
90
343
  }
91
344
  }
345
+ const topicOptions = {};
346
+ if (params.hasOwnProperty("topiccaptionmode")) {
347
+ topicOptions.captionMode = params.topiccaptionmode;
348
+ delete params.topiccaptionmode;
349
+ } else {
350
+ topicOptions.captionMode = ibiz.config.common.aiChatTopicCaptionMode;
351
+ }
352
+ topicOptions.beforeDelete = async (...args2) => {
353
+ const isBatchRemove = args2[4];
354
+ const result = await ibiz.confirm.warning({
355
+ title: ibiz.i18n.t(
356
+ "util.appUtil.".concat(isBatchRemove ? "clearTopic" : "aiTitle")
357
+ ),
358
+ desc: ibiz.i18n.t(
359
+ "util.appUtil.".concat(isBatchRemove ? "clearTopicDesc" : "aiDesc")
360
+ )
361
+ });
362
+ return result;
363
+ };
364
+ topicOptions.action = async (action, context2, params2, data2, event) => {
365
+ if (action === "LINK") {
366
+ await ibiz.openView.push(data2.url);
367
+ }
368
+ return true;
369
+ };
370
+ topicOptions.configService = (appid, storageType, subType) => {
371
+ return new runtime.ConfigService(appid, storageType, subType);
372
+ };
92
373
  const chatOptions = {};
93
374
  if (context.srfaiappendcurdata === "true") {
94
375
  chatOptions.appendCurData = data;
@@ -122,7 +403,236 @@ class AIChatUtil {
122
403
  chatOptions.srfMode = params.srfmode;
123
404
  delete params.srfmode;
124
405
  }
125
- return { containerOptions, chatOptions };
406
+ if (params.hasOwnProperty("srfaiagent")) {
407
+ chatOptions.activeAIAgentID = params.srfaiagent;
408
+ delete params.srfaiagent;
409
+ }
410
+ const aiAgentlist = await this.getAIAgentList(context, params);
411
+ chatOptions.aiAgentlist = aiAgentlist;
412
+ if (deACMode) {
413
+ const {
414
+ contentToolbarItems,
415
+ footerToolbarItems,
416
+ questionToolbarItems,
417
+ otherToolbarItems
418
+ } = this.calcAiToolbarItemsByAc(deACMode);
419
+ chatOptions.contentToolbarItems = contentToolbarItems;
420
+ chatOptions.footerToolbarItems = footerToolbarItems;
421
+ chatOptions.questionToolbarItems = questionToolbarItems;
422
+ chatOptions.otherToolbarItems = otherToolbarItems;
423
+ }
424
+ let id = "";
425
+ let abortController;
426
+ const { chatInstance, view, ctrl } = args;
427
+ chatOptions.history = async (ctx, param, other) => {
428
+ const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
429
+ const historyRequestData = {};
430
+ if (other.appendCurData) {
431
+ Object.assign(historyRequestData, {
432
+ ...other.appendCurData
433
+ });
434
+ }
435
+ if (other.sessionid) {
436
+ Object.assign(historyRequestData, {
437
+ sessionid: other.sessionid
438
+ });
439
+ }
440
+ if (other.srfaiagent) {
441
+ Object.assign(historyRequestData, {
442
+ srfaiagent: other.srfaiagent
443
+ });
444
+ }
445
+ if (other.srfmode) {
446
+ Object.assign(historyRequestData, {
447
+ mode: other.srfmode
448
+ });
449
+ }
450
+ const result = await deService.aiChatHistory(
451
+ ctx,
452
+ param,
453
+ historyRequestData
454
+ );
455
+ if (result.data && Array.isArray(result.data)) {
456
+ let preMsg;
457
+ result.data.forEach((item) => {
458
+ if (item.role === "TOOL") {
459
+ if (preMsg && item.content) {
460
+ chatInstance.aiChat.updateRecommendPrompt(
461
+ preMsg,
462
+ item.content
463
+ );
464
+ }
465
+ } else {
466
+ const msg = {
467
+ messageid: qxUtil.createUUID(),
468
+ state: 30,
469
+ type: "DEFAULT",
470
+ role: item.role,
471
+ content: item.content,
472
+ completed: true
473
+ };
474
+ preMsg = msg;
475
+ chatInstance.aiChat.addMessage(msg);
476
+ }
477
+ });
478
+ }
479
+ return true;
480
+ };
481
+ chatOptions.question = async (aiChat, ctx, param, other, arr, sessionid, srfaiagent, srfmode) => {
482
+ id = qxUtil.createUUID();
483
+ abortController = new AbortController();
484
+ const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
485
+ try {
486
+ const questionRequestData = {
487
+ messages: arr,
488
+ sessionid
489
+ };
490
+ if (srfaiagent) {
491
+ questionRequestData.srfaiagent = srfaiagent;
492
+ }
493
+ if (srfmode) {
494
+ questionRequestData.mode = srfmode;
495
+ }
496
+ await deService.aiChatSse(
497
+ (msg) => {
498
+ if (msg.actionstate === 20 && msg.actionresult) {
499
+ aiChat.addMessage({
500
+ messageid: id,
501
+ state: msg.actionstate,
502
+ type: "DEFAULT",
503
+ role: "ASSISTANT",
504
+ content: msg.actionresult
505
+ });
506
+ } else if (msg.actionstate === 30 && msg.actionresult) {
507
+ const result = JSON.parse(msg.actionresult);
508
+ const choices = result.choices;
509
+ if (choices && choices.length > 0) {
510
+ aiChat.replaceMessage({
511
+ messageid: id,
512
+ state: msg.actionstate,
513
+ type: "DEFAULT",
514
+ role: "ASSISTANT",
515
+ content: choices[0].content || "",
516
+ realmessageid: choices[0].messageid
517
+ });
518
+ }
519
+ } else if (msg.actionstate === 40) {
520
+ aiChat.replaceMessage({
521
+ messageid: id,
522
+ state: msg.actionstate,
523
+ type: "ERROR",
524
+ role: "ASSISTANT",
525
+ content: msg.actionresult
526
+ });
527
+ }
528
+ },
529
+ abortController,
530
+ ctx,
531
+ param,
532
+ { ...questionRequestData }
533
+ );
534
+ } catch (error) {
535
+ aiChat.replaceMessage({
536
+ messageid: id,
537
+ state: 40,
538
+ type: "ERROR",
539
+ role: "ASSISTANT",
540
+ content: error.message || ibiz.i18n.t("app.aiError")
541
+ });
542
+ abortController == null ? void 0 : abortController.abort();
543
+ } finally {
544
+ aiChat.completeMessage(id, true);
545
+ return true;
546
+ }
547
+ };
548
+ chatOptions.abortQuestion = async (aiChat) => {
549
+ abortController == null ? void 0 : abortController.abort();
550
+ await aiChat.stopMessage({
551
+ messageid: id,
552
+ state: 30,
553
+ type: "DEFAULT",
554
+ role: "ASSISTANT",
555
+ content: ""
556
+ });
557
+ await aiChat.completeMessage(id, true);
558
+ };
559
+ chatOptions.recommendPrompt = async (ctx, param, other) => {
560
+ const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
561
+ const tempParams = { ...param };
562
+ if (other.srfaiagent) {
563
+ tempParams.srfaiagent = other.srfaiagent;
564
+ }
565
+ const result = await deService.aiChatRecommendPrompt(
566
+ ctx,
567
+ tempParams,
568
+ other.message
569
+ );
570
+ if (result.ok && result.data) {
571
+ const choices = result.data.choices;
572
+ if (choices && choices.length > 0) {
573
+ return choices[0];
574
+ }
575
+ return null;
576
+ }
577
+ return null;
578
+ };
579
+ chatOptions.uploader = {
580
+ onUpload: async (file, reportProgress, options) => {
581
+ const { uploadUrl } = ibiz.util.file.calcFileUpDownUrl(
582
+ (options == null ? void 0 : options.context) || context,
583
+ (options == null ? void 0 : options.params) || params,
584
+ {},
585
+ { enableNoAccess: true }
586
+ );
587
+ const headers = ibiz.util.file.getUploadHeaders();
588
+ const formData = new FormData();
589
+ formData.append("file", file);
590
+ const res = await ibiz.net.axios({
591
+ url: uploadUrl,
592
+ method: "post",
593
+ headers,
594
+ data: formData,
595
+ onUploadProgress: (progressEvent) => {
596
+ const percent = progressEvent.loaded / progressEvent.total * 100;
597
+ reportProgress(percent);
598
+ }
599
+ });
600
+ return res.data;
601
+ }
602
+ };
603
+ chatOptions.extendToolbarClick = async (event, source, context2, params2, data2) => {
604
+ var _a, _b;
605
+ const result = await runtime.UIActionUtil.exec(
606
+ source.id,
607
+ {
608
+ view,
609
+ ctrl,
610
+ context: core.IBizContext.create(context2),
611
+ params: params2,
612
+ data: [data2],
613
+ event
614
+ },
615
+ source.appId
616
+ );
617
+ if (result.closeView) {
618
+ view.closeView({ ok: true });
619
+ } else if (result.refresh) {
620
+ switch (result.refreshMode) {
621
+ case 1:
622
+ view.callUIAction(runtime.SysUIActionTag.REFRESH);
623
+ break;
624
+ case 2:
625
+ (_a = view.parentView) == null ? void 0 : _a.callUIAction(runtime.SysUIActionTag.REFRESH);
626
+ break;
627
+ case 3:
628
+ (_b = view.getTopView()) == null ? void 0 : _b.callUIAction(runtime.SysUIActionTag.REFRESH);
629
+ break;
630
+ default:
631
+ }
632
+ }
633
+ return result;
634
+ };
635
+ return { containerOptions, topicOptions, chatOptions };
126
636
  }
127
637
  /**
128
638
  * 计算界面行为扩展AI聊天工具栏项
@@ -200,7 +710,7 @@ class AIChatUtil {
200
710
  return emptyList;
201
711
  }
202
712
  const utilService = new runtime.UtilService(aiAgentUtil);
203
- const resultParams = { ...params };
713
+ const resultParams = { ...params, page: 0, size: 1e3 };
204
714
  if (editorParams && editorParams.srfaiagentscope) {
205
715
  Object.assign(resultParams, {
206
716
  srfaiagentscope: editorParams.srfaiagentscope
@@ -212,6 +722,161 @@ class AIChatUtil {
212
722
  }
213
723
  return data;
214
724
  }
725
+ /**
726
+ * 获取会话标识(TOPIC:适用于多话题场景;INLINE:适用于ai行内会话场景;TEMP:适用于传统ai编辑器会话场景)
727
+ * @param sessionID
728
+ */
729
+ getChatSessionId(type, sessionID) {
730
+ let tempSessionID = "";
731
+ switch (type) {
732
+ case "TOPIC":
733
+ tempSessionID += this.TOPIC_CHAT_PREFIX;
734
+ break;
735
+ case "INLINE":
736
+ tempSessionID += this.INLINE_CHAT_SUFFIX;
737
+ break;
738
+ case "TEMP":
739
+ tempSessionID += this.TEMP_CHAT_SUFFIX;
740
+ break;
741
+ default:
742
+ tempSessionID += this.UNKOWN_CHAT_SUFFIX;
743
+ break;
744
+ }
745
+ tempSessionID += "@".concat(sessionID || qxUtil.createUUID(), "@").concat((/* @__PURE__ */ new Date()).getTime());
746
+ return tempSessionID;
747
+ }
748
+ /**
749
+ * 获取AI会话应用功能
750
+ * @returns
751
+ */
752
+ async getAIResourceUtil() {
753
+ const app = ibiz.hub.getApp(ibiz.env.appId);
754
+ const aiSessionUtil = app.getAppUtil("DYNAMICAISESSION", "CUSTOM");
755
+ return aiSessionUtil;
756
+ }
757
+ /**
758
+ * 获取AI资源参数
759
+ * @returns
760
+ */
761
+ async getAIResourceOptions(context, params) {
762
+ const resourceOptions = {};
763
+ if (ibiz.config.common.aiResourceMode) {
764
+ resourceOptions.resourceMode = ibiz.config.common.aiResourceMode;
765
+ return resourceOptions;
766
+ }
767
+ const aiSessionUtil = await this.getAIResourceUtil();
768
+ resourceOptions.resourceMode = aiSessionUtil ? "REMOTE" : "LOCAL";
769
+ if (!aiSessionUtil) {
770
+ return resourceOptions;
771
+ }
772
+ const utilService = new runtime.AIUtilService(aiSessionUtil);
773
+ resourceOptions.getSessionList = async (args = {}) => {
774
+ const tempParams = { ...params, page: 0, size: 1e3, ...args };
775
+ const result = await utilService.getSessionList(context, tempParams);
776
+ return result;
777
+ };
778
+ resourceOptions.updateSession = async (realID, data) => {
779
+ const result = await utilService.updateSession(
780
+ context,
781
+ params,
782
+ realID,
783
+ data
784
+ );
785
+ return result;
786
+ };
787
+ resourceOptions.deleteSession = async (realID) => {
788
+ const result = await utilService.deleteSession(context, params, realID);
789
+ return result;
790
+ };
791
+ resourceOptions.getMessages = async (args = {}) => {
792
+ const tempParams = { ...params, page: 0, size: 1e3, ...args };
793
+ const result = await utilService.getMessageList(context, tempParams);
794
+ return result;
795
+ };
796
+ resourceOptions.deleteMessage = async (messageID) => {
797
+ const result = await utilService.deleteMessage(
798
+ context,
799
+ params,
800
+ messageID
801
+ );
802
+ return result;
803
+ };
804
+ resourceOptions.likeMessage = async (messageID) => {
805
+ const result = await utilService.likeMessage(context, params, messageID);
806
+ return result;
807
+ };
808
+ resourceOptions.dislikeMessage = async (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
+ messageID,
829
+ content
830
+ );
831
+ return _result;
832
+ };
833
+ resourceOptions.cancelFeedback = async (messageID) => {
834
+ const result = await utilService.cancelFeedback(
835
+ context,
836
+ params,
837
+ messageID
838
+ );
839
+ return result;
840
+ };
841
+ resourceOptions.clearAllSession = async (excludeSessionID) => {
842
+ const result = await utilService.clearAllSession(
843
+ context,
844
+ params,
845
+ excludeSessionID
846
+ );
847
+ return result;
848
+ };
849
+ resourceOptions.clearAllMessageBySessionId = async (realID) => {
850
+ const result = await utilService.clearAllMessageBySessionId(
851
+ context,
852
+ params,
853
+ realID
854
+ );
855
+ return result;
856
+ };
857
+ return resourceOptions;
858
+ }
859
+ /**
860
+ * 获取AI聊天模式
861
+ * @param type 场景类型:UIACTION:界面行为;EDITOR:编辑器
862
+ * @param context
863
+ * @param params
864
+ * @param editorParams
865
+ */
866
+ getAIChatMode(type, context, params, editorParams) {
867
+ switch (type) {
868
+ case "UIACTION":
869
+ if (params.srfenabletempmode && params.srfenabletempmode === "true") {
870
+ delete params.srfenabletempmode;
871
+ return "DEFAULT";
872
+ }
873
+ return "TOPIC";
874
+ case "EDITOR":
875
+ return "DEFAULT";
876
+ default:
877
+ return "DEFAULT";
878
+ }
879
+ }
215
880
  }
216
881
 
217
882
  exports.AIChatUtil = AIChatUtil;