@myun/gimi-chat 0.9.63 → 0.9.65

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 +0 -6
  2. package/dist/apis/useApi.js +1 -45
  3. package/dist/components/ai-chat-dialogue/index copy.js +1 -1
  4. package/dist/components/ai-chat-dialogue/index.js +2 -4
  5. package/dist/components/answer-item/index.d.ts +1 -2
  6. package/dist/components/answer-item/index.js +8 -179
  7. package/dist/components/answer-item/index.module.css +0 -35
  8. package/dist/components/ask-card/index.d.ts +1 -1
  9. package/dist/components/chat-input/extension/index.d.ts +0 -1
  10. package/dist/components/chat-input/extension/index.js +1 -2
  11. package/dist/components/chat-input/index.js +24 -145
  12. package/dist/components/file-card/index.js +1 -2
  13. package/dist/components/file-card/index.module.css +0 -1
  14. package/dist/components/knowledge-trace/tryWatch.js +1 -1
  15. package/dist/components/message-list/index.js +3 -15
  16. package/dist/components/message-list/index.module.css +0 -3
  17. package/dist/components/templates/CommonChat.js +1 -3
  18. package/dist/hooks/useChatActions.d.ts +1 -2
  19. package/dist/hooks/useChatActions.js +12 -52
  20. package/dist/hooks/useChatStream.d.ts +1 -6
  21. package/dist/hooks/useChatStream.js +5 -97
  22. package/dist/hooks/useCommonChatAPI.d.ts +1 -1
  23. package/dist/hooks/useCommonChatAPI.js +58 -212
  24. package/dist/i18n/locales/en-US.d.ts +0 -6
  25. package/dist/i18n/locales/en-US.js +1 -7
  26. package/dist/i18n/locales/zh-CN.d.ts +0 -6
  27. package/dist/i18n/locales/zh-CN.js +1 -7
  28. package/dist/interfaces/chatMessage.d.ts +0 -40
  29. package/dist/umd/index.min.js +1 -1
  30. package/dist/utils/tools.d.ts +0 -7
  31. package/dist/utils/tools.js +1 -38
  32. package/package.json +2 -4
  33. package/dist/components/answer-item/component/artifacts/index.d.ts +0 -13
  34. package/dist/components/answer-item/component/artifacts/index.js +0 -52
  35. package/dist/components/answer-item/component/artifacts/index.module.css +0 -24
  36. package/dist/components/answer-item/component/tool-list/index.d.ts +0 -7
  37. package/dist/components/answer-item/component/tool-list/index.js +0 -117
  38. package/dist/components/answer-item/component/tool-list/index.module.css +0 -97
  39. package/dist/components/chat-input/extension/skill/MentionList.d.ts +0 -31
  40. package/dist/components/chat-input/extension/skill/MentionList.js +0 -199
  41. package/dist/components/chat-input/extension/skill/ReferSlot.d.ts +0 -3
  42. package/dist/components/chat-input/extension/skill/ReferSlot.js +0 -100
  43. package/dist/components/chat-input/extension/skill/data.d.ts +0 -10
  44. package/dist/components/chat-input/extension/skill/data.js +0 -49
  45. package/dist/components/chat-input/extension/skill/index.d.ts +0 -7
  46. package/dist/components/chat-input/extension/skill/index.js +0 -5
  47. package/dist/components/chat-input/extension/skill/index.less +0 -117
  48. package/dist/components/chat-input/extension/skill/suggestion.d.ts +0 -16
  49. package/dist/components/chat-input/extension/skill/suggestion.js +0 -206
  50. package/dist/components/message-list/skill-tag/index.d.ts +0 -5
  51. package/dist/components/message-list/skill-tag/index.js +0 -23
  52. package/dist/components/message-list/skill-tag/index.module.css +0 -21
@@ -24,14 +24,12 @@ 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";
28
27
  import { fileValidation, getTimeZone, parseMessageContent, processString } from "../utils/tools";
29
28
  import { filterPropmptFromUserInput } from "../utils/tools";
30
29
  import { useChatMessage } from "./useChatMessage";
31
30
  import { useChatStream } from "./useChatStream";
32
31
  import { useLastEventId } from "./useLastEventId";
33
32
  import useScroll from "./useScroll";
