@myun/gimi-chat 0.3.5 → 0.3.7

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.
@@ -58,5 +58,6 @@ declare const useApi: (baseUrl?: string, authToken?: string) => {
58
58
  checkRetry: (params: {
59
59
  conversationId: number;
60
60
  }) => Promise<FetchResponse<any>>;
61
+ interrupt: (conversationId: number) => any;
61
62
  };
62
63
  export default useApi;
@@ -368,6 +368,13 @@ var useApi = function useApi(baseUrl, authToken) {
368
368
  };
369
369
  }();
370
370
 
371
+ /** 手动打断当前语音对话 */
372
+ var interrupt = function interrupt(conversationId) {
373
+ return apiRef.current.post('/api/voice/interrupt', {
374
+ conversationId: conversationId
375
+ });
376
+ };
377
+
371
378
  // 搜索 - 视频引用列表
372
379
  var getReferenceVideoList = /*#__PURE__*/function () {
373
380
  var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
@@ -441,7 +448,8 @@ var useApi = function useApi(baseUrl, authToken) {
441
448
  getAiCorrection: getAiCorrection,
442
449
  getReferenceVideoList: getReferenceVideoList,
443
450
  getReferenceCourseList: getReferenceCourseList,
444
- checkRetry: checkRetry
451
+ checkRetry: checkRetry,
452
+ interrupt: interrupt
445
453
  };
446
454
  };
447
455
  export default useApi;
@@ -99,7 +99,8 @@ var AiExplain = function AiExplain(_ref) {
99
99
  _startVoiceChat = _useApi.startVoiceChat,
100
100
  _stopVoiceChat = _useApi.stopVoiceChat,
101
101
  getUserFirstUse = _useApi.getUserFirstUse,
102
- getRtcConfig = _useApi.getRtcConfig;
102
+ getRtcConfig = _useApi.getRtcConfig,
103
+ interrupt = _useApi.interrupt;
103
104
  var dispatch = useDispatch();
104
105
  var UNSUPPORTED_CALL_MSG_KEY = 'ai-chat-unsupported-call';
105
106
  var unsupportedShownRef = useRef(false);
@@ -693,6 +694,8 @@ var AiExplain = function AiExplain(_ref) {
693
694
  var handleInterrupt = function handleInterrupt() {
694
695
  try {
695
696
  var _clientRef$current6;
697
+ setIsTextLoading(false);
698
+ interrupt(paper.conversationId);
696
699
  (_clientRef$current6 = clientRef.current) === null || _clientRef$current6 === void 0 || _clientRef$current6.interrupt();
697
700
  } catch (_unused4) {}
698
701
  };
@@ -31,6 +31,7 @@ interface IAIInputProps {
31
31
  titleSlot?: string;
32
32
  showDefaultPrompt?: boolean;
33
33
  onConversationCreated?: (conversationId: number) => void;
34
+ onMicHangUp?: () => void;
34
35
  }
35
36
  declare const ChatInput: React.ForwardRefExoticComponent<IAIInputProps & React.RefAttributes<ChatInputRef>>;
36
37
  export default ChatInput;
@@ -30,7 +30,6 @@ import { FileStatus } from "../../interfaces/fileInterface";
30
30
  import LottieImg from "../lottie-img";
31
31
  import AIChatDialogue from "../ai-chat-dialogue";
32
32
  import { Keydown, TitleSlot } from "./extension";
33
- import { aesEncrypt } from "../../utils/aes";
34
33
  import QuotedContent from "../quoted-content";
35
34
  import { ReferencesEdit } from "../reference-content";
36
35
  var extractText = function extractText() {
@@ -187,7 +186,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
187
186
  src: 'https://simg01.gaodunwangxiao.com/uploadimgs/tmp/upload/202509/24/6726e_20250924141448.png',
188
187
  alt: ""
189
188
  }))));
