@myun/gimi-chat 0.2.1 → 0.2.3

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.
@@ -21,7 +21,7 @@ import useApi from "../apis/useApi";
21
21
  import React, { useRef } from 'react';
22
22
  import { Toast } from "@douyinfe/semi-ui";
23
23
  import { useAppDispatch, useAppSelector } from "../store/hooks";
24
- import { setMessageList, setFileList, setConversationId, setAgentDetail, setAutoLoadConversation } from "../store/slices/gimiMenuSlice";
24
+ import { setMessageList, setFileList, setConversationId, setAgentDetail, setAutoLoadConversation, updateState } from "../store/slices/gimiMenuSlice";
25
25
  import { fileValidation, processString } from "../utils/tools";
26
26
  import { filterPropmptFromUserInput } from "../utils/tools";
27
27
  import { useChatMessage } from "./useChatMessage";
@@ -32,7 +32,7 @@ import { useChatRecommend } from "./useChatRecommend";
32
32
  import { set, cloneDeep } from 'lodash';
33
33
  import { FileStatus } from "../interfaces/fileInterface";
34
34
  import useChatHistory from "./useChatHistory";
35
- var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTSByText, isPlaying, agentId, reloadAgentKey, resetKey, interruptKey, onConversationCreated, onSendEnd) {
35
+ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTSByText, isPlaying, agentId, reloadAgentKey, resetKey, interruptKey, chatInputConfig) {
36
36
  var _useApi = useApi(),
37
37
  getMessageTitle = _useApi.getMessageTitle,
38
38
  stopStreamOut = _useApi.stopStreamOut,
@@ -41,6 +41,11 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
41
41
  deleteConversationById = _useApi.deleteConversationById,
42
42
  getAiCorrection = _useApi.getAiCorrection,
43
43
  checkRetry = _useApi.checkRetry;
44
+ var _ref = chatInputConfig || {},
45
+ onFirstSendSuccess = _ref.onFirstSendSuccess,
46
+ onSendSuccess = _ref.onSendSuccess,
47
+ onSendEnd = _ref.onSendEnd,
48
+ onConversationCreated = _ref.onConversationCreated;
44
49
  var dispatch = useAppDispatch();
45
50
  var _React$useState = React.useState(''),
46
51
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -157,29 +162,28 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
157
162
  });
158
163
 
159
164
  // 重置与当前回话关联的Redux状态