34
- // 获取推荐课程
35
33
  import { useChatRecommend } from "./useChatRecommend";
36
34
  import { set, cloneDeep } from 'lodash';
37
35
  import { FileStatus } from "../interfaces/fileInterface";
@@ -246,7 +244,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
246
244
 
247
245
  // 打断ai输出
248
246
  var handleInterrupt = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
249
- var uid, _parseMessageContent, content, _item, newMessageList, lastToolList, _newMessageList;
247
+ var uid, _parseMessageContent, content, _item, newMessageList, _newMessageList;
250
248
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
251
249
  while (1) switch (_context2.prev = _context2.next) {
252
250
  case 0:
@@ -296,7 +294,6 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
296
294
  }));
297
295
  }
298
296
  } else {
299
- lastToolList = _toConsumableArray(messageList[messageList.length - 1].toolList || []);
300
297
  _newMessageList = [].concat(_toConsumableArray(messageList.slice(0, -1)), [_objectSpread(_objectSpread({}, messageList[messageList.length - 1]), {}, {
301
298
  loading: false,
302
299
  reasoningLoading: false,
@@ -304,16 +301,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
304
301
  reasoningStatus: content ? 2 : 3,
305
302
  msgLoading: false,
306
303
  relatedResourceList: [],
307
- mcp: null,
308
- thinkingInfo: {
309
- status: "COMPLETED",
310
- toolName: t('chatApi.completed'),
311
- collapse: true,
312
- loaded: false
313
- },
314
- toolList: _toConsumableArray(lastToolList.filter(function (v) {
315
- return v.moduleType !== "agent" && v.moduleType !== 'end';
316
- }))
304
+ mcp: null
317
305
  })]);
318
306
  dispatch(setMessageList({
319
307
  messageList: _newMessageList
@@ -354,68 +342,8 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
354
342
  messageList: newMessageList
355
343
  }));
356
344
  }, [dispatch]);
357
- var handleToolStreamRs = React.useCallback(function (dataObj) {
358
- // 只处理工作流模式下的 tool_result,其他情况暂不处理
359
- if (dataObj.moduleType === 'tool_result' && dataObj.name !== 'executeWorkflow') return;
360
- setStatus(2);
361
- var messageList = messageListRef.current;
362
- var lastMessage = messageList[messageList.length - 1];
363
- var curToolList = _toConsumableArray((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.toolList) || []);
364
- var curToolIndex = curToolList.findIndex(function (item) {
365
- return (item === null || item === void 0 ? void 0 : item.id) === dataObj.id;
366
- });
367
-
368
- // 为新节点类型根据 status 生成 toolName
369
- var isNewNodeType = !['tool_invocation', 'tool_result', "agent"].includes(dataObj.moduleType);
370
- var toolName = isNewNodeType ? getToolNameByStatus(dataObj.moduleType, dataObj.status) : dataObj.toolName;
371
- if (curToolIndex >= 0) {
372
- curToolList[curToolIndex] = _objectSpread(_objectSpread({}, curToolList[curToolIndex]), {}, {
373
- content: dataObj.moduleType === 'thinking' ? dataObj.reasoningContent : dataObj.content || '',
374
- // tool_invocation 更新 toolName 和 status,新节点类型也更新
375
- toolName: dataObj.moduleType === 'tool_invocation' ? dataObj.toolName || '' : isNewNodeType ? toolName : curToolList[curToolIndex].toolName,
376
- status: dataObj.moduleType === 'tool_invocation' || isNewNodeType ? dataObj.status : curToolList[curToolIndex].status
377
- });
378
- } else {
379
- // 新增工具时,为新节点类型补充 toolName
380
- // agent 类类型,保持只有一个 agent
381
- // tool_result只是工具的结果,不能新增
382
- if (dataObj.moduleType === 'agent' && curToolList.length > 0 || dataObj.moduleType === 'tool_result') return;
383
- curToolList = curToolList.filter(function (tool) {
384
- return tool.moduleType !== 'agent';
385
- });
386
- curToolList = [].concat(_toConsumableArray(curToolList), [_objectSpread(_objectSpread({}, dataObj), {}, {
387
- toolName: toolName || dataObj.toolName
388
- })]);
389
- }
390
- var newMessageList = [].concat(_toConsumableArray(messageList.slice(0, -1)), [_objectSpread(_objectSpread({}, lastMessage), {}, {
391
- moduleType: dataObj.moduleType,
392
- toolList: _toConsumableArray(curToolList)
393
- })]);
394
- dispatch(setMessageList({
395
- messageList: newMessageList
396
- }));
397
- }, [dispatch]);
398
- var handleArtifactStreamRs = React.useCallback(function (dataObj) {
399
- setStatus(2);
400
- var messageList = messageListRef.current;
401
- var lastMessage = messageList[messageList.length - 1];
402
- var newMessageList = [].concat(_toConsumableArray(messageList.slice(0, -1)), [_objectSpread(_objectSpread({}, lastMessage), {}, {
403
- moduleType: dataObj.moduleType,
404
- artifacts: dataObj.artifacts || []
405
- })]);
406
- messageListRef.current = newMessageList;
407
- dispatch(setMessageList({
408
- messageList: newMessageList
409
- }));
410
- }, [dispatch]);
411
345
 
