@myun/gimi-chat 0.2.0 → 0.2.1
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 +3 -0
- package/dist/apis/useApi.js +24 -3
- package/dist/components/chat-input/index.js +9 -1
- package/dist/hooks/useCommonChatAPI.d.ts +1 -1
- package/dist/hooks/useCommonChatAPI.js +166 -118
- package/dist/store/slices/gimiMenuSlice.d.ts +6 -1
- package/dist/store/slices/gimiMenuSlice.js +8 -2
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
package/dist/apis/useApi.d.ts
CHANGED
|
@@ -55,5 +55,8 @@ declare const useApi: (baseUrl?: string, authToken?: string) => {
|
|
|
55
55
|
}) => Promise<FetchResponse<any>>;
|
|
56
56
|
getReferenceVideoList: (params: any) => Promise<FetchResponse<any>>;
|
|
57
57
|
getReferenceCourseList: (params: any) => Promise<FetchResponse<any>>;
|
|
58
|
+
checkRetry: (params: {
|
|
59
|
+
conversationId: number;
|
|
60
|
+
}) => Promise<FetchResponse<any>>;
|
|
58
61
|
};
|
|
59
62
|
export default useApi;
|
package/dist/apis/useApi.js
CHANGED
|
@@ -6,12 +6,14 @@ import { createFetch } from "./fetch";
|
|
|
6
6
|
import { useAppSelector } from "../store/hooks";
|
|
7
7
|
import React from 'react';
|
|
8
8
|
var useApi = function useApi(baseUrl, authToken) {
|
|
9
|
-
var
|
|
9
|
+
var storedToken = useAppSelector(function (state) {
|
|
10
10
|
return state.gimiMenu.token;
|
|
11
11
|
});
|
|
12
|
-
var
|
|
12
|
+
var storedBaseURL = useAppSelector(function (state) {
|
|
13
13
|
return state.gimiMenu.baseUrl;
|
|
14
14
|
});
|
|
15
|
+
var token = authToken || storedToken;
|
|
16
|
+
var baseURL = baseUrl || storedBaseURL;
|
|
15
17
|
var apiRef = React.useRef(createFetch({
|
|
16
18
|
baseURL: baseURL,
|
|
17
19
|
timeout: 10000,
|
|
@@ -401,6 +403,24 @@ var useApi = function useApi(baseUrl, authToken) {
|
|
|
401
403
|
return _ref20.apply(this, arguments);
|
|
402
404
|
};
|
|
403
405
|
}();
|
|
406
|
+
var checkRetry = /*#__PURE__*/function () {
|
|
407
|
+
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
408
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
409
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
410
|
+
case 0:
|
|
411
|
+
return _context20.abrupt("return", apiRef.current.get('/mbot/web/agent-message/retry/judge', {
|
|
412
|
+
params: params
|
|
413
|
+
}));
|
|
414
|
+
case 1:
|
|
415
|
+
case "end":
|
|
416
|
+
return _context20.stop();
|
|
417
|
+
}
|
|
418
|
+
}, _callee20);
|
|
419
|
+
}));
|
|
420
|
+
return function checkRetry(_x19) {
|
|
421
|
+
return _ref21.apply(this, arguments);
|
|
422
|
+
};
|
|
423
|
+
}();
|
|
404
424
|
return {
|
|
405
425
|
getSkillData: getSkillData,
|
|
406
426
|
getProductList: getProductList,
|
|
@@ -420,7 +440,8 @@ var useApi = function useApi(baseUrl, authToken) {
|
|
|
420
440
|
deleteConversationById: deleteConversationById,
|
|
421
441
|
getAiCorrection: getAiCorrection,
|
|
422
442
|
getReferenceVideoList: getReferenceVideoList,
|
|
423
|
-
getReferenceCourseList: getReferenceCourseList
|
|
443
|
+
getReferenceCourseList: getReferenceCourseList,
|
|
444
|
+
checkRetry: checkRetry
|
|
424
445
|
};
|
|
425
446
|
};
|
|
426
447
|
export default useApi;
|
|
@@ -22,7 +22,7 @@ import { Tooltip } from "@douyinfe/semi-ui";
|
|
|
22
22
|
import styles from "./index.module.css";
|
|
23
23
|
import FileUpload from "../file-upload";
|
|
24
24
|
import { useAppSelector, useAppDispatch } from "../../store/hooks";
|
|
25
|
-
import { setConversationId, setFileList } from "../../store/slices/gimiMenuSlice";
|
|
25
|
+
import { setAutoLoadConversation, setConversationId, setFileList } from "../../store/slices/gimiMenuSlice";
|
|
26
26
|
import { Toast } from "@douyinfe/semi-ui";
|
|
27
27
|
import useApi from "../../apis/useApi";
|
|
28
28
|
import UploadList from "../upload-list";
|
|
@@ -235,6 +235,10 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
235
235
|
case 16:
|
|
236
236
|
res = _context.sent;
|
|
237
237
|
if (res && res.status === 0) {
|
|
238
|
+
// 关闭自动加载会话,避免重复加载
|
|
239
|
+
dispatch(setAutoLoadConversation({
|
|
240
|
+
autoLoadConversation: false
|
|
241
|
+
}));
|
|
238
242
|
dispatch(setConversationId({
|
|
239
243
|
conversationId: res.result
|
|
240
244
|
}));
|
|
@@ -390,6 +394,10 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
390
394
|
window.location.href = "/gimi/chat/".concat(aesId);
|
|
391
395
|
return;
|
|
392
396
|
}
|
|
397
|
+
// 重置自动加载会话设置
|
|
398
|
+
dispatch(setAutoLoadConversation({
|
|
399
|
+
autoLoadConversation: true
|
|
400
|
+
}));
|
|
393
401
|
(_props$onHistoryReloa = props.onHistoryReload) === null || _props$onHistoryReloa === void 0 || _props$onHistoryReloa.call(props);
|
|
394
402
|
};
|
|
395
403
|
var defaultContent = transformToInputSlots(props.defaultPrompt || '', props.titleSlot || '');
|
|
@@ -22,7 +22,7 @@ declare const useCommonChatAPI: (containerRef: React.RefObject<HTMLDivElement>,
|
|
|
22
22
|
isMoreLoading: boolean;
|
|
23
23
|
startConversationAndChat: (value: string) => Promise<string | undefined>;
|
|
24
24
|
deleteConversation: () => Promise<void>;
|
|
25
|
-
regenerate: () => void
|
|
25
|
+
regenerate: () => Promise<void>;
|
|
26
26
|
startAICorrection: (answerId: number, questionId: number) => Promise<void>;
|
|
27
27
|
};
|
|
28
28
|
export default useCommonChatAPI;
|