160
- // const clearQuotesFromRedux = () => {
161
- // dispatch(updateState({
162
- // fileList: [],
163
- // showKonwledgeTrace: false,
164
- // showSidebarFileList: false,
165
- // filePreviewState: {
166
- // show: false,
167
- // url: '',
168
- // filename: '',
169
- // },
170
- // // quoteProductList: [],
171
- // // quoteTeachModelList: [],
172
- // konwledgeTraceState: {
173
- // type: 'video',
174
- // resources: [],
175
- // messageId: null,
176
- // },
177
- // }))
178
- // };
179
-
165
+ var clearQuotesFromRedux = React.useCallback(function () {
166
+ dispatch(updateState({
167
+ fileList: [],
168
+ showKonwledgeTrace: false,
169
+ showSidebarFileList: false,
170
+ filePreviewState: {
171
+ show: false,
172
+ url: '',
173
+ filename: ''
174
+ },
175
+ // quoteProductList: [],
176
+ // quoteTeachModelList: [],
177
+ konwledgeTraceState: {
178
+ type: 'video',
179
+ resources: [],
180
+ messageId: null
181
+ }
182
+ }));
183
+ }, [dispatch]);
180
184
  var startAICorrection = React.useCallback( /*#__PURE__*/function () {
181
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(answerId, questionId) {
182
- var res, _res$result, _res$result2, _message, aiChat;
185
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(answerId, questionId) {
186
+ var res, _res$result, _res$result2, message, aiChat;
183
187
  return _regeneratorRuntime().wrap(function _callee$(_context) {
184
188
  while (1) switch (_context.prev = _context.next) {
185
189
  case 0:
@@ -191,10 +195,10 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
191
195
  case 2:
192
196
  res = _context.sent;
193
197
  if (res.status === 0) {
194
- _message = createUserChat((_res$result = res.result) === null || _res$result === void 0 ? void 0 : _res$result.title, '');
198
+ message = createUserChat((_res$result = res.result) === null || _res$result === void 0 ? void 0 : _res$result.title, '');
195
199
  aiChat = createAiChat({});
196
200
  dispatch(setMessageList({
197
- messageList: [_message, aiChat]
201
+ messageList: [message, aiChat]
198
202
  }));
199
203
  dispatch(setAgentDetail({
200
204
  agentDetail: {
@@ -213,7 +217,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
213
217
  }, _callee);
214
218
  }));
215
219
  return function (_x, _x2) {
216
- return _ref.apply(this, arguments);
220
+ return _ref2.apply(this, arguments);
217
221
  };
218
222
  }(), [getAiCorrection]);
219
223
  var deleteConversation = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
@@ -251,7 +255,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
251
255
 
252
256
  // 打断ai输出
253
257
  var handleInterrupt = /*#__PURE__*/function () {
254
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
258
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
255
259
  var uid, messageList, _item, newMessageList, _newMessageList;
256
260
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
257
261
  while (1) switch (_context3.prev = _context3.next) {
@@ -334,7 +338,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
334
338
  }, _callee3);
335
339
  }));
336
340
  return function handleInterrupt() {
337
- return _ref3.apply(this, arguments);
341
+ return _ref4.apply(this, arguments);
338
342
  };
339
343
  }();
340
344
  var handleMCPToolsStreamRs = React.useCallback(function (dataObj) {
@@ -356,7 +360,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
356
360
 
357
361
  // 发起会话 - 使用新的hook简化逻辑
358
362
  var fetchAICorrectionChatStream = React.useCallback( /*#__PURE__*/function () {
359
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_onSseOpen, _onDataReceived, _onComplete, _onErrorComplete) {
363
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_onSseOpen, _onDataReceived, _onComplete, _onErrorComplete) {
360
364
  var fullResponse, reasoningResponse;
361
365
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
362
366
  while (1) switch (_context4.prev = _context4.next) {
@@ -405,13 +409,13 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
405
409
  }, _callee4);
406
410
  }));
407
411
  return function (_x3, _x4, _x5, _x6) {
408
- return _ref4.apply(this, arguments);
412
+ return _ref5.apply(this, arguments);
409
413
  };
410
414
  }(), [fetchChatStreamHook, setIgnoreOnMessage, dispatch, removeLastEventId, handleMCPToolsStreamRs]);
411
415
 
412
416
  // 发起会话 - 使用新的hook简化逻辑
413
417
  var fetchChatStream = React.useCallback( /*#__PURE__*/function () {
414
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id, reSumeInfo, _onSseOpen2, _onDataReceived2, _onComplete2, _onErrorComplete2) {
418
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id, reSumeInfo, _onSseOpen2, _onDataReceived2, _onComplete2, _onErrorComplete2) {
415
419
  var fullResponse, reasoningResponse;
416
420
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
417
421
  while (1) switch (_context5.prev = _context5.next) {
@@ -461,7 +465,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
461
465
  }, _callee5);
462
466
  }));
463
467
  return function (_x7, _x8, _x9, _x10, _x11, _x12) {
464
- return _ref5.apply(this, arguments);
468
+ return _ref6.apply(this, arguments);
465
469
  };
466
470
  }(), [fetchChatStreamHook, setIgnoreOnMessage, dispatch, removeLastEventId, handleMCPToolsStreamRs]);
467
471
 
@@ -492,7 +496,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
492
496
  messageList: newMessageList
493
497
  }));
494
498
  }, /*#__PURE__*/function () {
495
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(Response, type, reasoningResponse) {
499
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(Response, type, reasoningResponse) {
496
500
  var currentMessageList, newMessageList;
497
501
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
498
502
  while (1) switch (_context6.prev = _context6.next) {
@@ -518,7 +522,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
518
522
  }, _callee6);
519
523
  }));
520
524
  return function (_x13, _x14, _x15) {
521
- return _ref7.apply(this, arguments);
525
+ return _ref8.apply(this, arguments);
522
526
  };
523
527
  }(), function () {
524
528
  setIgnoreOnMessage(true);
@@ -550,7 +554,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
550
554
 
551
555
  // 流式输出开始
552
556
  var streamChat = React.useCallback( /*#__PURE__*/function () {
553
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(lastId, again) {
557
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(lastId, again) {
554
558
  var reSumeInfo,
555
559
  agentInfo,
556
560
  _args9 = arguments;
@@ -592,7 +596,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
592
596
  messageList: newMessageList
593
597
  }));
594
598
  }, /*#__PURE__*/function () {
595
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(Response, type, reasoningResponse) {
599
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(Response, type, reasoningResponse) {
596
600
  var currentMessageList, newMessageList, agentDetail;
597
601
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
598
602
  while (1) switch (_context8.prev = _context8.next) {
@@ -634,7 +638,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
634
638
  }, _callee8);
635
639
  }));