412
346
  // 发起会话 - 使用新的hook简化逻辑
413
- // @param id 会话ID
414
- // @param reSumeInfo 恢复信息
415
- // @param onSseOpen 开启SSE回调
416
- // @param onDataReceived 数据接收回调
417
- // @param onComplete 完成回调
418
- // @param onErrorComplete 错误完成回调
419
347
  var fetchChatStream = React.useCallback( /*#__PURE__*/function () {
420
348
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(id, reSumeInfo, _onSseOpen, _onDataReceived, _onComplete, _onErrorComplete) {
421
349
  var fullResponse, reasoningResponse;
@@ -440,10 +368,10 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
440
368
  }
441
369
  _onDataReceived(response, type);
442
370
  },
443
- onComplete: function onComplete(response, type, reasoning, dataObj) {
371
+ onComplete: function onComplete(response, type) {
444
372
  if (type === 'end' || type === 'COMPLETED') {
445
373
  removeLastEventId(id);
446
- _onComplete(fullResponse, type, reasoningResponse, dataObj);
374
+ _onComplete(fullResponse, type, reasoningResponse);
447
375
  } else {
448
376
  moduleInfoRef.current = response;
449
377
  _onComplete(response, type);
@@ -454,12 +382,6 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
454
382
  },
455
383
  onMCPToolsStream: function onMCPToolsStream(dataObj) {
456
384
  handleMCPToolsStreamRs(dataObj);
457
- },
458
- onToolStream: function onToolStream(dataObj) {
459
- handleToolStreamRs(dataObj);
460
- },
461
- onArtifactStream: function onArtifactStream(dataObj) {
462
- handleArtifactStreamRs(dataObj);
463
385
  }
464
386
  });
465
387
  case 5:
@@ -471,7 +393,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
471
393
  return function (_x, _x2, _x3, _x4, _x5, _x6) {
472
394
  return _ref5.apply(this, arguments);
473
395
  };
474
- }(), [fetchChatStreamHook, setIgnoreOnMessage, removeLastEventId, handleMCPToolsStreamRs, handleToolStreamRs, handleArtifactStreamRs]);
396
+ }(), [fetchChatStreamHook, setIgnoreOnMessage, removeLastEventId, handleMCPToolsStreamRs]);
475
397
  var getRelatedCourses = React.useCallback( /*#__PURE__*/function () {
476
398
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(input) {
477
399
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
@@ -539,69 +461,22 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
539
461
  setMsgLoading(false);
540
462
  setStatus(2);
541
463
  var currentMessageList = messageListRef.current;
542
- var lastToolList = _toConsumableArray(currentMessageList[currentMessageList.length - 1].toolList || []);
543
- if (lastToolList.findIndex(function (v) {
544
- return v.moduleType === 'end';
545
- }) < 0) {
546
- lastToolList.push({
547
- moduleType: 'end',
548
- content: '',
549
- status: "RUNNING",
550
- toolName: t('chatApi.organizingAnswer'),
551
- id: "".concat(new Date().getTime())
552
- });
553
- }
554
- 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))]);
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))]);
555
465
  dispatch(setMessageList({
556
466
  messageList: newMessageList
557
467
  }));
