@ibiz-template/vue3-components 0.7.41-alpha.149 → 0.7.41-alpha.150

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.
@@ -19,6 +19,8 @@ class AIChatUtil {
19
19
  __publicField(this, "TEMP_CHAT_SUFFIX", "temp");
20
20
  __publicField(this, "UNKOWN_CHAT_SUFFIX", "unknow");
21
21
  __publicField(this, "PRE_ERROR_MESSAGE", "Expected content-type to be text/event-stream, Actual: application/json;charset=UTF-8");
22
+ // 无流内容回来
23
+ __publicField(this, "NONE_ERROR_MESSAGE", "Expected content-type to be text/event-stream, Actual: null");
22
24
  }
23
25
  /**
24
26
  * 获取AI聊天对象
@@ -366,7 +368,9 @@ class AIChatUtil {
366
368
  await deService.aiChatSse(
367
369
  (msg) => {
368
370
  if (msg.actionstate === 20 && msg.actionresult) {
369
- aiChat.setActiveAsyncacitonId(msg.asyncacitonid);
371
+ if (!aiChat.getActiveAsyncacitonId()) {
372
+ aiChat.setActiveAsyncacitonId(msg.asyncacitonid);
373
+ }
370
374
  aiChat.addMessage({
371
375
  messageid: id,
372
376
  state: msg.actionstate,
@@ -431,6 +435,7 @@ class AIChatUtil {
431
435
  abortController == null ? void 0 : abortController.abort();
432
436
  } finally {
433
437
  aiChat.completeMessage(id, true);
438
+ aiChat.setActiveAsyncacitonId("");
434
439
  return true;
435
440
  }
436
441
  };
@@ -467,6 +472,106 @@ class AIChatUtil {
467
472
  });
468
473
  await aiChat.completeMessage(id, true);
469
474
  };
475
+ chatOptions.resumeQuestion = async (aiChat, ctx, param, other, arr) => {
476
+ if (other.asyncacitonid) {
477
+ id = createUUID();
478
+ abortController = new AbortController();
479
+ const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
480
+ const resumeRequestData = { asyncacitonid: other.asyncacitonid };
481
+ if (other.sessionid) {
482
+ Object.assign(resumeRequestData, {
483
+ sessionid: other.sessionid
484
+ });
485
+ }
486
+ if (other.srfaiagent) {
487
+ Object.assign(resumeRequestData, {
488
+ srfaiagent: other.srfaiagent
489
+ });
490
+ }
491
+ if (other.srfproject)
492
+ Object.assign(resumeRequestData, {
493
+ srfproject: other.srfproject
494
+ });
495
+ try {
496
+ await deService.aiResumeSse(
497
+ (msg) => {
498
+ if (msg.actionstate === 20 && msg.actionresult) {
499
+ aiChat.isLoading.value = true;
500
+ if (!aiChat.getActiveAsyncacitonId()) {
501
+ aiChat.setActiveAsyncacitonId(msg.asyncacitonid);
502
+ }
503
+ aiChat.addMessage({
504
+ messageid: id,
505
+ state: msg.actionstate,
506
+ type: "DEFAULT",
507
+ role: "ASSISTANT",
508
+ content: msg.actionresult,
509
+ status: "pending"
510
+ });
511
+ } else if (msg.actionstate === 30 && msg.actionresult) {
512
+ const result = JSON.parse(msg.actionresult);
513
+ if (result.usage) {
514
+ aiChat.updateMsgUsage(id, result.usage);
515
+ }
516
+ const choices = result.choices;
517
+ if (choices && choices.length > 0) {
518
+ aiChat.replaceMessage({
519
+ messageid: id,
520
+ state: msg.actionstate,
521
+ type: "DEFAULT",
522
+ role: "ASSISTANT",
523
+ content: choices[0].content || "",
524
+ realmessageid: choices[0].messageid,
525
+ status: "sent"
526
+ });
527
+ }
528
+ } else if (msg.actionstate === 40) {
529
+ aiChat.replaceMessage({
530
+ messageid: id,
531
+ state: msg.actionstate,
532
+ type: "ERROR",
533
+ role: "ASSISTANT",
534
+ errorText: msg.actionresult,
535
+ status: "failed"
536
+ });
537
+ }
538
+ },
539
+ abortController,
540
+ ctx,
541
+ { srfactag: param.srfactag },
542
+ { ...resumeRequestData }
543
+ );
544
+ } catch (error) {
545
+ if (error && error.message !== this.NONE_ERROR_MESSAGE) {
546
+ if (error && error.message !== this.PRE_ERROR_MESSAGE) {
547
+ aiChat.replaceMessage({
548
+ messageid: id,
549
+ state: 40,
550
+ type: "ERROR",
551
+ role: "ASSISTANT",
552
+ errorText: error.message || ibiz.i18n.t("app.aiError"),
553
+ status: "failed"
554
+ });
555
+ } else {
556
+ const lastMessage = arr[arr.length - 1];
557
+ aiChat.replaceMessage(
558
+ {
559
+ ...lastMessage,
560
+ state: 40
561
+ },
562
+ false
563
+ );
564
+ }
565
+ }
566
+ abortController == null ? void 0 : abortController.abort();
567
+ } finally {
568
+ aiChat.isLoading.value = false;
569
+ aiChat.completeMessage(id, true);
570
+ aiChat.setActiveAsyncacitonId("");
571
+ return true;
572
+ }
573
+ }
574
+ };
470
575
  chatOptions.supplementQuestion = async (aiChat, ctx, param, other) => {
471
576
  const asyncacitonid = aiChat.getActiveAsyncacitonId();
472
577
  if (asyncacitonid) {
@@ -1064,7 +1169,9 @@ class AIChatUtil {
1064
1169
  await deService.aiChatSse(
1065
1170
  (msg) => {
1066
1171
  if (msg.actionstate === 20 && msg.actionresult) {
1067
- aiChat.setActiveAsyncacitonId(msg.asyncacitonid);
1172
+ if (!aiChat.getActiveAsyncacitonId()) {
1173
+ aiChat.setActiveAsyncacitonId(msg.asyncacitonid);
1174
+ }
1068
1175
  aiChat.addMessage({
1069
1176
  messageid: id,
1070
1177
  state: msg.actionstate,
@@ -1128,6 +1235,7 @@ class AIChatUtil {
1128
1235
  }
1129
1236
  abortController == null ? void 0 : abortController.abort();
1130
1237
  } finally {
1238
+ aiChat.setActiveAsyncacitonId("");
1131
1239
  aiChat.completeMessage(id, true);
1132
1240
  return true;
1133
1241
  }
@@ -1165,6 +1273,106 @@ class AIChatUtil {
1165
1273
  });
1166
1274
  await aiChat.completeMessage(id, true);
1167
1275
  };
1276
+ chatOptions.resumeQuestion = async (aiChat, ctx, param, other, arr) => {
1277
+ if (other.asyncacitonid) {
1278
+ id = createUUID();
1279
+ abortController = new AbortController();
1280
+ const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
1281
+ const resumeRequestData = { asyncacitonid: other.asyncacitonid };
1282
+ if (other.sessionid) {
1283
+ Object.assign(resumeRequestData, {
1284
+ sessionid: other.sessionid
1285
+ });
1286
+ }
1287
+ if (other.srfaiagent) {
1288
+ Object.assign(resumeRequestData, {
1289
+ srfaiagent: other.srfaiagent
1290
+ });
1291
+ }
1292
+ if (other.srfproject)
1293
+ Object.assign(resumeRequestData, {
1294
+ srfproject: other.srfproject
1295
+ });
1296
+ try {
1297
+ await deService.aiResumeSse(
1298
+ (msg) => {
1299
+ if (msg.actionstate === 20 && msg.actionresult) {
1300
+ aiChat.isLoading.value = true;
1301
+ if (!aiChat.getActiveAsyncacitonId()) {
1302
+ aiChat.setActiveAsyncacitonId(msg.asyncacitonid);
1303
+ }
1304
+ aiChat.addMessage({
1305
+ messageid: id,
1306
+ state: msg.actionstate,
1307
+ type: "DEFAULT",
1308
+ role: "ASSISTANT",
1309
+ content: msg.actionresult,
1310
+ status: "pending"
1311
+ });
1312
+ } else if (msg.actionstate === 30 && msg.actionresult) {
1313
+ const result = JSON.parse(msg.actionresult);
1314
+ if (result.usage) {
1315
+ aiChat.updateMsgUsage(id, result.usage);
1316
+ }
1317
+ const choices = result.choices;
1318
+ if (choices && choices.length > 0) {
1319
+ aiChat.replaceMessage({
1320
+ messageid: id,
1321
+ state: msg.actionstate,
1322
+ type: "DEFAULT",
1323
+ role: "ASSISTANT",
1324
+ content: choices[0].content || "",
1325
+ realmessageid: choices[0].messageid,
1326
+ status: "sent"
1327
+ });
1328
+ }
1329
+ } else if (msg.actionstate === 40) {
1330
+ aiChat.replaceMessage({
1331
+ messageid: id,
1332
+ state: msg.actionstate,
1333
+ type: "ERROR",
1334
+ role: "ASSISTANT",
1335
+ errorText: msg.actionresult,
1336
+ status: "failed"
1337
+ });
1338
+ }
1339
+ },
1340
+ abortController,
1341
+ ctx,
1342
+ { srfactag: param.srfactag },
1343
+ { ...resumeRequestData }
1344
+ );
1345
+ } catch (error) {
1346
+ if (error && error.message !== this.NONE_ERROR_MESSAGE) {
1347
+ if (error && error.message !== this.PRE_ERROR_MESSAGE) {
1348
+ aiChat.replaceMessage({
1349
+ messageid: id,
1350
+ state: 40,
1351
+ type: "ERROR",
1352
+ role: "ASSISTANT",
1353
+ errorText: error.message || ibiz.i18n.t("app.aiError"),
1354
+ status: "failed"
1355
+ });
1356
+ } else {
1357
+ const lastMessage = arr[arr.length - 1];
1358
+ aiChat.replaceMessage(
1359
+ {
1360
+ ...lastMessage,
1361
+ state: 40
1362
+ },
1363
+ false
1364
+ );
1365
+ }
1366
+ }
1367
+ abortController == null ? void 0 : abortController.abort();
1368
+ } finally {
1369
+ aiChat.isLoading.value = false;
1370
+ aiChat.completeMessage(id, true);
1371
+ aiChat.setActiveAsyncacitonId("");
1372
+ return true;
1373
+ }
1374
+ }
1375
+ };
1168
1376
  chatOptions.supplementQuestion = async (aiChat, ctx, param, other) => {
1169
1377
  const asyncacitonid = aiChat.getActiveAsyncacitonId();
1170
1378
  if (asyncacitonid) {
@@ -21,6 +21,8 @@ class AIChatUtil {
21
21
  __publicField(this, "TEMP_CHAT_SUFFIX", "temp");
22
22
  __publicField(this, "UNKOWN_CHAT_SUFFIX", "unknow");
23
23
  __publicField(this, "PRE_ERROR_MESSAGE", "Expected content-type to be text/event-stream, Actual: application/json;charset=UTF-8");
24
+ // 无流内容回来
25
+ __publicField(this, "NONE_ERROR_MESSAGE", "Expected content-type to be text/event-stream, Actual: null");
24
26
  }
25
27
  /**
26
28
  * 获取AI聊天对象
@@ -368,7 +370,9 @@ class AIChatUtil {
368
370
  await deService.aiChatSse(
369
371
  (msg) => {
370
372
  if (msg.actionstate === 20 && msg.actionresult) {
371
- aiChat.setActiveAsyncacitonId(msg.asyncacitonid);
373
+ if (!aiChat.getActiveAsyncacitonId()) {
374
+ aiChat.setActiveAsyncacitonId(msg.asyncacitonid);
375
+ }
372
376
  aiChat.addMessage({
373
377
  messageid: id,
374
378
  state: msg.actionstate,
@@ -433,6 +437,7 @@ class AIChatUtil {
433
437
  abortController == null ? void 0 : abortController.abort();
434
438
  } finally {
435
439
  aiChat.completeMessage(id, true);
440
+ aiChat.setActiveAsyncacitonId("");
436
441
  return true;
437
442
  }
438
443
  };
@@ -469,6 +474,106 @@ class AIChatUtil {
469
474
  });
470
475
  await aiChat.completeMessage(id, true);
471
476
  };
477
+ chatOptions.resumeQuestion = async (aiChat, ctx, param, other, arr) => {
478
+ if (other.asyncacitonid) {
479
+ id = qxUtil.createUUID();
480
+ abortController = new AbortController();
481
+ const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
482
+ const resumeRequestData = { asyncacitonid: other.asyncacitonid };
483
+ if (other.sessionid) {
484
+ Object.assign(resumeRequestData, {
485
+ sessionid: other.sessionid
486
+ });
487
+ }
488
+ if (other.srfaiagent) {
489
+ Object.assign(resumeRequestData, {
490
+ srfaiagent: other.srfaiagent
491
+ });
492
+ }
493
+ if (other.srfproject)
494
+ Object.assign(resumeRequestData, {
495
+ srfproject: other.srfproject
496
+ });
497
+ try {
498
+ await deService.aiResumeSse(
499
+ (msg) => {
500
+ if (msg.actionstate === 20 && msg.actionresult) {
501
+ aiChat.isLoading.value = true;
502
+ if (!aiChat.getActiveAsyncacitonId()) {
503
+ aiChat.setActiveAsyncacitonId(msg.asyncacitonid);
504
+ }
505
+ aiChat.addMessage({
506
+ messageid: id,
507
+ state: msg.actionstate,
508
+ type: "DEFAULT",
509
+ role: "ASSISTANT",
510
+ content: msg.actionresult,
511
+ status: "pending"
512
+ });
513
+ } else if (msg.actionstate === 30 && msg.actionresult) {
514
+ const result = JSON.parse(msg.actionresult);
515
+ if (result.usage) {
516
+ aiChat.updateMsgUsage(id, result.usage);
517
+ }
518
+ const choices = result.choices;
519
+ if (choices && choices.length > 0) {
520
+ aiChat.replaceMessage({
521
+ messageid: id,
522
+ state: msg.actionstate,
523
+ type: "DEFAULT",
524
+ role: "ASSISTANT",
525
+ content: choices[0].content || "",
526
+ realmessageid: choices[0].messageid,
527
+ status: "sent"
528
+ });
529
+ }
530
+ } else if (msg.actionstate === 40) {
531
+ aiChat.replaceMessage({
532
+ messageid: id,
533
+ state: msg.actionstate,
534
+ type: "ERROR",
535
+ role: "ASSISTANT",
536
+ errorText: msg.actionresult,
537
+ status: "failed"
538
+ });
539
+ }
540
+ },
541
+ abortController,
542
+ ctx,
543
+ { srfactag: param.srfactag },
544
+ { ...resumeRequestData }
545
+ );
546
+ } catch (error) {
547
+ if (error && error.message !== this.NONE_ERROR_MESSAGE) {
548
+ if (error && error.message !== this.PRE_ERROR_MESSAGE) {
549
+ aiChat.replaceMessage({
550
+ messageid: id,
551
+ state: 40,
552
+ type: "ERROR",
553
+ role: "ASSISTANT",
554
+ errorText: error.message || ibiz.i18n.t("app.aiError"),
555
+ status: "failed"
556
+ });
557
+ } else {
558
+ const lastMessage = arr[arr.length - 1];
559
+ aiChat.replaceMessage(
560
+ {
561
+ ...lastMessage,
562
+ state: 40
563
+ },
564
+ false
565
+ );
566
+ }
567
+ }
568
+ abortController == null ? void 0 : abortController.abort();
569
+ } finally {
570
+ aiChat.isLoading.value = false;
571
+ aiChat.completeMessage(id, true);
572
+ aiChat.setActiveAsyncacitonId("");
573
+ return true;
574
+ }
575
+ }
576
+ };
472
577
  chatOptions.supplementQuestion = async (aiChat, ctx, param, other) => {
473
578
  const asyncacitonid = aiChat.getActiveAsyncacitonId();
474
579
  if (asyncacitonid) {
@@ -1066,7 +1171,9 @@ class AIChatUtil {
1066
1171
  await deService.aiChatSse(
1067
1172
  (msg) => {
1068
1173
  if (msg.actionstate === 20 && msg.actionresult) {
1069
- aiChat.setActiveAsyncacitonId(msg.asyncacitonid);
1174
+ if (!aiChat.getActiveAsyncacitonId()) {
1175
+ aiChat.setActiveAsyncacitonId(msg.asyncacitonid);
1176
+ }
1070
1177
  aiChat.addMessage({
1071
1178
  messageid: id,
1072
1179
  state: msg.actionstate,
@@ -1130,6 +1237,7 @@ class AIChatUtil {
1130
1237
  }
1131
1238
  abortController == null ? void 0 : abortController.abort();
1132
1239
  } finally {
1240
+ aiChat.setActiveAsyncacitonId("");
1133
1241
  aiChat.completeMessage(id, true);
1134
1242
  return true;
1135
1243
  }
@@ -1167,6 +1275,106 @@ class AIChatUtil {
1167
1275
  });
1168
1276
  await aiChat.completeMessage(id, true);
1169
1277
  };
1278
+ chatOptions.resumeQuestion = async (aiChat, ctx, param, other, arr) => {
1279
+ if (other.asyncacitonid) {
1280
+ id = qxUtil.createUUID();
1281
+ abortController = new AbortController();
1282
+ const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
1283
+ const resumeRequestData = { asyncacitonid: other.asyncacitonid };
1284
+ if (other.sessionid) {
1285
+ Object.assign(resumeRequestData, {
1286
+ sessionid: other.sessionid
1287
+ });
1288
+ }
1289
+ if (other.srfaiagent) {
1290
+ Object.assign(resumeRequestData, {
1291
+ srfaiagent: other.srfaiagent
1292
+ });
1293
+ }
1294
+ if (other.srfproject)
1295
+ Object.assign(resumeRequestData, {
1296
+ srfproject: other.srfproject
1297
+ });
1298
+ try {
1299
+ await deService.aiResumeSse(
1300
+ (msg) => {
1301
+ if (msg.actionstate === 20 && msg.actionresult) {
1302
+ aiChat.isLoading.value = true;
1303
+ if (!aiChat.getActiveAsyncacitonId()) {
1304
+ aiChat.setActiveAsyncacitonId(msg.asyncacitonid);
1305
+ }
1306
+ aiChat.addMessage({
1307
+ messageid: id,
1308
+ state: msg.actionstate,
1309
+ type: "DEFAULT",
1310
+ role: "ASSISTANT",
1311
+ content: msg.actionresult,
1312
+ status: "pending"
1313
+ });
1314
+ } else if (msg.actionstate === 30 && msg.actionresult) {
1315
+ const result = JSON.parse(msg.actionresult);
1316
+ if (result.usage) {
1317
+ aiChat.updateMsgUsage(id, result.usage);
1318
+ }
1319
+ const choices = result.choices;
1320
+ if (choices && choices.length > 0) {
1321
+ aiChat.replaceMessage({
1322
+ messageid: id,
1323
+ state: msg.actionstate,
1324
+ type: "DEFAULT",
1325
+ role: "ASSISTANT",
1326
+ content: choices[0].content || "",
1327
+ realmessageid: choices[0].messageid,
1328
+ status: "sent"
1329
+ });
1330
+ }
1331
+ } else if (msg.actionstate === 40) {
1332
+ aiChat.replaceMessage({
1333
+ messageid: id,
1334
+ state: msg.actionstate,
1335
+ type: "ERROR",
1336
+ role: "ASSISTANT",
1337
+ errorText: msg.actionresult,
1338
+ status: "failed"
1339
+ });
1340
+ }
1341
+ },
1342
+ abortController,
1343
+ ctx,
1344
+ { srfactag: param.srfactag },
1345
+ { ...resumeRequestData }
1346
+ );
1347
+ } catch (error) {
1348
+ if (error && error.message !== this.NONE_ERROR_MESSAGE) {
1349
+ if (error && error.message !== this.PRE_ERROR_MESSAGE) {
1350
+ aiChat.replaceMessage({
1351
+ messageid: id,
1352
+ state: 40,
1353
+ type: "ERROR",
1354
+ role: "ASSISTANT",
1355
+ errorText: error.message || ibiz.i18n.t("app.aiError"),
1356
+ status: "failed"
1357
+ });
1358
+ } else {
1359
+ const lastMessage = arr[arr.length - 1];
1360
+ aiChat.replaceMessage(
1361
+ {
1362
+ ...lastMessage,
1363
+ state: 40
1364
+ },
1365
+ false
1366
+ );
1367
+ }
1368
+ }
1369
+ abortController == null ? void 0 : abortController.abort();
1370
+ } finally {
1371
+ aiChat.isLoading.value = false;
1372
+ aiChat.completeMessage(id, true);
1373
+ aiChat.setActiveAsyncacitonId("");
1374
+ return true;
1375
+ }
1376
+ }
1377
+ };
1170
1378
  chatOptions.supplementQuestion = async (aiChat, ctx, param, other) => {
1171
1379
  const asyncacitonid = aiChat.getActiveAsyncacitonId();
1172
1380
  if (asyncacitonid) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template/vue3-components",
3
- "version": "0.7.41-alpha.149",
3
+ "version": "0.7.41-alpha.150",
4
4
  "description": "web端组件库(vue3)",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "es/index.mjs",
@@ -31,16 +31,16 @@
31
31
  "dependencies": {
32
32
  "@amap/amap-jsapi-loader": "^1.0.1",
33
33
  "@floating-ui/dom": "^1.5.3",
34
- "@ibiz-template-plugin/ai-chat": "^0.0.114",
34
+ "@ibiz-template-plugin/ai-chat": "^0.0.115",
35
35
  "@ibiz-template-plugin/gantt": "0.1.8-alpha.468",
36
36
  "@ibiz-template-plugin/bi-report": "0.0.32",
37
37
  "@ibiz-template-plugin/data-view": "0.0.8",
38
38
  "@ibiz-template/core": "0.7.41-alpha.150",
39
39
  "@ibiz-template/devtool": "0.0.17",
40
- "@ibiz-template/model-helper": "0.7.41-alpha.150",
41
- "@ibiz-template/runtime": "0.7.41-alpha.150",
40
+ "@ibiz-template/model-helper": "0.7.41-alpha.151",
41
+ "@ibiz-template/runtime": "0.7.41-alpha.151",
42
42
  "@ibiz-template/theme": "0.7.39",
43
- "@ibiz-template/vue3-util": "0.7.41-alpha.150",
43
+ "@ibiz-template/vue3-util": "0.7.41-alpha.151",
44
44
  "@ibiz-template/web-theme": "3.16.0",
45
45
  "@ibiz/model-core": "^0.1.89",
46
46
  "@imengyu/vue3-context-menu": "^1.3.5",