@myun/gimi-chat 0.9.45 → 0.9.47

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 (52) hide show
  1. package/dist/apis/useApi.d.ts +6 -0
  2. package/dist/apis/useApi.js +45 -1
  3. package/dist/components/ai-chat-dialogue/index copy.js +1 -1
  4. package/dist/components/ai-chat-dialogue/index.js +4 -2
  5. package/dist/components/answer-item/component/artifacts/index.d.ts +13 -0
  6. package/dist/components/answer-item/component/artifacts/index.js +52 -0
  7. package/dist/components/answer-item/component/artifacts/index.module.css +24 -0
  8. package/dist/components/answer-item/component/tool-list/index.d.ts +7 -0
  9. package/dist/components/answer-item/component/tool-list/index.js +97 -0
  10. package/dist/components/answer-item/component/tool-list/index.module.css +92 -0
  11. package/dist/components/answer-item/index.d.ts +2 -1
  12. package/dist/components/answer-item/index.js +160 -7
  13. package/dist/components/answer-item/index.module.css +24 -0
  14. package/dist/components/ask-card/index.d.ts +1 -1
  15. package/dist/components/chat-input/extension/index.d.ts +1 -0
  16. package/dist/components/chat-input/extension/index.js +2 -1
  17. package/dist/components/chat-input/extension/skill/MentionList.d.ts +30 -0
  18. package/dist/components/chat-input/extension/skill/MentionList.js +181 -0
  19. package/dist/components/chat-input/extension/skill/ReferSlot.d.ts +3 -0
  20. package/dist/components/chat-input/extension/skill/ReferSlot.js +100 -0
  21. package/dist/components/chat-input/extension/skill/data.d.ts +10 -0
  22. package/dist/components/chat-input/extension/skill/data.js +49 -0
  23. package/dist/components/chat-input/extension/skill/index.d.ts +7 -0
  24. package/dist/components/chat-input/extension/skill/index.js +5 -0
  25. package/dist/components/chat-input/extension/skill/index.less +100 -0
  26. package/dist/components/chat-input/extension/skill/suggestion.d.ts +14 -0
  27. package/dist/components/chat-input/extension/skill/suggestion.js +173 -0
  28. package/dist/components/chat-input/index.js +63 -15
  29. package/dist/components/file-card/index.js +2 -1
  30. package/dist/components/file-card/index.module.css +1 -0
  31. package/dist/components/knowledge-trace/tryWatch.js +8 -1
  32. package/dist/components/message-list/index.js +15 -3
  33. package/dist/components/message-list/index.module.css +3 -0
  34. package/dist/components/message-list/skill-tag/index.d.ts +5 -0
  35. package/dist/components/message-list/skill-tag/index.js +24 -0
  36. package/dist/components/message-list/skill-tag/index.module.css +22 -0
  37. package/dist/components/templates/CommonChat.js +3 -1
  38. package/dist/hooks/useChatActions.d.ts +2 -1
  39. package/dist/hooks/useChatActions.js +41 -3
  40. package/dist/hooks/useChatStream.d.ts +6 -1
  41. package/dist/hooks/useChatStream.js +96 -5
  42. package/dist/hooks/useCommonChatAPI.d.ts +1 -1
  43. package/dist/hooks/useCommonChatAPI.js +190 -54
  44. package/dist/i18n/locales/en-US.d.ts +3 -0
  45. package/dist/i18n/locales/en-US.js +10 -7
  46. package/dist/i18n/locales/zh-CN.d.ts +3 -0
  47. package/dist/i18n/locales/zh-CN.js +4 -1
  48. package/dist/interfaces/chatMessage.d.ts +38 -0
  49. package/dist/umd/index.min.js +1 -1
  50. package/dist/utils/tools.d.ts +6 -0
  51. package/dist/utils/tools.js +31 -0
  52. package/package.json +4 -2
@@ -24,12 +24,14 @@ import { useTranslation } from 'react-i18next';
24
24
  import { Toast } from "@douyinfe/semi-ui";
25
25
  import { useAppDispatch, useAppSelector } from "../store/hooks";
26
26
  import { setMessageList, setFileList, setConversationId, setAgentDetail, setBusinessParams, setAutoLoadConversation, updateState, closeSidebar } from "../store/slices/gimiMenuSlice";
27
+ import { getToolNameByStatus } from "./useChatStream";
27
28
  import { fileValidation, getTimeZone, parseMessageContent, processString } from "../utils/tools";
28
29
  import { filterPropmptFromUserInput } from "../utils/tools";
29
30
  import { useChatMessage } from "./useChatMessage";
30
31
  import { useChatStream } from "./useChatStream";
31
32
  import { useLastEventId } from "./useLastEventId";
32
33
  import useScroll from "./useScroll";