558
468
  }, /*#__PURE__*/function () {
559
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(Response, type, reasoningResponse, dataObj) {
560
- var currentMessageList, lastToolList, newMessageList, agentDetail, userInput;
469
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(Response, type, reasoningResponse) {
470
+ var currentMessageList, newMessageList, agentDetail, userInput;
561
471
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
562
472
  while (1) switch (_context5.prev = _context5.next) {
563
473
  case 0:
564
474
  // if (isSystemAuto) return;
565
475
  setIgnoreOnMessage(true);
566
476
  currentMessageList = messageListRef.current;
567
- lastToolList = _toConsumableArray(currentMessageList[currentMessageList.length - 1].toolList || []);
568
- newMessageList = [];
569
- if (type === 'user_confirm') {
570
- newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, {
571
- moduleType: type,
572
- moduleInfo: Response,
573
- reasoningResponse: '',
574
- loading: false,
575
- reasoningLoading: false,
576
- mcp: null,
577
- thinkingInfo: {
578
- status: "RUNNING",
579
- toolName: t('chatApi.completed'),
580
- collapse: false,
581
- loaded: true
582
- },
583
- toolList: [].concat(_toConsumableArray(lastToolList), [{
584
- moduleType: type,
585
- content: '',
586
- data: Response,
587
- status: "RUNNING",
588
- toolName: t('chatApi.waitingForConfirmation'),
589
- confirmStatus: "PENDING",
590
- id: "".concat(new Date().getTime())
591
- }])
592
- })]);
593
- } else {
594
- newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
595
- moduleType: type
596
- }, 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", {
597
- status: type === 'end' ? "COMPLETED" : "RUNNING",
598
- toolName: t('chatApi.completed'),
599
- collapse: true,
600
- loaded: true
601
- }), "toolList", _toConsumableArray(lastToolList.filter(function (v) {
602
- return v.moduleType !== "agent" && v.moduleType !== 'end';
603
- }))))]);
604
- }
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))]);
605
480
  dispatch(setMessageList({
606
481
  messageList: newMessageList
607
482
  }));
@@ -612,13 +487,13 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
612
487
  // 获取最新的agent详情,防止redux异步更新
613
488
  agentDetail = agentInfo || agentObjRef.current; // 获取推荐追问
614
489
  if (!((agentDetail === null || agentDetail === void 0 ? void 0 : agentDetail.isEnableRelated) === 1 && (type === 'end' || type === 'COMPLETED'))) {
615
- _context5.next = 12;
490
+ _context5.next = 10;
616
491
  break;
617
492
  }
618
493
  setMsgLoading(true);
619
- _context5.next = 12;
494
+ _context5.next = 10;
620
495
  return getRecommendList(newMessageList, lastId, statusRef.current);
621
- case 12:
496
+ case 10:
622
497
  // 获取相关课程
623
498
  userInput = newMessageList[newMessageList.length - 2].content;
624
499
  getRelatedCourses(userInput || '');
@@ -629,35 +504,25 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
629
504
  }
630
505
  setMsgLoading(false);
631
506
  onSendEnd === null || onSendEnd === void 0 || onSendEnd(newMessageList[newMessageList.length - 1]);
632
- case 17:
507
+ case 15:
633
508
  case "end":
634
509
  return _context5.stop();
635
510
  }
636
511
  }, _callee5);
637
512
  }));
638
- return function (_x10, _x11, _x12, _x13) {
513
+ return function (_x10, _x11, _x12) {
639
514
  return _ref8.apply(this, arguments);
640
515
  };
641
516
  }(), function () {
642
517
  setIgnoreOnMessage(true);
643
518
  var currentMessageList = messageListRef.current;
644
- var lastToolList = [].concat(_toConsumableArray(currentMessageList[currentMessageList.length - 1].toolList || []), [{
645
- moduleType: 'FAILED',
646
- content: '',
647
- status: "COMPLETED",
648
- toolName: '服务异常',
649
- id: "".concat(new Date().getTime())
650
- }]);
651
519
  var newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, {
652
520
  loading: false,
653
521
  reasoningLoading: false,
654
522
  stop: 0,
655
523
  reasoningStatus: 3,
656
524
  msgLoading: false,
657
- mcp: null,
658
- toolList: _toConsumableArray(lastToolList.filter(function (v) {
659
- return v.moduleType !== "agent" && v.moduleType !== 'end';
660
- }))
525
+ mcp: null
661
526
  })]);