636
640
  return function (_x18, _x19, _x20) {
637
- return _ref9.apply(this, arguments);
641
+ return _ref10.apply(this, arguments);
638
642
  };
639
643
  }(), function () {
640
644
  setIgnoreOnMessage(true);
@@ -665,7 +669,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
665
669
  }, _callee9);
666
670
  }));
667
671
  return function (_x16, _x17) {
668
- return _ref8.apply(this, arguments);
672
+ return _ref9.apply(this, arguments);
669
673
  };
670
674
  }(), [fetchChatStream, dispatch, setIgnoreOnMessage, scrollBottomForce, getRecommendList]);
671
675
  var regenerate = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
@@ -714,7 +718,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
714
718
 
715
719
  // 单独的断点续传
716
720
  var checkUnfinishedMessage = React.useCallback( /*#__PURE__*/function () {
717
- var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(chatList) {
721
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(chatList) {
718
722
  var lastMessage, newMessageList, _agentObjRef$current, lastUserRequestMessage;
719
723
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
720
724
  while (1) switch (_context11.prev = _context11.next) {
@@ -756,7 +760,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
756
760
  }, _callee11);
757
761
  }));
758
762
  return function (_x21) {
759
- return _ref11.apply(this, arguments);
763
+ return _ref12.apply(this, arguments);
760
764
  };
761
765
  }(), [dispatch, streamChat, removeLastEventId, rewriteRecommendListFormHistory]);
762
766
  var _useChatHistory = useChatHistory(checkUnfinishedMessage, scrollBottomForce, containerRef),
@@ -775,7 +779,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
775
779
 
776
780
  // 获取对话标题
777
781
  var getHeaderValue = /*#__PURE__*/function () {
778
- var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(conversationId) {
782
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(conversationId) {
779
783
  var res, _res$result3;
780
784
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
781
785
  while (1) switch (_context12.prev = _context12.next) {
@@ -807,12 +811,19 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
807
811
  }, _callee12, null, [[2, 9]]);
808
812
  }));
809
813
  return function getHeaderValue(_x22) {
810
- return _ref12.apply(this, arguments);
814
+ return _ref13.apply(this, arguments);
811
815
  };
812
816
  }();
813
817
  React.useEffect(function () {
814
818
  if (conversationId && conversationIdRef.current !== conversationId) {
815
819
  conversationIdRef.current = conversationId;
820
+ if (controllerRef.current) {
821
+ controllerRef.current.abort();
822
+ }
823
+ if (streamEsAbortRef.current) {
824
+ streamEsAbortRef.current.abort();
825
+ }
826
+ clearQuotesFromRedux();
816
827
  if (autoLoadConversation) {
817
828
  getHeaderValue(conversationId);
818
829
  getContentMessageList();
@@ -822,8 +833,8 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
822
833
 
823
834
  // 开始会话
824
835
  var startChat = React.useCallback( /*#__PURE__*/function () {
825
- var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(messageList) {
826
- var _reverse$find, _bussinessParamsRef$c;
836
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(messageList) {
837
+ var _reverse$find;
827
838
  var isSystemAuto,
828
839
  conversationId,
829
840
  isAskFileSend,
@@ -859,7 +870,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
859
870
  controllerRef.current = new AbortController();
860
871
  signal = controllerRef.current.signal;
861
872
  step.current = 1;
862
- currentBussinessParams = _objectSpread({}, ((_bussinessParamsRef$c = bussinessParamsRef.current) === null || _bussinessParamsRef$c === void 0 ? void 0 : _bussinessParamsRef$c.bussinessParams) || {});
873
+ currentBussinessParams = _objectSpread({}, bussinessParamsRef.current || {});
863
874
  _context13.prev = 10;
864
875
  params = _objectSpread({
865
876
  content: val,
@@ -903,13 +914,17 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
903
914
  case 20:
904
915
  _response = _context13.sent;
905
916
  if (!_response.ok) {
906
- _context13.next = 27;
917
+ _context13.next = 29;
907
918
  break;
908
919
  }
909
920
  _context13.next = 24;
910
921
  return _response.json();
911
922
  case 24:
912
923
  responseMsg = _context13.sent;
924
+ // 执行使用方定义的回调函数
925
+ onFirstSendSuccess === null || onFirstSendSuccess === void 0 || onFirstSendSuccess();
926
+ onSendSuccess === null || onSendSuccess === void 0 || onSendSuccess();
927
+
913
928
  // 清空发送时的引用
914
929
  dispatch(setFileList({
915
930
  fileList: []
@@ -933,11 +948,11 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
933
948
  setStatus(0);
934
949
  }
935
950
  }
936
- case 27:
937
- _context13.next = 32;
938
- break;
939
951
  case 29:
940
- _context13.prev = 29;
952
+ _context13.next = 34;
953
+ break;
954
+ case 31:
955
+ _context13.prev = 31;
941
956
  _context13.t0 = _context13["catch"](10);
942
957
  if (_context13.t0.name === 'AbortError') {
943
958
  setMsgLoading(false);
@@ -955,18 +970,18 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
955
970
  setStatus(0);
956
971
  }
957
972
  }
958
- case 32:
973
+ case 34:
959
974
  case "end":
960
975
  return _context13.stop();
961
976
  }
962
- }, _callee13, null, [[10, 29]]);
977
+ }, _callee13, null, [[10, 31]]);
963
978
  }));
964
979
  return function (_x23) {
965
- return _ref13.apply(this, arguments);
980
+ return _ref14.apply(this, arguments);
966
981
  };
967
982
  }(), [dispatch]);