34
+ // 获取推荐课程
33
35
  import { useChatRecommend } from "./useChatRecommend";
34
36
  import { set, cloneDeep } from 'lodash';
35
37
  import { FileStatus } from "../interfaces/fileInterface";
@@ -301,7 +303,13 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
301
303
  reasoningStatus: content ? 2 : 3,
302
304
  msgLoading: false,
303
305
  relatedResourceList: [],
304
- mcp: null
306
+ mcp: null,
307
+ thinkingInfo: {
308
+ status: "COMPLETED",
309
+ toolName: "已完成",
310
+ collapse: true,
311
+ loaded: false
312
+ }
305
313
  })]);
306
314
  dispatch(setMessageList({
307
315
  messageList: _newMessageList
@@ -342,8 +350,64 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
342
350
  messageList: newMessageList
343
351
  }));
344
352
  }, [dispatch]);
353
+ var handleToolStreamRs = React.useCallback(function (dataObj) {
354
+ setStatus(2);
355
+ var messageList = messageListRef.current;
356
+ var lastMessage = messageList[messageList.length - 1];
357
+ var curToolList = _toConsumableArray((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.toolList) || []);
358
+ var curToolIndex = curToolList.findIndex(function (item) {
359
+ return (item === null || item === void 0 ? void 0 : item.id) === dataObj.id;
360
+ });
361
+
362
+ // 为新节点类型根据 status 生成 toolName
363
+ var isNewNodeType = !['tool_invocation', 'tool_result'].includes(dataObj.moduleType);
364
+ var toolName = isNewNodeType ? getToolNameByStatus(dataObj.moduleType, dataObj.status) : dataObj.toolName;
365
+ if (curToolIndex >= 0) {
366
+ curToolList[curToolIndex] = _objectSpread(_objectSpread({}, curToolList[curToolIndex]), {}, {
367
+ content: dataObj.moduleType === 'thinking' ? dataObj.reasoningContent : dataObj.content || '',
368
+ // tool_invocation 更新 toolName 和 status,新节点类型也更新
369
+ toolName: dataObj.moduleType === 'tool_invocation' ? dataObj.toolName || '' : isNewNodeType ? toolName : curToolList[curToolIndex].toolName,
370
+ status: dataObj.moduleType === 'tool_invocation' || isNewNodeType ? dataObj.status : curToolList[curToolIndex].status
371
+ });
372
+ } else {
373
+ // 新增工具时,为新节点类型补充 toolName
374
+ // agent 类类型,保持只有一个 agent
375
+ if (dataObj.moduleType === 'agent' && curToolList.length > 0) return;
376
+ curToolList = curToolList.filter(function (tool) {
377
+ return tool.moduleType !== 'agent';
378
+ });
379
+ curToolList = [].concat(_toConsumableArray(curToolList), [_objectSpread(_objectSpread({}, dataObj), {}, {
380
+ toolName: toolName || dataObj.toolName
381
+ })]);
382
+ }
383
+ var newMessageList = [].concat(_toConsumableArray(messageList.slice(0, -1)), [_objectSpread(_objectSpread({}, lastMessage), {}, {
384
+ moduleType: dataObj.moduleType,
385
+ toolList: _toConsumableArray(curToolList)
386
+ })]);
387
+ dispatch(setMessageList({
388
+ messageList: newMessageList
389
+ }));
390
+ }, [dispatch]);
391
+ var handleArtifactStreamRs = React.useCallback(function (dataObj) {
392
+ setStatus(2);
393
+ var messageList = messageListRef.current;
394
+ var lastMessage = messageList[messageList.length - 1];
395
+ var newMessageList = [].concat(_toConsumableArray(messageList.slice(0, -1)), [_objectSpread(_objectSpread({}, lastMessage), {}, {
396
+ moduleType: dataObj.moduleType,
397
+ artifacts: dataObj.artifacts || []
398
+ })]);
399
+ dispatch(setMessageList({
400
+ messageList: newMessageList
401
+ }));
402
+ }, [dispatch]);
345
403
 
346
404
  // 发起会话 - 使用新的hook简化逻辑
