@myun/gimi-chat 0.9.76 → 0.9.77
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/components/answer-item/component/tool-list/index.js +24 -6
- package/dist/components/answer-item/component/tool-list/index.module.css +0 -3
- package/dist/components/answer-item/index.js +3 -0
- package/dist/hooks/useCommonChatAPI.js +56 -28
- package/dist/i18n/locales/en-US.d.ts +1 -0
- package/dist/i18n/locales/en-US.js +1 -0
- package/dist/i18n/locales/zh-CN.d.ts +1 -0
- package/dist/i18n/locales/zh-CN.js +1 -0
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ import FileUpload from "../../../file-upload";
|
|
|
15
15
|
import styles from "./index.module.css";
|
|
16
16
|
import classNames from "classnames";
|
|
17
17
|
import { useTranslation } from "react-i18next";
|
|
18
|
-
|
|
18
|
+
import { useAppSelector } from "../../../../store/hooks";
|
|
19
19
|
// 思考工具项组件
|
|
20
20
|
var ThinkingToolItem = function ThinkingToolItem(_ref) {
|
|
21
21
|
var item = _ref.item,
|
|
@@ -162,8 +162,15 @@ var AskToolItem = function AskToolItem(_ref4) {
|
|
|
162
162
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
163
163
|
showContent = _useState8[0],
|
|
164
164
|
setShowContent = _useState8[1];
|
|
165
|
+
var _useState9 = useState(false),
|
|
166
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
167
|
+
uploadDisabled = _useState10[0],
|
|
168
|
+
setUploadDisabled = _useState10[1];
|
|
165
169
|
var _useTranslation = useTranslation(),
|
|
166
170
|
t = _useTranslation.t;
|
|
171
|
+
var fileList = useAppSelector(function (state) {
|
|
172
|
+
return state.gimiMenu.fileList;
|
|
173
|
+
});
|
|
167
174
|
var askTextMap = {
|
|
168
175
|
RUNNING: "等待人工确认",
|
|
169
176
|
COMPLETED: "用户已确认"
|
|
@@ -190,10 +197,15 @@ var AskToolItem = function AskToolItem(_ref4) {
|
|
|
190
197
|
detailInfo = _React$useMemo.detailInfo,
|
|
191
198
|
optionsList = _React$useMemo.optionsList,
|
|
192
199
|
questionContent = _React$useMemo.questionContent;
|
|
193
|
-
|
|
200
|
+
useEffect(function () {
|
|
194
201
|
var isAnswered = item.status === 'ANSWERED' || item.confirmStatus === 'CONFIRMED';
|
|
195
202
|
setDisabled(Boolean(isAnswered));
|
|
196
203
|
}, [item.confirmStatus, item.status]);
|
|
204
|
+
useEffect(function () {
|
|
205
|
+
setUploadDisabled((fileList === null || fileList === void 0 ? void 0 : fileList.findIndex(function (v) {
|
|
206
|
+
return (v === null || v === void 0 ? void 0 : v.status) === "uploading" || (v === null || v === void 0 ? void 0 : v.status) === "padding";
|
|
207
|
+
})) !== -1);
|
|
208
|
+
}, [fileList]);
|
|
197
209
|
var onAskItemClick = function onAskItemClick(key, value) {
|
|
198
210
|
if (disabled) return;
|
|
199
211
|
setDisabled(true);
|
|
@@ -238,13 +250,19 @@ var AskToolItem = function AskToolItem(_ref4) {
|
|
|
238
250
|
}, optionRender(v));
|
|
239
251
|
})), detailInfo.uploadFile && detailInfo.answerType === 0 && /*#__PURE__*/React.createElement("div", {
|
|
240
252
|
className: classNames(styles.showUpload)
|
|
241
|
-
}, /*#__PURE__*/React.createElement(FileUpload,
|
|
242
|
-
|
|
253
|
+
}, /*#__PURE__*/React.createElement(FileUpload, {
|
|
254
|
+
disabled: uploadDisabled
|
|
255
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
256
|
+
className: classNames(styles.uploadIcon, uploadDisabled ? styles.disableFile : '')
|
|
243
257
|
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
244
258
|
type: "icon-shurukuang-webtianjia",
|
|
245
259
|
size: 26,
|
|
246
|
-
color: 'var(--theme-deepNeutral, #2E394C)'
|
|
247
|
-
}), /*#__PURE__*/React.createElement("span",
|
|
260
|
+
color: uploadDisabled ? 'var(--theme-softNeutral, #D9DCE5)' : 'var(--theme-deepNeutral, #2E394C)'
|
|
261
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
262
|
+
style: uploadDisabled ? {
|
|
263
|
+
color: "var(--theme-softNeutral, #D9DCE5)"
|
|
264
|
+
} : {}
|
|
265
|
+
}, uploadDisabled ? t('askCard.uploading') : t('askCard.fileUpload')))))) : item.content && showContent && /*#__PURE__*/React.createElement("div", {
|
|
248
266
|
className: styles.toolItemContent
|
|
249
267
|
}, /*#__PURE__*/React.createElement(MMarkdown, {
|
|
250
268
|
content: item.content
|
|
@@ -171,12 +171,9 @@
|
|
|
171
171
|
}
|
|
172
172
|
.showUpload .disableFile {
|
|
173
173
|
border-radius: 22px;
|
|
174
|
-
border: 1px solid var(--theme-softNeutral, #D9DCE5);
|
|
175
174
|
background: #fff;
|
|
176
175
|
color: #ced3d9;
|
|
177
|
-
font-family: "PingFang SC";
|
|
178
176
|
font-size: 14px;
|
|
179
|
-
font-style: normal;
|
|
180
177
|
font-weight: 600;
|
|
181
178
|
line-height: normal;
|
|
182
179
|
}
|
|
@@ -300,6 +300,9 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
300
300
|
var options = (_eventData2 = eventData) === null || _eventData2 === void 0 || (_eventData2 = _eventData2.data) === null || _eventData2 === void 0 || (_eventData2 = _eventData2.results) === null || _eventData2 === void 0 || (_eventData2 = _eventData2.askShowInfo) === null || _eventData2 === void 0 ? void 0 : _eventData2.options;
|
|
301
301
|
if (clickedOptionId && options && options[clickedOptionId]) {
|
|
302
302
|
askContent = options[clickedOptionId];
|
|
303
|
+
} else {
|
|
304
|
+
var _eventData3;
|
|
305
|
+
askContent = ((_eventData3 = eventData) === null || _eventData3 === void 0 || (_eventData3 = _eventData3.data) === null || _eventData3 === void 0 ? void 0 : _eventData3.results["".concat(eventData.id, ".USER_RESPONSE")]) || '';
|
|
303
306
|
}
|
|
304
307
|
} catch (error) {}
|
|
305
308
|
newItem.content = askContent;
|
|
@@ -34,7 +34,6 @@ import useScroll from "./useScroll";
|
|
|
34
34
|
// 获取推荐课程
|
|
35
35
|
import { useChatRecommend } from "./useChatRecommend";
|
|
36
36
|
import { set, cloneDeep } from 'lodash';
|
|
37
|
-
import { FileStatus } from "../interfaces/fileInterface";
|
|
38
37
|
import useChatHistory from "./useChatHistory";
|
|
39
38
|
var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
40
39
|
var _useTranslation = useTranslation(),
|
|
@@ -1345,46 +1344,75 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
1345
1344
|
return;
|
|
1346
1345
|
}
|
|
1347
1346
|
setMsgLoading(true);
|
|
1348
|
-
startChat(messageList, false, undefined, true);
|
|
1347
|
+
startChat(messageList, false, undefined, true, true);
|
|
1349
1348
|
}, [startChat, status]);
|
|
1350
1349
|
React.useEffect(function () {
|
|
1351
1350
|
var hasValidFile = (fileList === null || fileList === void 0 ? void 0 : fileList.length) > 0;
|
|
1352
1351
|
var messageList = messageListRef.current || [];
|
|
1353
1352
|
var lastMessage = messageList[messageList.length - 1];
|
|
1354
|
-
|
|
1353
|
+
// const targetMessage = messageList[messageList.length - 2];
|
|
1355
1354
|
if (hasValidFile && lastMessage) {
|
|
1356
|
-
setDisableSend(
|
|
1355
|
+
setDisableSend(hasValidFile);
|
|
1357
1356
|
var uploadFile = fileList[0];
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
var
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1357
|
+
|
|
1358
|
+
// 当有文件内容时处理请求
|
|
1359
|
+
if (uploadFile !== null && uploadFile !== void 0 && uploadFile.content && (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.moduleType) === 'ask') {
|
|
1360
|
+
var _lastMessage$toolList, _messageListRef$curre;
|
|
1361
|
+
var moduleInfo = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.moduleInfo;
|
|
1362
|
+
var updatedToolList = (_lastMessage$toolList = lastMessage.toolList) === null || _lastMessage$toolList === void 0 ? void 0 : _lastMessage$toolList.map(function (tool) {
|
|
1363
|
+
return tool.status === 'RUNNING' ? _objectSpread(_objectSpread({}, tool), {}, {
|
|
1364
|
+
moduleType: "ask",
|
|
1365
|
+
status: 'COMPLETED',
|
|
1366
|
+
confirmStatus: "CONFIRMED",
|
|
1367
|
+
content: uploadFile.content
|
|
1368
|
+
}) : tool;
|
|
1369
|
+
});
|
|
1370
|
+
var updatedMessageList = [].concat(_toConsumableArray(messageList.slice(0, -1)), [_objectSpread(_objectSpread({}, lastMessage), {}, {
|
|
1371
|
+
toolList: updatedToolList
|
|
1365
1372
|
})]);
|
|
1366
1373
|
dispatch(setMessageList({
|
|
1367
|
-
messageList:
|
|
1374
|
+
messageList: updatedMessageList
|
|
1368
1375
|
}));
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
var _inputModel = _defineProperty({}, "".concat(moduleInfo === null || moduleInfo === void 0 ? void 0 : moduleInfo.id, ".input"), '');
|
|
1374
|
-
inputModelRef.current = _inputModel;
|
|
1375
|
-
if (((_messageListRef$curre = messageListRef.current) === null || _messageListRef$curre === void 0 ? void 0 : _messageListRef$curre.length) > 0) {
|
|
1376
|
-
handleSendFile(newMessageList);
|
|
1377
|
-
}
|
|
1376
|
+
var _inputModel = _defineProperty({}, "".concat(moduleInfo === null || moduleInfo === void 0 ? void 0 : moduleInfo.id, ".input"), '');
|
|
1377
|
+
inputModelRef.current = _inputModel;
|
|
1378
|
+
if (((_messageListRef$curre = messageListRef.current) === null || _messageListRef$curre === void 0 ? void 0 : _messageListRef$curre.length) > 0) {
|
|
1379
|
+
handleSendFile(updatedMessageList);
|
|
1378
1380
|
}
|
|
1379
|
-
} else {
|
|
1380
|
-
var _newMessageList2 = [].concat(_toConsumableArray(messageList.slice(0, -1)), [_objectSpread(_objectSpread({}, messageList[messageList.length - 1]), {}, {
|
|
1381
|
-
disableUploadFile: true
|
|
1382
|
-
}), createUserChat('', "".concat(conversationIdRef.current))]);
|
|
1383
|
-
dispatch(setMessageList({
|
|
1384
|
-
messageList: _newMessageList2
|
|
1385
|
-
}));
|
|
1386
1381
|
}
|
|
1387
1382
|
}
|
|
1383
|
+
// if (hasValidFile && lastMessage) {
|
|
1384
|
+
// setDisableSend(true);
|
|
1385
|
+
// const uploadFile = fileList[0];
|
|
1386
|
+
// const isLastMessageEmptyUserChat = lastMessage?.moduleType === 'ask'; // 空内容
|
|
1387
|
+
// if (!isLastMessageEmptyUserChat) {
|
|
1388
|
+
// const shouldEnableUpload = uploadFile.status === FileStatus.UPLOAD_FAILED || uploadFile.status === FileStatus.ANALYSE_FAILED;
|
|
1389
|
+
// const newMessageList = [...messageList.slice(0, -2),
|
|
1390
|
+
// { ...messageList[messageList.length - 2], disableUploadFile: !shouldEnableUpload },
|
|
1391
|
+
// { ...messageList[messageList.length - 1], messageFiles: [uploadFile] }];
|
|
1392
|
+
// dispatch(setMessageList({ messageList: newMessageList }));
|
|
1393
|
+
// // 当有文件内容时处理请求
|
|
1394
|
+
// if (uploadFile?.content && targetMessage?.moduleType === 'ask') {
|
|
1395
|
+
// const moduleInfo = targetMessage?.moduleInfo;
|
|
1396
|
+
// const _inputModel = {
|
|
1397
|
+
// [`${moduleInfo?.id}.input`]: '',
|
|
1398
|
+
// };
|
|
1399
|
+
// inputModelRef.current = _inputModel;
|
|
1400
|
+
// if (messageListRef.current?.length > 0) {
|
|
1401
|
+
// handleSendFile(newMessageList);
|
|
1402
|
+
// }
|
|
1403
|
+
// }
|
|
1404
|
+
// } else {
|
|
1405
|
+
// // const newMessageList = [
|
|
1406
|
+
// // ...messageList.slice(0, -1),
|
|
1407
|
+
// // {
|
|
1408
|
+
// // ...messageList[messageList.length - 1],
|
|
1409
|
+
// // disableUploadFile: true,
|
|
1410
|
+
// // },
|
|
1411
|
+
// // createUserChat('', `${conversationIdRef.current}`),
|
|
1412
|
+
// // ];
|
|
1413
|
+
// // dispatch(setMessageList({ messageList: newMessageList }));
|
|
1414
|
+
// }
|
|
1415
|
+
// }
|
|
1388
1416
|
}, [fileList, dispatch, handleSendFile, createUserChat]);
|
|
1389
1417
|
var onSucessExcel = React.useCallback(function (value) {
|
|
1390
1418
|
// setDisableSend(true);
|
|
@@ -111,6 +111,7 @@ declare const enUS: {
|
|
|
111
111
|
'common.scoreUnit': string;
|
|
112
112
|
'common.networkUnavailable': string;
|
|
113
113
|
'askCard.fileUpload': string;
|
|
114
|
+
'askCard.uploading': string;
|
|
114
115
|
'upload.readFailed': string;
|
|
115
116
|
'upload.networkRetry': string;
|
|
116
117
|
'upload.failedMaxRetry': string;
|
|
@@ -111,6 +111,7 @@ var enUS = {
|
|
|
111
111
|
'common.scoreUnit': 'Points',
|
|
112
112
|
'common.networkUnavailable': 'Network connection error',
|
|
113
113
|
'askCard.fileUpload': 'File Upload',
|
|
114
|
+
'askCard.uploading': 'Uploading',
|
|
114
115
|
'upload.readFailed': 'File read failed',
|
|
115
116
|
'upload.networkRetry': 'Network error, waiting to retry',
|
|
116
117
|
'upload.failedMaxRetry': 'Upload failed, max retries reached',
|
|
@@ -113,6 +113,7 @@ declare const zhCN: {
|
|
|
113
113
|
'common.scoreUnit': string;
|
|
114
114
|
'common.networkUnavailable': string;
|
|
115
115
|
'askCard.fileUpload': string;
|
|
116
|
+
'askCard.uploading': string;
|
|
116
117
|
'upload.readFailed': string;
|
|
117
118
|
'upload.networkRetry': string;
|
|
118
119
|
'upload.failedMaxRetry': string;
|
|
@@ -113,6 +113,7 @@ var zhCN = {
|
|
|
113
113
|
'common.scoreUnit': '分',
|
|
114
114
|
'common.networkUnavailable': '无法连接到网络',
|
|
115
115
|
'askCard.fileUpload': '文件上传',
|
|
116
|
+
'askCard.uploading': '上传中',
|
|
116
117
|
'upload.readFailed': '文件读取失败',
|
|
117
118
|
'upload.networkRetry': '网络异常,等待恢复后重试',
|
|
118
119
|
'upload.failedMaxRetry': '文件上传失败,已达到最大重试次数',
|