190
- }, [props.enableFileUpload, messageList, agentObj === null || agentObj === void 0 ? void 0 : agentObj.openUploadFile]);
189
+ }, [props.enableFileUpload, props.accept, props.disabled, messageList, agentObj === null || agentObj === void 0 ? void 0 : agentObj.openUploadFile, fileList]);
191
190
  var openChatCommunication = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
192
191
  var params, res, _props$onConversation;
193
192
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -264,7 +263,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
264
263
  return _context.stop();
265
264
  }
266
265
  }, _callee, null, [[2, 7], [13, 20]]);
267
- })), [dispatch, isMsgRecieving]);
266
+ })), [dispatch, isMsgRecieving, props]);
268
267
  var stopRecording = React.useCallback( /*#__PURE__*/function () {
269
268
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(enableInput) {
270
269
  var _props$shortAsrClick;
@@ -282,7 +281,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
282
281
  return function (_x) {
283
282
  return _ref2.apply(this, arguments);
284
283
  };
285
- }(), [props.shortAsrClick]);
284
+ }(), [props]);
286
285
  var VoiceTools = React.useMemo(function () {
287
286
  if (!props.enableVoiceChat && !props.enableVoiceRecord) {
288
287
  return null;
@@ -318,7 +317,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
318
317
  var inputContents = content.inputContents || [];
319
318
  var text = extractText(inputContents);
320
319
  (_props$onSend = props.onSend) === null || _props$onSend === void 0 || _props$onSend.call(props, text);
321
- }, []);
320
+ }, [props]);
322
321
  var renderConfigureArea = React.useCallback(function () {
323
322
  return /*#__PURE__*/React.createElement(Tooltip, {
324
323
  trigger: 'click',
@@ -338,13 +337,13 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
338
337
  (_uploadFileRef$curren = uploadFileRef.current) === null || _uploadFileRef$curren === void 0 || _uploadFileRef$curren.abortUpload();
339
338
  }
340
339
  };
341
- var handleDelFile = function handleDelFile() {
340
+ var handleDelFile = React.useCallback(function () {
342
341
  stopSSe();
343
342
  dispatch(setFileList({
344
343
  fileList: []
345
344
  }));
346
- };
347
- var handleReTry = function handleReTry(file) {
345
+ }, [dispatch]);
346
+ var handleReTry = React.useCallback(function (file) {
348
347
  var currentFileList = fileList || [];
349
348
  var _file = currentFileList.find(function (item) {
350
349
  return item.uid === file.uid;
@@ -356,7 +355,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
356
355
  var _uploadFileRef$curren3;
357
356
  (_uploadFileRef$curren3 = uploadFileRef.current) === null || _uploadFileRef$curren3 === void 0 || _uploadFileRef$curren3.retryUpload(_file === null || _file === void 0 ? void 0 : _file.uid);
358
357
  }
359
- };
358
+ }, [fileList]);
360
359
  var renderReference = React.useCallback(function () {
361
360
  return /*#__PURE__*/React.createElement("div", {
362
361
  className: styles.reference,
@@ -384,13 +383,11 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
384
383
  flex: 1
385
384
  }
386
385
  }, "\u6B63\u5728\u83B7\u53D6\u8BED\u97F3\u5185\u5BB9...")));
387
- }, [fileList, props.isRecording, props.isVoiceGetting, messageList, quoteProductList, quoteTeachModelList]);
386
+ }, [fileList, props.isRecording, props.isVoiceGetting, messageList, quoteProductList, quoteTeachModelList, handleDelFile, handleReTry]);
388
387
  var handleHangUp = function handleHangUp() {
389
388
  var _props$onHistoryReloa;
390
- var pathname = window.location.pathname;
391
- if (pathname === '/gimi' || pathname.startsWith('/gimi/flow')) {
392
- var aesId = aesEncrypt("".concat(conversationId));
393
- window.location.href = "/gimi/chat/".concat(aesId);
389
+ if (props.onMicHangUp) {
390
+ props.onMicHangUp();
394
391
  return;
395
392
  }
396
393
  // 重置自动加载会话设置
@@ -32,8 +32,8 @@ var tabList = [{
32
32
  }
33
33
  // { key: 'course', displayName: '课程' },
34
34
  ];
35
- var quotoIcon = 'https://simg01.gaodunwangxiao.com/uploadfiles/tmp/upload/202511/18/aedd7_20251118092438.png';
36
- var isActiveQuotoIcon = 'https://simg01.gaodunwangxiao.com/uploadfiles/tmp/upload/202512/01/aa4b5_20251201110652.png';
35
+ var quotoIcon = 'https://simg01.gaodunwangxiao.com/uploadimgs/tmp/upload/202601/30/be6d9_20260130135139.png';
36
+ var isActiveQuotoIcon = 'https://simg01.gaodunwangxiao.com/uploadimgs/tmp/upload/202601/30/8e64c_20260130135037.png';
37
37
  var QuotedContent = function QuotedContent() {
38
38
  var _useState = useState('video'),
39
39
  _useState2 = _slicedToArray(_useState, 2),
@@ -2,7 +2,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
2
2
  import React from 'react';
3
3
  import { store } from "../../store";
4
4
  import { useAppDispatch, useAppSelector } from "../../store/hooks";
5
- import { setBaseUrl, setToken, setPlatform, setConversationId, setAgentDetail, setBussinessParams } from "../../store/slices/gimiMenuSlice";
5
+ import { setBaseUrl, setToken, setPlatform, setConversationId, setAgentDetail, setBussinessParams, setQuoteTeachModelList } from "../../store/slices/gimiMenuSlice";
6
6
  import useCommonChatAPI from "../../hooks/useCommonChatAPI";
7
7
  import { replaceBraces } from "../../utils/tools";
8
8
  import styles from "./index.module.css";
@@ -114,22 +114,30 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
114
114
  dispatch(setPlatform({
115
115
  platform: platform
116
116
  }));
117
- }, [baseUrl, token, platform]);
117
+ }, [baseUrl, token, platform, dispatch]);
118
118
  React.useEffect(function () {
119
119
  if (conversationId) {
120
120
  dispatch(setConversationId({
121
121
  conversationId: conversationId
122
122
  }));
123
123
  }
124
- }, [conversationId]);
124
+ }, [conversationId, dispatch]);
125
125
  React.useEffect(function () {
126
126
  dispatch(setAgentDetail({
127
127
  agentDetail: agentDetail || {}
128
128
  }));
129
- }, [agentDetail]);
129
+ }, [agentDetail, dispatch]);
130
130
  React.useEffect(function () {
131
131
  dispatch(setBussinessParams(bussinessParams || {}));
132
- }, [bussinessParams]);
132
+ }, [bussinessParams, dispatch]);
133
+ React.useEffect(function () {
134
+ var _props$initQuoteSourc;
135
+ if ((_props$initQuoteSourc = props.initQuoteSource) !== null && _props$initQuoteSourc !== void 0 && _props$initQuoteSourc.teachModelId) {
136
+ dispatch(setQuoteTeachModelList({
137
+ quoteTeachModelList: [props.initQuoteSource]
138
+ }));
139
+ }
140
+ }, [props.initQuoteSource, dispatch]);
133
141
  var disableVoiceCommunication = React.useMemo(function () {
134
142
  var lastedMessage = messageList[messageList.length - 1];
135
143
  var content = (lastedMessage === null || lastedMessage === void 0 ? void 0 : lastedMessage.content) || '';
@@ -158,7 +158,8 @@ export var useChatStream = function useChatStream(platform) {
158
158
  return;
159
159
  }
160
160
  } else if (_dataObj.ERROR || _dataObj.moduleType === 'FAILED') {
161
- Toast.error('服务异常');
161
+ var errorMessage = '内容过大,请精简后开启新对话';
162
+ Toast.error(_dataObj.ERROR === errorMessage ? errorMessage : '服务异常');
162
163
  onErrorComplete === null || onErrorComplete === void 0 || onErrorComplete();
163
164
  return;
164
165
  } else if (data.status && data.status !== 0 && !_dataObj.ERROR) {
@@ -796,39 +796,38 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
796
796
  isSystemAuto = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : false;
797
797
  conversationId = _args9.length > 3 ? _args9[3] : undefined;
798
798
  value = val.trim();
799
- console.log('initAttachments', initAttachments);
800
799
  if (!(!value && !isSystemAuto)) {
801
- _context9.next = 7;
800
+ _context9.next = 6;
802
801
  break;
803
802
  }
804
803
  return _context9.abrupt("return");
805
- case 7:
804
+ case 6:
806
805
  if (navigator.onLine) {
807
- _context9.next = 10;
806
+ _context9.next = 9;
808
807
  break;
809
808
  }
810
809
  Toast.error('无法连接到网络');
811
810
  return _context9.abrupt("return");
812
- case 10:
813
- if (!(status === 2 || isMsgRecievingRef.current)) {
814
- _context9.next = 13;
811
+ case 9:
812
+ if (!(status === 2 || msgLoading)) {
813
+ _context9.next = 12;
815
814
  break;
816
815
  }
817
816
  Toast.error('AI正在输出中,请稍后');
818
817
  return _context9.abrupt("return");
819
- case 13:
818
+ case 12:
820
819
  chatInputConfig === null || chatInputConfig === void 0 || (_chatInputConfig$onBe = chatInputConfig.onBeforeSend) === null || _chatInputConfig$onBe === void 0 || _chatInputConfig$onBe.call(chatInputConfig, value);
821
820
 
822
821
  // 设置inputModel
823
822
  fillInputModel(value, messageListRef.current);
824
823
  fileValidationMsg = fileValidation(fileListRef.current);
825
824
  if (!fileValidationMsg) {
826
- _context9.next = 19;
825
+ _context9.next = 18;
827
826
  break;
828
827
  }
829
828
  Toast.error(fileValidationMsg);
830
829
  return _context9.abrupt("return");
831
- case 19:
830
+ case 18:
832
831
  if (isPlaying) {
833
832
  // 点击发送按钮时,先停止播放
834
833
  stopTTSByText === null || stopTTSByText === void 0 || stopTTSByText();
@@ -860,7 +859,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
860
859
  // 系统自动上传,直接开始会话,不更新列表
861
860
  startChat([].concat(_toConsumableArray(prevChatList), [userChat]), isSystemAuto, conversationId);
862
861
  }
863
- case 26:
862
+ case 25:
864
863
  case "end":
865
864
  return _context9.stop();
866
865
  }
@@ -39,6 +39,7 @@ export interface IAIInputProps {
39
39
  onSend?: (text: string) => void;
40
40
  onConversationCreated?: (conversationId: number) => void;
41
41
  onSendEnd?: (message: IChatMessageItem) => void;
42
+ onMicHangUp?: () => void;
42
43
  enableVoiceRecord?: boolean;
43
44
  enableVoiceChat?: boolean;
44
45
  enableFileUpload?: boolean;
@@ -114,6 +115,12 @@ export interface CommonChatProps {
114
115
  showHeader?: boolean;
115
116
  initSendValue?: string;
116
117
  initAttachments?: FileItem[];
118
+ initQuoteSource?: {
119
+ teachModelId: number;
120
+ teachModelName: string;
121
+ type?: string;
122
+ duration: number;
123
+ };
117
124
  chatInputConfig?: IAIInputProps;
118
125
  platform?: 'myun' | 'preview' | 'damai';
119
126
  businessType: 'correction' | 'chat';