405
+ // @param id 会话ID
406
+ // @param reSumeInfo 恢复信息
407
+ // @param onSseOpen 开启SSE回调
408
+ // @param onDataReceived 数据接收回调
409
+ // @param onComplete 完成回调
410
+ // @param onErrorComplete 错误完成回调
347
411
  var fetchChatStream = React.useCallback( /*#__PURE__*/function () {
348
412
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(id, reSumeInfo, _onSseOpen, _onDataReceived, _onComplete, _onErrorComplete) {
349
413
  var fullResponse, reasoningResponse;
@@ -368,10 +432,10 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
368
432
  }
369
433
  _onDataReceived(response, type);
370
434
  },
371
- onComplete: function onComplete(response, type) {
435
+ onComplete: function onComplete(response, type, reasoning, dataObj) {
372
436
  if (type === 'end' || type === 'COMPLETED') {
373
437
  removeLastEventId(id);
374
- _onComplete(fullResponse, type, reasoningResponse);
438
+ _onComplete(fullResponse, type, reasoningResponse, dataObj);
375
439
  } else {
376
440
  moduleInfoRef.current = response;
377
441
  _onComplete(response, type);
@@ -382,6 +446,12 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
382
446
  },
383
447
  onMCPToolsStream: function onMCPToolsStream(dataObj) {
384
448
  handleMCPToolsStreamRs(dataObj);
449
+ },
450
+ onToolStream: function onToolStream(dataObj) {
451
+ handleToolStreamRs(dataObj);
452
+ },
453
+ onArtifactStream: function onArtifactStream(dataObj) {
454
+ handleArtifactStreamRs(dataObj);
385
455
  }
386
456
  });
387
457
  case 5:
@@ -393,7 +463,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
393
463
  return function (_x, _x2, _x3, _x4, _x5, _x6) {
394
464
  return _ref5.apply(this, arguments);
395
465
  };
396
- }(), [fetchChatStreamHook, setIgnoreOnMessage, removeLastEventId, handleMCPToolsStreamRs]);
466
+ }(), [fetchChatStreamHook, setIgnoreOnMessage, removeLastEventId, handleMCPToolsStreamRs, handleToolStreamRs, handleArtifactStreamRs]);
397
467
  var getRelatedCourses = React.useCallback( /*#__PURE__*/function () {
398
468
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(input) {
399
469
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
@@ -461,22 +531,69 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
461
531
  setMsgLoading(false);
462
532
  setStatus(2);
463
533
  var currentMessageList = messageListRef.current;
464
- var newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, type, response || ''), "loading", again ? false : true), "msgLoading", false), "vipLevel", vipLevelRef.current), "reasoningLoading", type === 'content' ? false : again ? false : true), "reasoningStatus", type === 'content' ? 2 : 1), "moduleInfo", null), "moduleType", 'end'), "mcp", null))]);
534
+ var lastToolList = _toConsumableArray(currentMessageList[currentMessageList.length - 1].toolList || []);
535
+ if (lastToolList.findIndex(function (v) {
536
+ return v.moduleType === 'end';
537
+ }) < 0) {
538
+ lastToolList.push({
539
+ moduleType: 'end',
540
+ content: '',
541
+ status: "RUNNING",
542
+ toolName: "正在整理答案",
543
+ id: "".concat(new Date().getTime())
544
+ });
545
+ }
546
+ var newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, type, response || ''), "loading", again ? false : true), "msgLoading", false), "vipLevel", vipLevelRef.current), "reasoningLoading", type === 'content' ? false : again ? false : true), "reasoningStatus", type === 'content' ? 2 : 1), "moduleInfo", null), "moduleType", 'end'), "mcp", null), "toolList", lastToolList))]);
465
547
  dispatch(setMessageList({
466
548
  messageList: newMessageList
467
549
  }));
468
550
  }, /*#__PURE__*/function () {
469
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(Response, type, reasoningResponse) {
470
- var currentMessageList, newMessageList, agentDetail, userInput;
551
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(Response, type, reasoningResponse, dataObj) {
552
+ var currentMessageList, lastToolList, newMessageList, agentDetail, userInput;
471
553
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
472
554
  while (1) switch (_context5.prev = _context5.next) {
473
555
  case 0:
474
556
  // if (isSystemAuto) return;
475
557
  setIgnoreOnMessage(true);
476
558
  currentMessageList = messageListRef.current;
477
- newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
478
- moduleType: type
479
- }, type === 'end' ? 'content' : 'moduleInfo', Response), "reasoningResponse", type === 'end' ? reasoningResponse : ''), "loading", false), "reasoningLoading", false), "mcp", null))]);
559
+ lastToolList = _toConsumableArray(currentMessageList[currentMessageList.length - 1].toolList || []);
560
+ newMessageList = [];
561
+ if (type === 'user_confirm') {
562
+ newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, {
563
+ moduleType: type,
564
+ moduleInfo: Response,
565
+ reasoningResponse: '',
566
+ loading: false,
567
+ reasoningLoading: false,
568
+ mcp: null,
569
+ thinkingInfo: {
570
+ status: "RUNNING",
571
+ toolName: "已完成",
572
+ collapse: false,
573
+ loaded: true
574
+ },
575
+ toolList: [].concat(_toConsumableArray(lastToolList), [{
576
+ moduleType: type,
577
+ content: '',
578
+ data: Response,
579
+ status: "RUNNING",
580
+ toolName: "等待人工确认",
581
+ confirmStatus: "PENDING",
582
+ id: "".concat(new Date().getTime())
583
+ }])
584
+ })]);
585
+ } else {
586
+ newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
587
+ moduleType: type
588
+ }, type === 'end' ? 'content' : 'moduleInfo', Response), "reasoningResponse", type === 'end' ? reasoningResponse : ''), "loading", false), "reasoningLoading", false), "mcp", null), "durationMs", (dataObj === null || dataObj === void 0 ? void 0 : dataObj.elapsed) || 0), "totalTokens", (dataObj === null || dataObj === void 0 ? void 0 : dataObj.totalTokens) || 0), "thinkingInfo", {
589
+ status: type === 'end' ? "COMPLETED" : "RUNNING",
590
+ toolName: "已完成",
591
+ collapse: true,
592
+ loaded: true
593
+ }), "toolList", _toConsumableArray(lastToolList.slice(0, -1).filter(function (v) {
594
+ return v.moduleType !== "agent";
595
+ }))))]);
596
+ }
480
597
  dispatch(setMessageList({
481
598
  messageList: newMessageList
482
599
  }));