662
527
  dispatch(setMessageList({
663
528
  messageList: newMessageList
@@ -736,7 +601,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
736
601
  lastUserMessage = chatList.filter(function (item) {
737
602
  return item.role === 0;
738
603
  }).pop(); // 检查最后一条消息是否为未完成的AI消息
739
- if ((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) === 1 && lastMessage.isCompleteOut === 0 && lastMessage.chatId && lastMessage.moduleType !== 'user_confirm') {
604
+ if ((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) === 1 && lastMessage.isCompleteOut === 0 && lastMessage.chatId) {
740
605
  if (lastMessage.vipLevel === 1) {
741
606
  vipLevelRef.current = 1;
742
607
  }
@@ -753,7 +618,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
753
618
  reasoningContent: processString(lastMessage.reasoningContent || '')
754
619
  }, agentObjRef.current); // 调用续传接口
755
620
  }
756
- if (!((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) === 1 && lastMessage.isCompleteOut === 1 && lastMessage.moduleType !== 'user_confirm')) {
621
+ if (!((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) === 1 && lastMessage.isCompleteOut === 1)) {
757
622
  _context8.next = 10;
758
623
  break;
759
624
  }
@@ -778,7 +643,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
778
643
  }
779
644
  }, _callee8);
780
645
  }));
781
- return function (_x14) {
646
+ return function (_x13) {
782
647
  return _ref10.apply(this, arguments);
783
648
  };
784
649
  }(), [dispatch, streamChat, removeLastEventId, rewriteRecommendListFormHistory, getRelatedCourses]);
@@ -804,7 +669,6 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
804
669
  var isSystemAuto,
805
670
  conversationId,
806
671
  isAskFileSend,
807
- skipCreateNewMessage,
808
672
  val,
809
673
  signal,
810
674
  currentBusinessParams,
@@ -824,7 +688,6 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
824
688
  isSystemAuto = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : false;
825
689
  conversationId = _args9.length > 2 ? _args9[2] : undefined;
826
690
  isAskFileSend = _args9.length > 3 ? _args9[3] : undefined;
827
- skipCreateNewMessage = _args9.length > 4 ? _args9[4] : undefined;
828
691
  // 如果是ask卡片的file上传,发送content为''
829
692
  val = isAskFileSend ? '' : (_reverse$find = _toConsumableArray(messageList).reverse().find(function (item) {
830
693
  return item.role === 0;
@@ -839,7 +702,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
839
702
  signal = controllerRef.current.signal;
840
703
  step.current = 1;
841
704
  currentBusinessParams = _objectSpread({}, businessParamsRef.current || {});
842
- _context9.prev = 11;
705
+ _context9.prev = 10;
843
706
  params = _objectSpread({
844
707
  content: val,
845
708
  conversationId: conversationId || conversationIdRef.current,
@@ -873,7 +736,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
873
736
  if (isSystemAuto) {
874
737
  params.isSystemAuto = 1;
875
738
  }
876
- _context9.next = 21;
739
+ _context9.next = 20;
877
740
  return fetch("https://".concat(baseUrlRef.current, "/mbot/web/agent-message"), {
878
741
  method: 'POST',
879
742
  headers: {
@@ -885,15 +748,15 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
885
748
  signal: signal,
886
749
  body: JSON.stringify(params)
887
750
  });
888
- case 21:
751
+ case 20:
889
752
  _response = _context9.sent;
890
753
  if (!_response.ok) {
891
- _context9.next = 31;
754
+ _context9.next = 29;
892
755
  break;
893
756
  }
894
- _context9.next = 25;
757
+ _context9.next = 24;
895
758
  return _response.json();
896
- case 25:
759
+ case 24:
897
760
  responseMsg = _context9.sent;
898
761
  // 执行使用方定义的回调函数
899
762
  if (!onFirstSendSuccessCalledRef.current) {
@@ -906,16 +769,14 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
906
769
  dispatch(setFileList({
907
770
  fileList: []
908
771
  }));
909
- inputModelRef.current = null; // 清空 inputModel,避免下次发送时残留
910
-
911
772
  if (responseMsg.status === 0) {
912
- result = responseMsg.result; // 如果 skipCreateNewMessage 为 true,不创建新消息,直接用当前最后一条
913
- if (!skipCreateNewMessage) {
914
- aiChat = createAiChat(result);
915
- dispatch(setMessageList({
916
- messageList: [].concat(_toConsumableArray(messageList), [aiChat])
917
- }));
918
- }
773
+ result = responseMsg.result;
774
+ aiChat = createAiChat(result); // 根据isSystemAuto决定是否添加AI消息到列表
775
+ // if (!isSystemAuto) {
776
+ dispatch(setMessageList({
777
+ messageList: [].concat(_toConsumableArray(messageList), [aiChat])
778
+ }));
779
+ // }
919
780
  // 继续流式处理聊天
920
781
  streamChat(result.id, false);
921
782
  } else {
@@ -927,12 +788,12 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
927
788
  setStatus(0);
928
789
  }
929
790
  }
930
- case 31:
931
- _context9.next = 36;
791
+ case 29:
792
+ _context9.next = 34;
932
793
  break;
933
- case 33:
934
- _context9.prev = 33;
935
- _context9.t0 = _context9["catch"](11);
794
+ case 31:
795
+ _context9.prev = 31;
796
+ _context9.t0 = _context9["catch"](10);
936
797
  if (_context9.t0.name === 'AbortError') {
937
798
  setMsgLoading(false);
938
799
  if (inputValue) {
@@ -949,21 +810,17 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
949
810
  setStatus(0);
950
811
  }
951
812
  }
952
- case 36:
813
+ case 34:
953
814
  case "end":
954
815
  return _context9.stop();
955
816
  }
956
- }, _callee9, null, [[11, 33]]);
817
+ }, _callee9, null, [[10, 31]]);
957
818
  }));