968
983
  var fetchAgentDetail = React.useCallback( /*#__PURE__*/function () {
969
- var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(agentId) {
984
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(agentId) {
970
985
  var res;
971
986
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
972
987
  while (1) switch (_context14.prev = _context14.next) {
@@ -1002,23 +1017,24 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
1002
1017
  }, _callee14, null, [[0, 13]]);
1003
1018
  }));
1004
1019
  return function (_x24) {
1005
- return _ref14.apply(this, arguments);
1020
+ return _ref15.apply(this, arguments);
1006
1021
  };
1007
1022
  }(), []);
1008
1023
  var startConversationAndChat = React.useCallback( /*#__PURE__*/function () {
1009
- var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(value) {
1010
- var _agentObjRef$current3, _bussinessParamsRef$c2;
1024
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(value) {
1025
+ var _agentObjRef$current3;
1011
1026
  var currentBussinessParams, params, res;
1012
1027
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1013
1028
  while (1) switch (_context15.prev = _context15.next) {
1014
1029
  case 0:
1015
1030
  if ((_agentObjRef$current3 = agentObjRef.current) !== null && _agentObjRef$current3 !== void 0 && _agentObjRef$current3.agentId) {
1016
- _context15.next = 2;
1031
+ _context15.next = 3;
1017
1032
  break;
1018
1033
  }
1019
- return _context15.abrupt("return", Toast.error('请先关联智能体'));
1020
- case 2:
1021
- currentBussinessParams = _objectSpread({}, ((_bussinessParamsRef$c2 = bussinessParamsRef.current) === null || _bussinessParamsRef$c2 === void 0 ? void 0 : _bussinessParamsRef$c2.bussinessParams) || {});
1034
+ Toast.error('请先关联智能体');
1035
+ return _context15.abrupt("return");
1036
+ case 3:
1037
+ currentBussinessParams = _objectSpread({}, bussinessParamsRef.current || {});
1022
1038
  params = _objectSpread({
1023
1039
  content: value,
1024
1040
  conversationType: agentObjRef.current.conversationType,
@@ -1028,11 +1044,11 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
1028
1044
  dispatch(setAutoLoadConversation({
1029
1045
  autoLoadConversation: false
1030
1046
  }));
1031
- _context15.prev = 5;
1047
+ _context15.prev = 6;
1032
1048
  setMsgLoading(true);
1033
- _context15.next = 9;
1049
+ _context15.next = 10;
1034
1050
  return createRoomId(params);
1035
- case 9:
1051
+ case 10:
1036
1052
  res = _context15.sent;
1037
1053
  if (res.status === 0) {
1038
1054
  dispatch(setConversationId({
@@ -1050,22 +1066,22 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
1050
1066
  } else {
1051
1067
  Toast.error(res.message);
1052
1068
  }
1053
- _context15.next = 18;
1069
+ _context15.next = 19;
1054
1070
  break;
1055
- case 13:
1056
- _context15.prev = 13;
1057
- _context15.t0 = _context15["catch"](5);
1071
+ case 14:
1072
+ _context15.prev = 14;
1073
+ _context15.t0 = _context15["catch"](6);
1058
1074
  Toast.error('创建会话失败');
1059
1075
  console.log('error', _context15.t0);
1060
1076
  setMsgLoading(false);
1061
- case 18:
1077
+ case 19:
1062
1078
  case "end":
1063
1079
  return _context15.stop();
1064
1080
  }
1065
- }, _callee15, null, [[5, 13]]);
1081
+ }, _callee15, null, [[6, 14]]);
1066
1082
  }));
1067
1083
  return function (_x25) {
1068
- return _ref15.apply(this, arguments);
1084
+ return _ref16.apply(this, arguments);
1069
1085
  };
1070
1086
  }(), []);