@@ -487,13 +604,13 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
487
604
  // 获取最新的agent详情,防止redux异步更新
488
605
  agentDetail = agentInfo || agentObjRef.current; // 获取推荐追问
489
606
  if (!((agentDetail === null || agentDetail === void 0 ? void 0 : agentDetail.isEnableRelated) === 1 && (type === 'end' || type === 'COMPLETED'))) {
490
- _context5.next = 10;
607
+ _context5.next = 12;
491
608
  break;
492
609
  }
493
610
  setMsgLoading(true);
494
- _context5.next = 10;
611
+ _context5.next = 12;
495
612
  return getRecommendList(newMessageList, lastId, statusRef.current);
496
- case 10:
613
+ case 12:
497
614
  // 获取相关课程
498
615
  userInput = newMessageList[newMessageList.length - 2].content;
499
616
  getRelatedCourses(userInput || '');
@@ -504,13 +621,13 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
504
621
  }
505
622
  setMsgLoading(false);
506
623
  onSendEnd === null || onSendEnd === void 0 || onSendEnd(newMessageList[newMessageList.length - 1]);
507
- case 15:
624
+ case 17:
508
625
  case "end":
509
626
  return _context5.stop();
510
627
  }
511
628
  }, _callee5);
512
629
  }));
513
- return function (_x10, _x11, _x12) {
630
+ return function (_x10, _x11, _x12, _x13) {
514
631
  return _ref8.apply(this, arguments);
515
632
  };
516
633
  }(), function () {
@@ -643,7 +760,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
643
760
  }
644
761
  }, _callee8);
645
762
  }));
646
- return function (_x13) {
763
+ return function (_x14) {
647
764
  return _ref10.apply(this, arguments);
648
765
  };
649
766
  }(), [dispatch, streamChat, removeLastEventId, rewriteRecommendListFormHistory, getRelatedCourses]);
@@ -669,6 +786,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
669
786
  var isSystemAuto,
670
787
  conversationId,
671
788
  isAskFileSend,
789
+ skipCreateNewMessage,
672
790
  val,
673
791
  signal,
674
792
  currentBusinessParams,
@@ -688,6 +806,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
688
806
  isSystemAuto = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : false;
689
807
  conversationId = _args9.length > 2 ? _args9[2] : undefined;
690
808
  isAskFileSend = _args9.length > 3 ? _args9[3] : undefined;
809
+ skipCreateNewMessage = _args9.length > 4 ? _args9[4] : undefined;
691
810
  // 如果是ask卡片的file上传,发送content为''