958
- return function (_x15) {
819
+ return function (_x14) {
959
820
  return _ref11.apply(this, arguments);
960
821
  };
961
822
  }(), [dispatch, inputValue, streamEsAbortRef]);
962
823
  var fillInputModel = React.useCallback(function (value, messageList) {
963
- // 如果 inputModelRef 已经被设置(confirm/ask点击等),不要覆盖
964
- if (inputModelRef.current) {
965
- return;
966
- }
967
824
  if ((messageList === null || messageList === void 0 ? void 0 : messageList.length) > 0 && value && messageList[messageList.length - 1].moduleType === 'ask') {
968
825
  var targetChatItem = _toConsumableArray(messageList).reverse().find(function (item) {
969
826
  return item.role === 1;
@@ -974,15 +831,12 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
974
831
  inputModelRef.current = _inputModel;
975
832
  }
976
833
  }, []);
977
-
978
- // 点击发送按钮
979
834
  var handleSend = React.useCallback( /*#__PURE__*/function () {
980
835
  var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(val) {
981
836
  var _chatInputConfig$onBe;
982
837
  var agent,
983
838
  isSystemAuto,
984
839
  conversationId,
985
- skipCreateNewMessage,
986
840
  value,
987
841
  fileValidationMsg,
988
842
  cleanVal,
@@ -998,40 +852,39 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
998
852
  agent = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : agentObj;
999
853
  isSystemAuto = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : false;
1000
854
  conversationId = _args10.length > 3 ? _args10[3] : undefined;
1001
- skipCreateNewMessage = _args10.length > 4 ? _args10[4] : undefined;
1002
855
  value = val.trim();
1003
856
  if (!(!value && !isSystemAuto)) {
1004
- _context10.next = 7;
857
+ _context10.next = 6;
1005
858
  break;
1006
859
  }
1007
860
  return _context10.abrupt("return");
1008
- case 7:
861
+ case 6:
1009
862
  if (navigator.onLine) {
1010
- _context10.next = 10;
863
+ _context10.next = 9;
1011
864
  break;
1012
865
  }
1013
866
  Toast.error(t('common.networkUnavailable'));
1014
867
  return _context10.abrupt("return");
1015
- case 10:
868
+ case 9:
1016
869
  if (!(status === 2 || msgLoading)) {
1017
- _context10.next = 13;
870
+ _context10.next = 12;
1018
871
  break;
1019
872
  }
1020
873
  Toast.error(t('chatApi.aiResponding'));
1021
874
  return _context10.abrupt("return");
1022
- case 13:
875
+ case 12:
1023
876
  chatInputConfig === null || chatInputConfig === void 0 || (_chatInputConfig$onBe = chatInputConfig.onBeforeSend) === null || _chatInputConfig$onBe === void 0 || _chatInputConfig$onBe.call(chatInputConfig, value);
1024
877
 
1025
878
  // 设置inputModel
1026
879
  fillInputModel(value, messageListRef.current);
1027
880
  fileValidationMsg = fileValidation(fileListRef.current);
1028
881
  if (!fileValidationMsg) {
1029
- _context10.next = 19;
882
+ _context10.next = 18;
1030
883
  break;
1031
884
  }
1032
885
  Toast.error(fileValidationMsg);
1033
886
  return _context10.abrupt("return");
1034
- case 19:
887
+ case 18:
1035
888
  if (isPlaying) {
1036
889
  // 点击发送按钮时,先停止播放
1037
890
  stopTTSByText === null || stopTTSByText === void 0 || stopTTSByText();
@@ -1056,19 +909,19 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
1056
909
  dispatch(setMessageList({
1057
910
  messageList: newChatList
1058
911
  }));
1059
- startChat(newChatList, isSystemAuto, conversationId, undefined, skipCreateNewMessage);
912
+ startChat(newChatList, isSystemAuto, conversationId);
1060
913
  } else {
1061
914
  setMsgLoading(true);
1062
915
  // 系统自动上传,直接开始会话,不更新列表
1063
- startChat(_toConsumableArray(prevChatList), isSystemAuto, conversationId, undefined, skipCreateNewMessage);
916
+ startChat(_toConsumableArray(prevChatList), isSystemAuto, conversationId);
1064
917
  }
1065
- case 25:
918
+ case 24:
1066
919
  case "end":
1067
920
  return _context10.stop();
1068
921
  }
1069
922
  }, _callee10);
1070
923
  }));