1071
1087
  React.useEffect(function () {
@@ -1089,7 +1105,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
1089
1105
  }
1090
1106
  }, [resetKey]);
1091
1107
  var handleSend = React.useCallback( /*#__PURE__*/function () {
1092
- var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(val) {
1108
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(val) {
1093
1109
  var agent,
1094
1110
  isSystemAuto,
1095
1111
  conversationId,
@@ -1175,7 +1191,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
1175
1191
  }, _callee16);
1176
1192
  }));
1177
1193
  return function (_x26) {
1178
- return _ref16.apply(this, arguments);
1194
+ return _ref17.apply(this, arguments);
1179
1195
  };
1180
1196
  }(), [dispatch, startChat]);
1181
1197
  var handleSendFile = React.useCallback(function (messageList) {
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import { GimiChatComponent } from './components';
2
+ export { default as GimiChatSdk } from './client';
2
3
  export default GimiChatComponent;
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  import { GimiChatComponent } from "./components";
2
+ export { default as GimiChatSdk } from "./client";
2
3
  export default GimiChatComponent;
@@ -48,7 +48,6 @@ export interface GimiMenuState {
48
48
  displayImage: number;
49
49
  imageUrl: string;
50
50
  showMicWarning: boolean;
51
- initMsg?: string;
52
51
  }
53
52
  export declare const getChatHistoryList: import("@reduxjs/toolkit").AsyncThunk<{
54
53
  data: any;
@@ -92,9 +91,7 @@ export declare const setAgentDetail: import("@reduxjs/toolkit").ActionCreatorWit
92
91
  quoteTeachModelList: GimiMenuState['quoteTeachModelList'];
93
92
  }, "gimiMenu/setQuoteTeachModelList">, setShowMicWarning: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
94
93
  showMicWarning: boolean;
95
- }, "gimiMenu/setShowMicWarning">, setBussinessParams: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<Record<string, any>>, "gimiMenu/setBussinessParams">, setInitMsg: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
96
- initMsg: string;
97
- }, "gimiMenu/setInitMsg">, setAutoLoadConversation: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
94
+ }, "gimiMenu/setShowMicWarning">, setBussinessParams: import("@reduxjs/toolkit").ActionCreatorWithPayload<Record<string, any>, "gimiMenu/setBussinessParams">, setAutoLoadConversation: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
98
95
  autoLoadConversation: boolean;
99
96
  }, "gimiMenu/setAutoLoadConversation">;
100
97
  declare const reducer: Reducer<GimiMenuState>;
@@ -5,12 +5,12 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
5
5
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
6
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
7
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
8
9
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
10
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
11
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
12
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
13
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
14
14
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
15
15
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
16
16
  import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
@@ -56,27 +56,26 @@ var initialState = {
56
56
  quoteTeachModelList: [],
57
57
  displayImage: 1,
58
58
  imageUrl: '',
59
- showMicWarning: false,
60
- initMsg: ''
59
+ showMicWarning: false
61
60
  };