692
811
  val = isAskFileSend ? '' : (_reverse$find = _toConsumableArray(messageList).reverse().find(function (item) {
693
812
  return item.role === 0;
@@ -702,7 +821,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
702
821
  signal = controllerRef.current.signal;
703
822
  step.current = 1;
704
823
  currentBusinessParams = _objectSpread({}, businessParamsRef.current || {});
705
- _context9.prev = 10;
824
+ _context9.prev = 11;
706
825
  params = _objectSpread({
707
826
  content: val,
708
827
  conversationId: conversationId || conversationIdRef.current,
@@ -736,7 +855,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
736
855
  if (isSystemAuto) {
737
856
  params.isSystemAuto = 1;
738
857
  }
739
- _context9.next = 20;
858
+ _context9.next = 21;
740
859
  return fetch("https://".concat(baseUrlRef.current, "/mbot/web/agent-message"), {
741
860
  method: 'POST',
742
861
  headers: {
@@ -748,15 +867,15 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
748
867
  signal: signal,
749
868
  body: JSON.stringify(params)
750
869
  });
751
- case 20:
870
+ case 21:
752
871
  _response = _context9.sent;
753
872
  if (!_response.ok) {
754
- _context9.next = 29;
873
+ _context9.next = 31;
755
874
  break;
756
875
  }
757
- _context9.next = 24;
876
+ _context9.next = 25;
758
877
  return _response.json();
759
- case 24:
878
+ case 25:
760
879
  responseMsg = _context9.sent;
761
880
  // 执行使用方定义的回调函数
762
881
  if (!onFirstSendSuccessCalledRef.current) {
@@ -769,14 +888,16 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
769
888
  dispatch(setFileList({
770
889
  fileList: []
771
890
  }));
891
+ inputModelRef.current = null; // 清空 inputModel,避免下次发送时残留
892
+
772
893
  if (responseMsg.status === 0) {
773
- result = responseMsg.result;
774
- aiChat = createAiChat(result); // 根据isSystemAuto决定是否添加AI消息到列表
775
- // if (!isSystemAuto) {
776
- dispatch(setMessageList({
777
- messageList: [].concat(_toConsumableArray(messageList), [aiChat])
778
- }));
779
- // }
894
+ result = responseMsg.result; // 如果 skipCreateNewMessage 为 true,不创建新消息,直接用当前最后一条
895
+ if (!skipCreateNewMessage) {
896
+ aiChat = createAiChat(result);
897
+ dispatch(setMessageList({
898
+ messageList: [].concat(_toConsumableArray(messageList), [aiChat])
899
+ }));
900
+ }
780
901
  // 继续流式处理聊天
781
902
  streamChat(result.id, false);
782
903
  } else {
@@ -788,12 +909,12 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
788
909
  setStatus(0);
789
910
  }
790
911
  }
791
- case 29:
792
- _context9.next = 34;
793
- break;
794
912
  case 31:
795
- _context9.prev = 31;
796
- _context9.t0 = _context9["catch"](10);
913
+ _context9.next = 36;
914
+ break;
915
+ case 33:
916
+ _context9.prev = 33;
917
+ _context9.t0 = _context9["catch"](11);
797
918
  if (_context9.t0.name === 'AbortError') {
798
919
  setMsgLoading(false);
799
920
  if (inputValue) {
@@ -810,17 +931,21 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
810
931
  setStatus(0);
811
932
  }
812
933
  }
813
- case 34:
934
+ case 36:
814
935
  case "end":
815
936
  return _context9.stop();
816
937
  }
817
- }, _callee9, null, [[10, 31]]);
938
+ }, _callee9, null, [[11, 33]]);
818
939
  }));
819
- return function (_x14) {
940
+ return function (_x15) {
820
941
  return _ref11.apply(this, arguments);
821
942
  };
822
943
  }(), [dispatch, inputValue, streamEsAbortRef]);
