@myun/gimi-chat 0.9.73 → 0.9.74
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 +13 -6
- package/dist/components/answer-item/component/tool-list/index.module.css +52 -0
- package/dist/components/answer-item/index.js +1 -3
- package/dist/hooks/useChatActions.js +0 -2
- package/dist/hooks/useCommonChatAPI.js +54 -22
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
|
@@ -11,8 +11,10 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
11
11
|
import React, { useMemo, useState } from "react";
|
|
12
12
|
import { MMarkdown } from '@myun/gimi-design';
|
|
13
13
|
import IconFont from "../../../iconfont-com";
|
|
14
|
+
import FileUpload from "../../../file-upload";
|
|
14
15
|
import styles from "./index.module.css";
|
|
15
16
|
import classNames from "classnames";
|
|
17
|
+
import { useTranslation } from "react-i18next";
|
|
16
18
|
|
|
17
19
|
// 思考工具项组件
|
|
18
20
|
var ThinkingToolItem = function ThinkingToolItem(_ref) {
|
|
@@ -148,6 +150,8 @@ var AskToolItem = function AskToolItem(_ref4) {
|
|
|
148
150
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
149
151
|
showContent = _useState6[0],
|
|
150
152
|
setShowContent = _useState6[1];
|
|
153
|
+
var _useTranslation = useTranslation(),
|
|
154
|
+
t = _useTranslation.t;
|
|
151
155
|
var askTextMap = {
|
|
152
156
|
RUNNING: "等待用户回答",
|
|
153
157
|
COMPLETED: "用户已回答"
|
|
@@ -183,11 +187,6 @@ var AskToolItem = function AskToolItem(_ref4) {
|
|
|
183
187
|
setDisabled(true);
|
|
184
188
|
handleClickAskList(item, 'click', key, value);
|
|
185
189
|
};
|
|
186
|
-
var handleInputSubmit = function handleInputSubmit() {
|
|
187
|
-
if (!inputValue.trim() || disabled) return;
|
|
188
|
-
setDisabled(true);
|
|
189
|
-
handleClickAskList(item, 'input', 'answer', inputValue.trim());
|
|
190
|
-
};
|
|
191
190
|
var optionRender = function optionRender(v) {
|
|
192
191
|
return /*#__PURE__*/React.createElement("span", null, v.value ? v.value : v.key);
|
|
193
192
|
};
|
|
@@ -225,7 +224,15 @@ var AskToolItem = function AskToolItem(_ref4) {
|
|
|
225
224
|
return onAskItemClick(v.key, v.value || v.key);
|
|
226
225
|
}
|
|
227
226
|
}, optionRender(v));
|
|
228
|
-
}))
|
|
227
|
+
})), detailInfo.uploadFile && detailInfo.answerType === 0 && /*#__PURE__*/React.createElement("div", {
|
|
228
|
+
className: classNames(styles.showUpload)
|
|
229
|
+
}, /*#__PURE__*/React.createElement(FileUpload, null, /*#__PURE__*/React.createElement("div", {
|
|
230
|
+
className: classNames(styles.uploadIcon)
|
|
231
|
+
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
232
|
+
type: "icon-shurukuang-webtianjia",
|
|
233
|
+
size: 26,
|
|
234
|
+
color: 'var(--theme-deepNeutral, #2E394C)'
|
|
235
|
+
}), /*#__PURE__*/React.createElement("span", null, t('askCard.fileUpload')))))) : item.content && showContent && /*#__PURE__*/React.createElement("div", {
|
|
229
236
|
className: styles.toolItemContent
|
|
230
237
|
}, /*#__PURE__*/React.createElement(MMarkdown, {
|
|
231
238
|
content: item.content
|
|
@@ -134,6 +134,58 @@
|
|
|
134
134
|
pointer-events: none;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
.showUpload {
|
|
138
|
+
width: fit-content;
|
|
139
|
+
min-width: 128px;
|
|
140
|
+
height: 44px;
|
|
141
|
+
flex-shrink: 0;
|
|
142
|
+
border-radius: 22px;
|
|
143
|
+
border: 1px solid var(--theme-softNeutral, #D9DCE5);
|
|
144
|
+
background: #fff;
|
|
145
|
+
display: flex;
|
|
146
|
+
align-items: center;
|
|
147
|
+
justify-content: center;
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
display: flex;
|
|
150
|
+
align-items: center;
|
|
151
|
+
padding: 0 12px;
|
|
152
|
+
box-sizing: border-box;
|
|
153
|
+
color: var(--theme-deepNeutral, #2E394C);
|
|
154
|
+
font-family: "PingFang SC";
|
|
155
|
+
font-size: 14px;
|
|
156
|
+
font-style: normal;
|
|
157
|
+
font-weight: 600;
|
|
158
|
+
line-height: normal;
|
|
159
|
+
}
|
|
160
|
+
.showUpload :global(.ant-upload) {
|
|
161
|
+
height: 100%;
|
|
162
|
+
}
|
|
163
|
+
.showUpload .uploadIcon {
|
|
164
|
+
height: 100%;
|
|
165
|
+
display: flex;
|
|
166
|
+
align-items: center;
|
|
167
|
+
gap: 6px;
|
|
168
|
+
}
|
|
169
|
+
.showUpload .uploadIcon span {
|
|
170
|
+
white-space: nowrap;
|
|
171
|
+
}
|
|
172
|
+
.showUpload .disableFile {
|
|
173
|
+
border-radius: 22px;
|
|
174
|
+
border: 1px solid var(--theme-softNeutral, #D9DCE5);
|
|
175
|
+
background: #fff;
|
|
176
|
+
color: #ced3d9;
|
|
177
|
+
font-family: "PingFang SC";
|
|
178
|
+
font-size: 14px;
|
|
179
|
+
font-style: normal;
|
|
180
|
+
font-weight: 600;
|
|
181
|
+
line-height: normal;
|
|
182
|
+
}
|
|
183
|
+
.showUpload img {
|
|
184
|
+
width: 32px;
|
|
185
|
+
height: 32px;
|
|
186
|
+
flex-shrink: 0;
|
|
187
|
+
}
|
|
188
|
+
|
|
137
189
|
@keyframes shine {
|
|
138
190
|
0% {
|
|
139
191
|
left: -60%;
|
|
@@ -303,9 +303,7 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
303
303
|
}
|
|
304
304
|
} catch (error) {}
|
|
305
305
|
newItem.content = askContent;
|
|
306
|
-
newItem.data = _objectSpread(_objectSpread({}, newItem.data),
|
|
307
|
-
data: eventData
|
|
308
|
-
});
|
|
306
|
+
newItem.data = _objectSpread(_objectSpread({}, newItem.data), eventData.data);
|
|
309
307
|
newItem.status = item.status === 'PENDING' ? 'RUNNING' : 'COMPLETED';
|
|
310
308
|
newItem.confirmStatus = item.status === 'PENDING' ? 'RUNNING' : 'COMPLETED';
|
|
311
309
|
}
|
|
@@ -198,8 +198,6 @@ var useChatActions = function useChatActions(showCopyId, inputModelRef, handleSe
|
|
|
198
198
|
// if (messageList[messageList.length - 1]?.selectValue) {
|
|
199
199
|
// return;
|
|
200
200
|
// }
|
|
201
|
-
console.log(item);
|
|
202
|
-
|
|
203
201
|
// 根据 operation 类型获取答案内容
|
|
204
202
|
var answerContent = '';
|
|
205
203
|
if (operation === 'click') {
|
|
@@ -1003,9 +1003,12 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
1003
1003
|
cleanVal,
|
|
1004
1004
|
userChat,
|
|
1005
1005
|
prevChatList,
|
|
1006
|
-
_prevChatList,
|
|
1007
|
-
lastItem,
|
|
1008
1006
|
newChatList,
|
|
1007
|
+
lastItem,
|
|
1008
|
+
_lastItem$toolList,
|
|
1009
|
+
_lastItem$toolList2,
|
|
1010
|
+
lastAskTool,
|
|
1011
|
+
updatedToolList,
|
|
1009
1012
|
_args10 = arguments;
|
|
1010
1013
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1011
1014
|
while (1) switch (_context10.prev = _context10.next) {
|
|
@@ -1057,27 +1060,55 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
1057
1060
|
|
|
1058
1061
|
// 根据isSystemAuto决定是否添加用户消息到列表
|
|
1059
1062
|
prevChatList = messageListRef.current.slice();
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
if (lastItem.moduleType === 'ask') {
|
|
1065
|
-
prevChatList = [].concat(_toConsumableArray(prevChatList.slice(0, -1)), [_objectSpread(_objectSpread({}, prevChatList[prevChatList.length - 1]), {}, {
|
|
1066
|
-
disableUploadFile: true
|
|
1067
|
-
})]);
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
newChatList = [].concat(_toConsumableArray(prevChatList), [userChat]);
|
|
1071
|
-
dispatch(setMessageList({
|
|
1072
|
-
messageList: newChatList
|
|
1073
|
-
}));
|
|
1074
|
-
startChat(newChatList, isSystemAuto, conversationId, undefined, skipCreateNewMessage);
|
|
1075
|
-
} else {
|
|
1076
|
-
setMsgLoading(true);
|
|
1077
|
-
// 系统自动上传,直接开始会话,不更新列表
|
|
1078
|
-
startChat(_toConsumableArray(prevChatList), isSystemAuto, conversationId, undefined, skipCreateNewMessage);
|
|
1063
|
+
newChatList = [].concat(_toConsumableArray(prevChatList), [userChat]);
|
|
1064
|
+
if (isSystemAuto) {
|
|
1065
|
+
_context10.next = 40;
|
|
1066
|
+
break;
|
|
1079
1067
|
}
|
|
1080
|
-
|
|
1068
|
+
setMsgLoading(true);
|
|
1069
|
+
if (!((prevChatList === null || prevChatList === void 0 ? void 0 : prevChatList.length) > 1)) {
|
|
1070
|
+
_context10.next = 36;
|
|
1071
|
+
break;
|
|
1072
|
+
}
|
|
1073
|
+
lastItem = prevChatList[prevChatList.length - 1];
|
|
1074
|
+
if (!(lastItem.moduleType === 'ask')) {
|
|
1075
|
+
_context10.next = 36;
|
|
1076
|
+
break;
|
|
1077
|
+
}
|
|
1078
|
+
lastAskTool = (_lastItem$toolList = lastItem.toolList) === null || _lastItem$toolList === void 0 ? void 0 : _lastItem$toolList.find(function (tool) {
|
|
1079
|
+
return tool.moduleType === 'ask';
|
|
1080
|
+
});
|
|
1081
|
+
if (lastAskTool) {
|
|
1082
|
+
_context10.next = 33;
|
|
1083
|
+
break;
|
|
1084
|
+
}
|
|
1085
|
+
return _context10.abrupt("return");
|
|
1086
|
+
case 33:
|
|
1087
|
+
updatedToolList = (_lastItem$toolList2 = lastItem.toolList) === null || _lastItem$toolList2 === void 0 ? void 0 : _lastItem$toolList2.map(function (tool) {
|
|
1088
|
+
return tool.id === lastAskTool.id ? _objectSpread(_objectSpread({}, tool), {}, {
|
|
1089
|
+
moduleType: "ask",
|
|
1090
|
+
status: 'COMPLETED',
|
|
1091
|
+
confirmStatus: "CONFIRMED",
|
|
1092
|
+
content: value
|
|
1093
|
+
}) : tool;
|
|
1094
|
+
});
|
|
1095
|
+
skipCreateNewMessage = true;
|
|
1096
|
+
newChatList = [].concat(_toConsumableArray(prevChatList.slice(0, -1)), [_objectSpread(_objectSpread({}, prevChatList[prevChatList.length - 1]), {}, {
|
|
1097
|
+
disableUploadFile: true,
|
|
1098
|
+
toolList: updatedToolList
|
|
1099
|
+
})]);
|
|
1100
|
+
case 36:
|
|
1101
|
+
dispatch(setMessageList({
|
|
1102
|
+
messageList: newChatList
|
|
1103
|
+
}));
|
|
1104
|
+
startChat(newChatList, isSystemAuto, conversationId, undefined, skipCreateNewMessage);
|
|
1105
|
+
_context10.next = 42;
|
|
1106
|
+
break;
|
|
1107
|
+
case 40:
|
|
1108
|
+
setMsgLoading(true);
|
|
1109
|
+
// 系统自动上传,直接开始会话,不更新列表
|
|
1110
|
+
startChat(_toConsumableArray(prevChatList), isSystemAuto, conversationId, undefined, skipCreateNewMessage);
|
|
1111
|
+
case 42:
|
|
1081
1112
|
case "end":
|
|
1082
1113
|
return _context10.stop();
|
|
1083
1114
|
}
|
|
@@ -1326,6 +1357,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
1326
1357
|
var uploadFile = fileList[0];
|
|
1327
1358
|
var isLastMessageEmptyUserChat = (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.moduleType) === 'ask'; // 空内容
|
|
1328
1359
|
if (!isLastMessageEmptyUserChat) {
|
|
1360
|
+
console.log('isLastMessageEmptyUserChat', isLastMessageEmptyUserChat);
|
|
1329
1361
|
var shouldEnableUpload = uploadFile.status === FileStatus.UPLOAD_FAILED || uploadFile.status === FileStatus.ANALYSE_FAILED;
|
|
1330
1362
|
var newMessageList = [].concat(_toConsumableArray(messageList.slice(0, -2)), [_objectSpread(_objectSpread({}, messageList[messageList.length - 2]), {}, {
|
|
1331
1363
|
disableUploadFile: !shouldEnableUpload
|