@myun/gimi-chat 0.3.4 → 0.3.6
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.
- package/dist/apis/useApi.d.ts +1 -0
- package/dist/apis/useApi.js +9 -1
- package/dist/components/ai-chat-dialogue/index.js +4 -1
- package/dist/components/chat-input/index.d.ts +1 -0
- package/dist/components/chat-input/index.js +11 -14
- package/dist/components/templates/CommonChat.js +4 -4
- package/dist/hooks/useCommonChatAPI.d.ts +0 -1
- package/dist/hooks/useCommonChatAPI.js +385 -564
- package/dist/types/chat.d.ts +1 -0
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
package/dist/apis/useApi.d.ts
CHANGED
package/dist/apis/useApi.js
CHANGED
|
@@ -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
|
|
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
|
|
340
|
+
var handleDelFile = React.useCallback(function () {
|
|
342
341
|
stopSSe();
|
|
343
342
|
dispatch(setFileList({
|
|
344
343
|
fileList: []
|
|
345
344
|
}));
|
|
346
|
-
};
|
|
347
|
-
var handleReTry = function
|
|
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
|
-
|
|
391
|
-
|
|
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
|
// 重置自动加载会话设置
|
|
@@ -114,22 +114,22 @@ 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
133
|
var disableVoiceCommunication = React.useMemo(function () {
|
|
134
134
|
var lastedMessage = messageList[messageList.length - 1];
|
|
135
135
|
var content = (lastedMessage === null || lastedMessage === void 0 ? void 0 : lastedMessage.content) || '';
|
|
@@ -37,6 +37,5 @@ declare const useCommonChatAPI: (props: IHookProps) => {
|
|
|
37
37
|
startConversationAndChat: (value: string) => Promise<void>;
|
|
38
38
|
deleteConversation: () => Promise<void>;
|
|
39
39
|
regenerate: () => Promise<void>;
|
|
40
|
-
startAICorrection: (answerId: number, questionId: number) => Promise<void>;
|
|
41
40
|
};
|
|
42
41
|
export default useCommonChatAPI;
|