823
944
  var fillInputModel = React.useCallback(function (value, messageList) {
945
+ // 如果 inputModelRef 已经被设置(confirm/ask点击等),不要覆盖
946
+ if (inputModelRef.current) {
947
+ return;
948
+ }
824
949
  if ((messageList === null || messageList === void 0 ? void 0 : messageList.length) > 0 && value && messageList[messageList.length - 1].moduleType === 'ask') {
825
950
  var targetChatItem = _toConsumableArray(messageList).reverse().find(function (item) {
826
951
  return item.role === 1;
@@ -831,12 +956,15 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
831
956
  inputModelRef.current = _inputModel;
832
957
  }
833
958
  }, []);
959
+
960
+ // 点击发送按钮
834
961
  var handleSend = React.useCallback( /*#__PURE__*/function () {
835
962
  var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(val) {
836
963
  var _chatInputConfig$onBe;
837
964
  var agent,
838
965
  isSystemAuto,
839
966
  conversationId,
967
+ skipCreateNewMessage,
840
968
  value,
841
969
  fileValidationMsg,
842
970
  cleanVal,
@@ -852,39 +980,40 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
852
980
  agent = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : agentObj;
853
981
  isSystemAuto = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : false;
854
982
  conversationId = _args10.length > 3 ? _args10[3] : undefined;
983
+ skipCreateNewMessage = _args10.length > 4 ? _args10[4] : undefined;
855
984
  value = val.trim();
856
985
  if (!(!value && !isSystemAuto)) {
857
- _context10.next = 6;
986
+ _context10.next = 7;
858
987
  break;
859
988
  }
860
989
  return _context10.abrupt("return");
861
- case 6:
990
+ case 7:
862
991
  if (navigator.onLine) {
863
- _context10.next = 9;
992
+ _context10.next = 10;
864
993
  break;
865
994
  }
866
995
  Toast.error(t('common.networkUnavailable'));
867
996
  return _context10.abrupt("return");
868
- case 9:
997
+ case 10:
869
998
  if (!(status === 2 || msgLoading)) {
870
- _context10.next = 12;
999
+ _context10.next = 13;
871
1000
  break;
872
1001
  }
873
1002
  Toast.error(t('chatApi.aiResponding'));
874
1003
  return _context10.abrupt("return");
875
- case 12:
1004
+ case 13:
876
1005
  chatInputConfig === null || chatInputConfig === void 0 || (_chatInputConfig$onBe = chatInputConfig.onBeforeSend) === null || _chatInputConfig$onBe === void 0 || _chatInputConfig$onBe.call(chatInputConfig, value);
877
1006
 
878
1007
  // 设置inputModel
879
1008
  fillInputModel(value, messageListRef.current);
880
1009
  fileValidationMsg = fileValidation(fileListRef.current);
881
1010
  if (!fileValidationMsg) {
882
- _context10.next = 18;
1011
+ _context10.next = 19;
883
1012
  break;
884
1013
  }
885
1014
  Toast.error(fileValidationMsg);
886
1015
  return _context10.abrupt("return");
887
- case 18:
1016
+ case 19:
888
1017
  if (isPlaying) {
889
1018
  // 点击发送按钮时,先停止播放
890
1019
  stopTTSByText === null || stopTTSByText === void 0 || stopTTSByText();
@@ -909,19 +1038,19 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
909
1038
  dispatch(setMessageList({
910
1039
  messageList: newChatList
911
1040
  }));
912
- startChat(newChatList, isSystemAuto, conversationId);
1041
+ startChat(newChatList, isSystemAuto, conversationId, undefined, skipCreateNewMessage);
913
1042
  } else {
914
1043
  setMsgLoading(true);
915
1044
  // 系统自动上传,直接开始会话,不更新列表
916
- startChat(_toConsumableArray(prevChatList), isSystemAuto, conversationId);
1045
+ startChat(_toConsumableArray(prevChatList), isSystemAuto, conversationId, undefined, skipCreateNewMessage);
917
1046
  }
918
- case 24:
1047
+ case 25:
919
1048
  case "end":
920
1049
  return _context10.stop();
921
1050
  }
922
1051
  }, _callee10);
923
1052
  }));
924
- return function (_x15) {
1053
+ return function (_x16) {
925
1054
  return _ref12.apply(this, arguments);
926
1055
  };
927
1056
  }(), [dispatch, startChat, chatInputConfig, createUserChat, fillInputModel, isPlaying, status, stopTTSByText, msgLoading, agentObj]);
@@ -959,7 +1088,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
959
1088
  }
960
1089
  }, _callee11, null, [[2, 9]]);
961
1090
  }));
962
- return function (_x16) {
1091
+ return function (_x17) {
963
1092
  return _ref13.apply(this, arguments);
964
1093
  };
965
1094
  }(), [t]);
@@ -1042,7 +1171,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
1042
1171
  }
1043
1172
  }, _callee12, null, [[0, 14]]);
1044
1173
  }));
1045
- return function (_x17) {
1174
+ return function (_x18) {
1046
1175
  return _ref14.apply(this, arguments);
1047
1176
  };
1048
1177
  }(), []);
@@ -1106,7 +1235,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
1106
1235
  }
1107
1236
  }, _callee13, null, [[6, 14]]);
1108
1237
  }));
1109
- return function (_x18) {
1238
+ return function (_x19) {
1110
1239
  return _ref15.apply(this, arguments);
1111
1240
  };
1112
1241
  }(), [handleSend, platform, dispatch, createRoomId, onConversationCreated, getHeaderValue, t]);
@@ -1218,10 +1347,17 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
1218
1347
  }, [dispatch, handleSend]);