1071
- return function (_x16) {
924
+ return function (_x15) {
1072
925
  return _ref12.apply(this, arguments);
1073
926
  };
1074
927
  }(), [dispatch, startChat, chatInputConfig, createUserChat, fillInputModel, isPlaying, status, stopTTSByText, msgLoading, agentObj]);
@@ -1106,7 +959,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
1106
959
  }
1107
960
  }, _callee11, null, [[2, 9]]);
1108
961
  }));
1109
- return function (_x17) {
962
+ return function (_x16) {
1110
963
  return _ref13.apply(this, arguments);
1111
964
  };
1112
965
  }(), [t]);
@@ -1189,7 +1042,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
1189
1042
  }
1190
1043
  }, _callee12, null, [[0, 14]]);
1191
1044
  }));
1192
- return function (_x18) {
1045
+ return function (_x17) {
1193
1046
  return _ref14.apply(this, arguments);
1194
1047
  };
1195
1048
  }(), []);
@@ -1253,7 +1106,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
1253
1106
  }
1254
1107
  }, _callee13, null, [[6, 14]]);
1255
1108
  }));
1256
- return function (_x19) {
1109
+ return function (_x18) {
1257
1110
  return _ref15.apply(this, arguments);
1258
1111
  };
1259
1112
  }(), [handleSend, platform, dispatch, createRoomId, onConversationCreated, getHeaderValue, t]);
@@ -1365,17 +1218,10 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
1365
1218
  }, [dispatch, handleSend]);