62
61
  export var getChatHistoryList = createAsyncThunk('gimiMenu/getChatHistoryList', /*#__PURE__*/function () {
63
62
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(payload, _ref) {
64
- var rejectWithValue, getState, pageIndex, pageSize, params, state, api, res;
63
+ var rejectWithValue, getState, pageIndex, pageSize, state, bussinessParams, params, api, res;
65
64
  return _regeneratorRuntime().wrap(function _callee$(_context) {
66
65
  while (1) switch (_context.prev = _context.next) {
67
66
  case 0:
68
67
  rejectWithValue = _ref.rejectWithValue, getState = _ref.getState;
69
68
  pageIndex = payload.pageIndex, pageSize = payload.pageSize;
70
- console.log('getChatHistoryList', payload);
69
+ state = getState();
70
+ bussinessParams = state.gimiMenu.bussinessParams;
71
71
  params = {
72
72
  pageIndex: pageIndex,
73
73
  pageSize: pageSize,
74
- where: {
74
+ where: _objectSpread({
75
75
  conversationTypes: [2, 3]
76
- }
76
+ }, bussinessParams)
77
77
  };
78
- _context.prev = 4;
79
- state = getState();
78
+ _context.prev = 5;
80
79
  api = createFetch({
81
80
  baseURL: state.gimiMenu.baseUrl,
82
81
  timeout: 10000,
@@ -103,13 +102,13 @@ export var getChatHistoryList = createAsyncThunk('gimiMenu/getChatHistoryList',
103
102
  return _context.abrupt("return", rejectWithValue('获取历史记录失败'));
104
103
  case 15:
105
104
  _context.prev = 15;
106
- _context.t0 = _context["catch"](4);
105
+ _context.t0 = _context["catch"](5);
107
106
  return _context.abrupt("return", rejectWithValue(_context.t0));
108
107
  case 18:
109
108
  case "end":
110
109
  return _context.stop();
111
110
  }
112
- }, _callee, null, [[4, 15]]);
111
+ }, _callee, null, [[5, 15]]);
113
112
  }));
114
113
  return function (_x, _x2) {
115
114
  return _ref2.apply(this, arguments);
@@ -205,9 +204,6 @@ var gimiMenuSlice = createSlice({
205
204
  setShowMicWarning: function setShowMicWarning(state, action) {
206
205
  state.showMicWarning = action.payload.showMicWarning;
207
206
  },
208
- setInitMsg: function setInitMsg(state, action) {
209
- state.initMsg = action.payload.initMsg;
210
- },
211
207
  setAutoLoadConversation: function setAutoLoadConversation(state, action) {
212
208
  state.autoLoadConversation = action.payload.autoLoadConversation;
213
209
  }
@@ -260,8 +256,7 @@ var _gimiMenuSlice$action = gimiMenuSlice.actions,
260
256
  setQuoteTeachModelList = _gimiMenuSlice$action.setQuoteTeachModelList,
261
257
  setShowMicWarning = _gimiMenuSlice$action.setShowMicWarning,
262
258
  setBussinessParams = _gimiMenuSlice$action.setBussinessParams,
263
- setInitMsg = _gimiMenuSlice$action.setInitMsg,
264
259
  setAutoLoadConversation = _gimiMenuSlice$action.setAutoLoadConversation;
265
- export { setAgentDetail, setConversationId, setIsMsgRecieving, setBaseUrl, setToken, setPlatform, updateState, setMessageList, setFileList, setCurrentMessageId, updateParams, setShowKonwledgeTrace, setShowSidebarFileList, setSidebarFileList, setKonwledgeTraceState, setFilePreviewState, setQuoteProductList, setQuoteTeachModelList, setShowMicWarning, setBussinessParams, setInitMsg, setAutoLoadConversation };
260
+ export { setAgentDetail, setConversationId, setIsMsgRecieving, setBaseUrl, setToken, setPlatform, updateState, setMessageList, setFileList, setCurrentMessageId, updateParams, setShowKonwledgeTrace, setShowSidebarFileList, setSidebarFileList, setKonwledgeTraceState, setFilePreviewState, setQuoteProductList, setQuoteTeachModelList, setShowMicWarning, setBussinessParams, setAutoLoadConversation };
266
261
  var reducer = gimiMenuSlice.reducer;
267
262
  export default reducer;
@@ -20,6 +20,8 @@ export interface IAIInputProps {
20
20
  defaultPrompt?: string;
21
21
  disabled?: boolean;
22
22
  onBeforeSend?: (text: string) => void;
23
+ onFirstSendSuccess?: () => void;
24
+ onSendSuccess?: () => void;
23
25
  onSend?: (text: string) => void;
24
26
  onConversationCreated?: (conversationId: number) => void;
25
27
  onSendEnd?: (message: IChatMessageItem) => void;