1219
1348
  React.useEffect(function () {
1220
1349
  if ((messageList === null || messageList === void 0 ? void 0 : messageList.length) > 0) {
1221
- var _chatItem$moduleInfo, _chatItem$moduleInfo2;
1350
+ var _chatItem$toolList, _chatItem$moduleInfo, _chatItem$moduleInfo2;
1222
1351
  // 设置输入框是否可点击
1223
1352
  var chatItem = messageList[messageList.length - 1];
1224
- if (chatItem.moduleType === 'ask' && (chatItem === null || chatItem === void 0 || (_chatItem$moduleInfo = chatItem.moduleInfo) === null || _chatItem$moduleInfo === void 0 || (_chatItem$moduleInfo = _chatItem$moduleInfo.data) === null || _chatItem$moduleInfo === void 0 || (_chatItem$moduleInfo = _chatItem$moduleInfo.results) === null || _chatItem$moduleInfo === void 0 ? void 0 : _chatItem$moduleInfo.askShowInfo.answerType) === 1) {
1353
+
1354
+ // 检查是否有等待用户确认的 user_confirm
1355
+ var hasWaitingConfirm = (_chatItem$toolList = chatItem.toolList) === null || _chatItem$toolList === void 0 ? void 0 : _chatItem$toolList.some(function (tool) {
1356
+ return tool.moduleType === 'user_confirm' && tool.status === 'RUNNING';
1357
+ });
1358
+ if (hasWaitingConfirm) {
1359
+ setDisableSend(true);
1360
+ } else if (chatItem.moduleType === 'ask' && (chatItem === null || chatItem === void 0 || (_chatItem$moduleInfo = chatItem.moduleInfo) === null || _chatItem$moduleInfo === void 0 || (_chatItem$moduleInfo = _chatItem$moduleInfo.data) === null || _chatItem$moduleInfo === void 0 || (_chatItem$moduleInfo = _chatItem$moduleInfo.results) === null || _chatItem$moduleInfo === void 0 ? void 0 : _chatItem$moduleInfo.askShowInfo.answerType) === 1) {
1225
1361
  setDisableSend(true);
1226
1362
  } else if (chatItem.moduleType === 'skill' && (chatItem === null || chatItem === void 0 || (_chatItem$moduleInfo2 = chatItem.moduleInfo) === null || _chatItem$moduleInfo2 === void 0 || (_chatItem$moduleInfo2 = _chatItem$moduleInfo2.data) === null || _chatItem$moduleInfo2 === void 0 || (_chatItem$moduleInfo2 = _chatItem$moduleInfo2.results) === null || _chatItem$moduleInfo2 === void 0 ? void 0 : _chatItem$moduleInfo2.skillResult.requestStatus) !== 1) {
1227
1363
  setDisableSend(true);
@@ -49,6 +49,7 @@ declare const enUS: {
49
49
  'trace.video.unsupportedTips': string;
50
50
  'trace.information.unsupportedTips': string;
51
51
  'trace.notPermission': string;
52
+ 'trace.noAccessibleCourse': string;
52
53
  'trace.tryWatchVideo': string;
53
54
  'trace.tryWatchDocument': string;
54
55
  'trace.tryWatchInformation': string;
@@ -96,6 +97,7 @@ declare const enUS: {
96
97
  'common.dataLoading': string;
97
98
  'common.pleaseWait': string;
98
99
  'common.empty': string;
100
+ 'common.noSkill': string;
99
101
  'common.delete': string;
100
102
  'common.cancel': string;
101
103
  'common.retry': string;
@@ -255,5 +257,6 @@ declare const enUS: {
255
257
  'informationDetail.applicableCountry': string;
256
258
  'informationDetail.signDate': string;
257
259
  'informationDetail.executeDate': string;
260
+ 'common.selectSkill': string;
258
261
  };
259
262
  export default enUS;
@@ -18,14 +18,14 @@ var enUS = {
18
18
  'chatInput.flowUnsupported': 'This button is not supported in the current flow. Please wait for the current flow to finish or follow the instructions on the chat card.',
19
19
  'chatInput.uploadFile': 'Supports Word, Excel,and Images.\nUp to 10 files (max 10MB each)',
20
20
  'chatInput.newConversation': 'New conversation',
21
- 'chatInput.deepThinkTip': 'System Automatically Switched Thinking Mode',
22
- 'chatInput.deepThinkModeAuto': 'Thinking',
21
+ 'chatInput.deepThinkTip': 'Auto-switching thinking mode',
22
+ 'chatInput.deepThinkModeAuto': 'Deep Thinking',
23
23
  'chatInput.fetchingVoice': 'Capturing Voice Input...',
24
24
  'chatInput.voiceCallUnsupported': 'Voice call is not supported in the current flow',
25
25
  'chatInput.micPermissionRequired': 'Microphone access required',
26
26
  'chatInput.more': 'More',
27
27
  'chatInput.stopVoiceInput': 'Stop Voice Input',
28
- 'chatInput.aiGeneratedTip': 'AI-generated response for reference only',
28
+ 'chatInput.aiGeneratedTip': 'AI-generated content is for reference only',
29
29
  'answer.taskCompleted': 'Task completed!',
30
30
  'answer.stopped': 'Stopped',
31
31
  'answer.courseRecommend': 'Related Courses',
@@ -49,6 +49,7 @@ var enUS = {
49
49
  'trace.video.unsupportedTips': 'This video does not support trial preview.\nTo view the full video, click the "View" button.',
50
50
  'trace.information.unsupportedTips': 'The following content is not available for trial preview',
51
51
  'trace.notPermission': 'No access rights',
52
+ 'trace.noAccessibleCourse': 'No accessible course content',
52
53
  'trace.tryWatchVideo': 'Video',
53
54
  'trace.tryWatchDocument': 'Document',
54
55
  'trace.tryWatchInformation': 'Information',
@@ -69,13 +70,13 @@ var enUS = {
69
70
  'file.viewAll': 'All',
70
71
  'quote.name': 'Name',
71
72
  'quote.currentVideo': 'Current Video',
72
- 'quote.currentCourseVideo': 'Current Course Video',
73
+ 'quote.currentCourseVideo': 'Course Videos',
73
74
  'quote.relatedVideos': 'Related Videos',
74
75
  'quote.courseTooltip': 'Cited Course',
75
76
  'quote.maxResources': 'Maximum 10 resources',
76
77
  'quote.imageAlt': 'Cited resource image',
77
- 'quote.durationMinutes': 'Duration {{minutes}} min',
78
- 'quote.empty': 'No resources cited',
78
+ 'quote.durationMinutes': 'Duration: {{minutes}} mins',
79
+ 'quote.empty': 'No Data Available',
79
80
  'reasoning.deepThinking': 'Deep Thinking',
80
81
  'reasoning.startAnalysis': 'Start Analysis',
81
82
  'reasoning.status.thinking': 'Thinking',
@@ -96,6 +97,7 @@ var enUS = {
96
97
  'common.dataLoading': 'Data loading...',
97
98
  'common.pleaseWait': 'Please wait...',
98
99
  'common.empty': 'No content',
100
+ 'common.noSkill': 'No Skill',
99
101
  'common.delete': 'Delete',
100
102
  'common.cancel': 'Cancel',
101
103
  'common.retry': 'Retry',
@@ -254,6 +256,7 @@ var enUS = {
254
256
  'informationDetail.taxPreferenceLabel': 'Tax Preference:',
255
257
  'informationDetail.applicableCountry': 'Applicable Country:',
256
258
  'informationDetail.signDate': 'Sign Date:',
257
- 'informationDetail.executeDate': 'Execute Date:'
259
+ 'informationDetail.executeDate': 'Execute Date:',
260
+ 'common.selectSkill': 'Select Skill'
258
261
  };
259
262
  export default enUS;
@@ -49,6 +49,7 @@ declare const zhCN: {
49
49
  'trace.video.unsupportedTips': string;
50
50
  'trace.information.unsupportedTips': string;
51
51
  'trace.notPermission': string;
52
+ 'trace.noAccessibleCourse': string;
52
53
  'trace.tryWatchVideo': string;
53
54
  'trace.tryWatchDocument': string;
54
55
  'trace.tryWatchInformation': string;
@@ -98,6 +99,7 @@ declare const zhCN: {
98
99
  'common.dataLoading': string;
99
100
  'common.pleaseWait': string;
100
101
  'common.empty': string;
102
+ 'common.noSkill': string;
101
103
  'common.delete': string;
102
104
  'common.cancel': string;
103
105
  'common.retry': string;
@@ -257,5 +259,6 @@ declare const zhCN: {
257
259
  'informationDetail.applicableCountry': string;
258
260
  'informationDetail.signDate': string;
259
261
  'informationDetail.executeDate': string;
262
+ 'common.selectSkill': string;
260
263
  };
261
264
  export default zhCN;
@@ -49,6 +49,7 @@ var zhCN = {
49
49
  'trace.video.unsupportedTips': '该视频暂不支持试看,\n如需查看完整视频,请点击“去查看”按钮。',
50
50
  'trace.information.unsupportedTips': '以下内容暂不可试看',
51
51
  'trace.notPermission': '暂无权益',
52
+ 'trace.noAccessibleCourse': '暂无可访问的课程内容',
52
53
  'trace.tryWatchVideo': '视频',
53
54
  'trace.tryWatchDocument': '文档',
54
55
  'trace.tryWatchInformation': '资讯',
@@ -98,6 +99,7 @@ var zhCN = {
98
99
  'common.dataLoading': '数据加载中~',
99
100
  'common.pleaseWait': '请稍等...',
100
101
  'common.empty': '暂无内容',
102
+ 'common.noSkill': '暂无技能',
101
103
  'common.delete': '删除',
102
104
  'common.cancel': '取消',
103
105
  'common.retry': '重试',
@@ -256,6 +258,7 @@ var zhCN = {
256
258
  'informationDetail.taxPreferenceLabel': '是否税费优惠及类型:',
257
259
  'informationDetail.applicableCountry': '适用国别:',
258
260
  'informationDetail.signDate': '签署日期:',
259
- 'informationDetail.executeDate': '执行日期:'
261
+ 'informationDetail.executeDate': '执行日期:',
262
+ 'common.selectSkill': '选择技能'
260
263
  };
261
264
  export default zhCN;