1366
1219
  React.useEffect(function () {
1367
1220
  if ((messageList === null || messageList === void 0 ? void 0 : messageList.length) > 0) {
1368
- var _chatItem$toolList, _chatItem$moduleInfo, _chatItem$moduleInfo2;
1221
+ var _chatItem$moduleInfo, _chatItem$moduleInfo2;
1369
1222
  // 设置输入框是否可点击
1370
1223
  var chatItem = messageList[messageList.length - 1];
1371
-
1372
- // 检查是否有等待用户确认的 user_confirm
1373
- var hasWaitingConfirm = (_chatItem$toolList = chatItem.toolList) === null || _chatItem$toolList === void 0 ? void 0 : _chatItem$toolList.some(function (tool) {
1374
- return tool.moduleType === 'user_confirm' && tool.status === 'RUNNING';
1375
- });
1376
- if (hasWaitingConfirm) {
1377
- setDisableSend(true);
1378
- } 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) {
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) {
1379
1225
  setDisableSend(true);
1380
1226
  } 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) {
1381
1227
  setDisableSend(true);
@@ -97,8 +97,6 @@ declare const enUS: {
97
97
  'common.dataLoading': string;
98
98
  'common.pleaseWait': string;
99
99
  'common.empty': string;
100
- 'common.noSkill': string;
101
- 'common.skillExceedLimit': string;
102
100
  'common.delete': string;
103
101
  'common.cancel': string;
104
102
  'common.retry': string;
@@ -167,9 +165,6 @@ declare const enUS: {
167
165
  'chatApi.deleteSuccess': string;
168
166
  'chatApi.deleteFailed': string;
169
167
  'chatApi.noRequestToCancel': string;
170
- 'chatApi.completed': string;
171
- 'chatApi.organizingAnswer': string;
172
- 'chatApi.waitingForConfirmation': string;
173
168
  'messageAction.copy': string;
174
169
  'messageAction.likeDone': string;
175
170
  'messageAction.like': string;
@@ -261,6 +256,5 @@ declare const enUS: {
261
256
  'informationDetail.applicableCountry': string;
262
257
  'informationDetail.signDate': string;
263
258
  'informationDetail.executeDate': string;
264
- 'common.selectSkill': string;
265
259
  };
266
260
  export default enUS;
@@ -97,8 +97,6 @@ var enUS = {
97
97
  'common.dataLoading': 'Data loading...',
98
98
  'common.pleaseWait': 'Please wait...',
99
99
  'common.empty': 'No content',
100
- 'common.noSkill': 'No Skill',
101
- 'common.skillExceedLimit': 'Adding this skill will exceed the 10000-character limit. Please shorten your input first.',
102
100
  'common.delete': 'Delete',
103
101
  'common.cancel': 'Cancel',
104
102
  'common.retry': 'Retry',
@@ -167,9 +165,6 @@ var enUS = {
167
165
  'chatApi.deleteSuccess': 'Conversation deleted successfully',
168
166
  'chatApi.deleteFailed': 'Failed to delete conversation',
169
167
  'chatApi.noRequestToCancel': 'No request to cancel',
170
- 'chatApi.completed': 'Completed',
171
- 'chatApi.organizingAnswer': 'Organizing answer',
172
- 'chatApi.waitingForConfirmation': 'Waiting for confirmation',
173
168
  'messageAction.copy': 'Copy',
174
169
  'messageAction.likeDone': 'Liked',
175
170
  'messageAction.like': 'Like',
@@ -260,7 +255,6 @@ var enUS = {
260
255
  'informationDetail.taxPreferenceLabel': 'Tax Preference:',
261
256
  'informationDetail.applicableCountry': 'Applicable Country:',
262
257
  'informationDetail.signDate': 'Sign Date:',
263
- 'informationDetail.executeDate': 'Execute Date:',
264
- 'common.selectSkill': 'Select Skill'
258
+ 'informationDetail.executeDate': 'Execute Date:'
265
259
  };
266
260
  export default enUS;
@@ -99,8 +99,6 @@ declare const zhCN: {
99
99
  'common.dataLoading': string;
100
100
  'common.pleaseWait': string;
101
101
  'common.empty': string;
102
- 'common.noSkill': string;
103
- 'common.skillExceedLimit': string;
104
102
  'common.delete': string;
105
103
  'common.cancel': string;
106
104
  'common.retry': string;
@@ -169,9 +167,6 @@ declare const zhCN: {
169
167
  'chatApi.deleteSuccess': string;
170
168
  'chatApi.deleteFailed': string;
171
169
  'chatApi.noRequestToCancel': string;
172
- 'chatApi.completed': string;
173
- 'chatApi.organizingAnswer': string;
174
- 'chatApi.waitingForConfirmation': string;
175
170
  'messageAction.copy': string;
176
171
  'messageAction.likeDone': string;
177
172
  'messageAction.like': string;
@@ -263,6 +258,5 @@ declare const zhCN: {
263
258
  'informationDetail.applicableCountry': string;
264
259
  'informationDetail.signDate': string;
265
260
  'informationDetail.executeDate': string;
266
- 'common.selectSkill': string;
267
261
  };
268
262
  export default zhCN;