@myun/gimi-chat 0.2.6 → 0.2.8

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.
@@ -5,6 +5,8 @@
5
5
  align-items: start;
6
6
  padding: 14px 0px 20px 10px;
7
7
  width: 100%;
8
+ max-width: 800px;
9
+ margin: 0 auto;
8
10
  }
9
11
  .container .prologue {
10
12
  font-family: PingFang SC;
@@ -684,18 +684,12 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
684
684
  });
685
685
  case 3:
686
686
  res = _context10.sent;
687
- if (res.result) {
688
- _context10.next = 7;
689
- break;
690
- }
691
- Toast.error('当前消息不可进行重试');
692
- return _context10.abrupt("return");
693
- case 7:
694
687
  if (res.status === 0 && res.result) {
695
688
  retryId = res.result;
696
689
  newMessageList = [].concat(_toConsumableArray(messageListRef.current.slice(0, -1)), [_objectSpread(_objectSpread({}, messageListRef.current[messageListRef.current.length - 1]), {}, {
697
690
  content: '',
698
691
  reasoningContent: '',
692
+ expand: true,
699
693
  relatedResourceList: [],
700
694
  loading: false,
701
695
  reasoningLoading: false,
@@ -710,17 +704,17 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
710
704
  } else {
711
705
  Toast.error(res.message || '当前消息不可进行重试');
712
706
  }
713
- _context10.next = 13;
707
+ _context10.next = 10;
714
708
  break;
715
- case 10:
716
- _context10.prev = 10;
709
+ case 7:
710
+ _context10.prev = 7;
717
711
  _context10.t0 = _context10["catch"](0);
718
712
  Toast.error('重试失败');
719
- case 13:
713
+ case 10:
720
714
  case "end":
721
715
  return _context10.stop();
722
716
  }
723
- }, _callee10, null, [[0, 10]]);
717
+ }, _callee10, null, [[0, 7]]);
724
718
  })), [streamChat]);
725
719
 
726
720
  // 单独的断点续传
@@ -824,19 +818,26 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
824
818
  React.useEffect(function () {
825
819
  if (conversationId && conversationIdRef.current !== conversationId) {
826
820
  conversationIdRef.current = conversationId;
827
- if (controllerRef.current) {
828
- controllerRef.current.abort();
829
- }
830
- if (streamEsAbortRef.current) {
831
- streamEsAbortRef.current.abort();
832
- }
833
- clearQuotesFromRedux();
834
821
  if (autoLoadConversation) {
835
822
  getHeaderValue(conversationId);
836
823
  getContentMessageList();
837
824
  }
838
825
  }
839
826
  }, [conversationId, autoLoadConversation]);
827
+ React.useEffect(function () {
828
+ var idAtEffectTime = conversationId;
829
+ return function () {
830
+ if (idAtEffectTime !== null && idAtEffectTime !== undefined && idAtEffectTime !== -1) {
831
+ if (controllerRef.current) {
832
+ controllerRef.current.abort();
833
+ }
834
+ if (streamEsAbortRef.current) {
835
+ streamEsAbortRef.current.abort();
836
+ }
837
+ }
838
+ clearQuotesFromRedux();
839
+ };
840
+ }, [conversationId]);
840
841
 
841
842
  // 开始会话
842
843
  var startChat = React.useCallback( /*#__PURE__*/function () {
@@ -1111,6 +1112,17 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
1111
1112
  setHeaderValue('');
1112
1113
  }
1113
1114
  }, [resetKey]);
1115
+ var fillInputModel = React.useCallback(function (value, messageList) {
1116
+ if ((messageList === null || messageList === void 0 ? void 0 : messageList.length) > 0 && value && messageList[messageList.length - 1].moduleType === 'ask') {
1117
+ var targetChatItem = _toConsumableArray(messageList).reverse().find(function (item) {
1118
+ return item.role === 1;
1119
+ });
1120
+ if (!targetChatItem || !targetChatItem.moduleInfo) return;
1121
+ var moduleInfo = targetChatItem.moduleInfo;
1122
+ var _inputModel = _defineProperty({}, "".concat(moduleInfo.id, ".input"), value || '');
1123
+ inputModelRef.current = _inputModel;
1124
+ }
1125
+ }, []);
1114
1126
  var handleSend = React.useCallback( /*#__PURE__*/function () {
1115
1127
  var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(val) {
1116
1128
  var agent,
@@ -1152,14 +1164,16 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
1152
1164
  Toast.error('AI正在输出中,请稍后');
1153
1165
  return _context16.abrupt("return");
1154
1166
  case 12:
1167
+ // 设置inputModel
1168
+ fillInputModel(value, messageListRef.current);
1155
1169
  fileValidationMsg = fileValidation(fileListRef.current);
1156
1170
  if (!fileValidationMsg) {
1157
- _context16.next = 16;
1171
+ _context16.next = 17;
1158
1172
  break;
1159
1173
  }
1160
1174
  Toast.error(fileValidationMsg);
1161
1175
  return _context16.abrupt("return");
1162
- case 16:
1176
+ case 17:
1163
1177
  if (isPlaying) {
1164
1178
  // 点击发送按钮时,先停止播放
1165
1179
  stopTTSByText === null || stopTTSByText === void 0 || stopTTSByText();
@@ -1191,7 +1205,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
1191
1205
  // 系统自动上传,直接开始会话,不更新列表
1192
1206
  startChat([].concat(_toConsumableArray(prevChatList), [userChat]), isSystemAuto, conversationId);
1193
1207
  }
1194
- case 23:
1208
+ case 24:
1195
1209
  case "end":
1196
1210
  return _context16.stop();
1197
1211
  }