@myun/gimi-chat 0.9.23 → 0.9.25
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/chat-input/index.d.ts +1 -0
- package/dist/components/chat-input/index.js +7 -3
- package/dist/components/chat-input/index.module.css +10 -0
- package/dist/components/message-list/index.js +2 -2
- package/dist/components/templates/CommonChat.js +4 -1
- package/dist/components/upload-list/index.js +13 -7
- package/dist/i18n/locales/en-US.js +1 -1
- package/dist/i18n/locales/zh-CN.js +1 -1
- package/dist/types/chat.d.ts +1 -0
- package/dist/types/file.d.ts +7 -0
- package/dist/umd/index.min.js +1 -1
- package/dist/utils/tools.d.ts +1 -0
- package/dist/utils/tools.js +25 -1
- package/package.json +1 -1
|
@@ -44,6 +44,7 @@ interface IAIInputProps {
|
|
|
44
44
|
onValueChange?: (value: string) => void;
|
|
45
45
|
renderSendButton?: (defaultBtn: React.ReactNode) => React.ReactNode;
|
|
46
46
|
agentList?: AgentConfig[];
|
|
47
|
+
hiddenDeepThink?: boolean;
|
|
47
48
|
onAgentChange?: (agentId: number) => void;
|
|
48
49
|
}
|
|
49
50
|
declare const ChatInput: React.ForwardRefExoticComponent<IAIInputProps & React.RefAttributes<ChatInputRef>>;
|
|
@@ -198,7 +198,11 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
198
198
|
disabled: shouldDisableUploadFile,
|
|
199
199
|
onFileUploaded: props.onFileUploaded
|
|
200
200
|
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
201
|
-
content:
|
|
201
|
+
content: /*#__PURE__*/React.createElement("span", {
|
|
202
|
+
style: {
|
|
203
|
+
whiteSpace: 'pre-line'
|
|
204
|
+
}
|
|
205
|
+
}, t('chatInput.uploadFile'))
|
|
202
206
|
}, shouldDisableUploadFile ? /*#__PURE__*/React.createElement("div", {
|
|
203
207
|
className: styles.uploadIcon,
|
|
204
208
|
onClick: handleTip,
|
|
@@ -445,7 +449,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
445
449
|
var renderConfigureArea = React.useCallback(function () {
|
|
446
450
|
return /*#__PURE__*/React.createElement("div", {
|
|
447
451
|
className: styles.configureArea
|
|
448
|
-
}, UploadFileTool, /*#__PURE__*/React.createElement(Tooltip, {
|
|
452
|
+
}, UploadFileTool, !props.hiddenDeepThink && /*#__PURE__*/React.createElement(Tooltip, {
|
|
449
453
|
trigger: 'click',
|
|
450
454
|
content: t('chatInput.deepThinkTip')
|
|
451
455
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -464,7 +468,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
464
468
|
marginLeft: 0
|
|
465
469
|
}
|
|
466
470
|
}))), AgentContainer);
|
|
467
|
-
}, [UploadFileTool]);
|
|
471
|
+
}, [UploadFileTool, props.hiddenDeepThink, AgentContainer]);
|
|
468
472
|
var stopSSe = function stopSSe() {
|
|
469
473
|
if (uploadFileRef.current) {
|
|
470
474
|
var _uploadFileRef$curren;
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
box-shadow: inset 0 2px #fff, 0 2px 10px rgba(84, 105, 140, 0.15);
|
|
9
9
|
border-radius: 10px;
|
|
10
10
|
}
|
|
11
|
+
@media (min-width: 1921px) {
|
|
12
|
+
.inputWrap {
|
|
13
|
+
max-width: 1000px;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
11
16
|
|
|
12
17
|
.deepthink {
|
|
13
18
|
padding: 0 12px;
|
|
@@ -60,6 +65,11 @@
|
|
|
60
65
|
scrollbar-width: thin;
|
|
61
66
|
scrollbar-color: #d1d1d1 transparent;
|
|
62
67
|
}
|
|
68
|
+
@media (min-width: 1921px) {
|
|
69
|
+
.chatInput {
|
|
70
|
+
max-width: 1000px;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
63
73
|
.chatInput::-webkit-scrollbar {
|
|
64
74
|
width: 4px;
|
|
65
75
|
}
|
|
@@ -25,7 +25,7 @@ import useChatActions from "../../hooks/useChatActions";
|
|
|
25
25
|
import CopyButton from "../message-actions/CopyButton";
|
|
26
26
|
import { Virtuoso } from 'react-virtuoso';
|
|
27
27
|
var MessageItem = /*#__PURE__*/React.memo(function (props) {
|
|
28
|
-
var _v$quoteTeachModelLis, _v$quoteProductList;
|
|
28
|
+
var _v$quoteTeachModelLis, _v$quoteProductList, _v$messageFilesList;
|
|
29
29
|
var v = props.v,
|
|
30
30
|
chatUI = props.chatUI,
|
|
31
31
|
hideUserMessage = props.hideUserMessage,
|
|
@@ -76,7 +76,7 @@ var MessageItem = /*#__PURE__*/React.memo(function (props) {
|
|
|
76
76
|
className: styles.listBox
|
|
77
77
|
}, /*#__PURE__*/React.createElement(UploadList, {
|
|
78
78
|
isMessage: true,
|
|
79
|
-
fileList: Array.isArray(v.messageFiles) ? v.messageFiles : [v.messageFiles],
|
|
79
|
+
fileList: v !== null && v !== void 0 && (_v$messageFilesList = v.messageFilesList) !== null && _v$messageFilesList !== void 0 && _v$messageFilesList.length ? v.messageFilesList : Array.isArray(v.messageFiles) ? v.messageFiles : [v.messageFiles],
|
|
80
80
|
showDel: false,
|
|
81
81
|
handleDelFile: function handleDelFile() {},
|
|
82
82
|
handleReTry: handleReTry
|
|
@@ -53,7 +53,9 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
53
53
|
_props$enableSearchCo = props.enableSearchCourse,
|
|
54
54
|
enableSearchCourse = _props$enableSearchCo === void 0 ? true : _props$enableSearchCo,
|
|
55
55
|
_props$agentList = props.agentList,
|
|
56
|
-
agentList = _props$agentList === void 0 ? [] : _props$agentList
|
|
56
|
+
agentList = _props$agentList === void 0 ? [] : _props$agentList,
|
|
57
|
+
_props$hiddenDeepThin = props.hiddenDeepThink,
|
|
58
|
+
hiddenDeepThink = _props$hiddenDeepThin === void 0 ? false : _props$hiddenDeepThin;
|
|
57
59
|
var store = useStore();
|
|
58
60
|
var dispatch = useAppDispatch();
|
|
59
61
|
var containerRef = React.useRef(null);
|
|
@@ -302,6 +304,7 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
302
304
|
platform: platform,
|
|
303
305
|
initQuoteSource: props.initQuoteSource,
|
|
304
306
|
agentList: agentList,
|
|
307
|
+
hiddenDeepThink: hiddenDeepThink,
|
|
305
308
|
onAgentChange: setCurrentAgentId
|
|
306
309
|
}, props.chatInputConfig)), showPrologue && messageList.length === 0 && !isMoreLoading && quickQuestionListPosition === 'bottom' && /*#__PURE__*/React.createElement(PresetAgentContent, {
|
|
307
310
|
prologue: '',
|
|
@@ -8,12 +8,13 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
8
8
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
9
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
-
import React, { useRef, useState, useEffect } from 'react';
|
|
11
|
+
import React, { useRef, useState, useEffect, useMemo } from 'react';
|
|
12
12
|
import ImageFile from "./ImageFile";
|
|
13
13
|
import CustomFile from "./CustomFile";
|
|
14
14
|
import styles from "./index.module.css";
|
|
15
15
|
import IconFontCom from "../iconfont-com";
|
|
16
16
|
import classNames from 'classnames';
|
|
17
|
+
import { handleFileList } from "../../utils/tools";
|
|
17
18
|
var UploadFile = function UploadFile(_ref) {
|
|
18
19
|
var _ref$fileList = _ref.fileList,
|
|
19
20
|
fileList = _ref$fileList === void 0 ? [] : _ref$fileList,
|
|
@@ -23,9 +24,6 @@ var UploadFile = function UploadFile(_ref) {
|
|
|
23
24
|
showDel = _ref$showDel === void 0 ? true : _ref$showDel,
|
|
24
25
|
_ref$isMessage = _ref.isMessage,
|
|
25
26
|
isMessage = _ref$isMessage === void 0 ? false : _ref$isMessage;
|
|
26
|
-
var allImages = (fileList === null || fileList === void 0 ? void 0 : fileList.length) > 0 && fileList.every(function (f) {
|
|
27
|
-
return f.isImage;
|
|
28
|
-
});
|
|
29
27
|
var scrollRef = useRef(null);
|
|
30
28
|
var _useState = useState(false),
|
|
31
29
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -35,6 +33,14 @@ var UploadFile = function UploadFile(_ref) {
|
|
|
35
33
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
36
34
|
showRight = _useState4[0],
|
|
37
35
|
setShowRight = _useState4[1];
|
|
36
|
+
var transformFileList = useMemo(function () {
|
|
37
|
+
return handleFileList(fileList);
|
|
38
|
+
}, [fileList]);
|
|
39
|
+
var allImages = useMemo(function () {
|
|
40
|
+
return (transformFileList === null || transformFileList === void 0 ? void 0 : transformFileList.length) > 0 && transformFileList.every(function (f) {
|
|
41
|
+
return f.isImage;
|
|
42
|
+
});
|
|
43
|
+
}, [transformFileList]);
|
|
38
44
|
var checkScroll = function checkScroll() {
|
|
39
45
|
var el = scrollRef.current;
|
|
40
46
|
if (!el) return;
|
|
@@ -55,7 +61,7 @@ var UploadFile = function UploadFile(_ref) {
|
|
|
55
61
|
};
|
|
56
62
|
return /*#__PURE__*/React.createElement(React.Fragment, null, allImages ? /*#__PURE__*/React.createElement("div", {
|
|
57
63
|
className: classNames(styles.imgList, _defineProperty({}, styles.imgListMessage, isMessage))
|
|
58
|
-
},
|
|
64
|
+
}, transformFileList.map(function (file) {
|
|
59
65
|
return /*#__PURE__*/React.createElement(ImageFile, {
|
|
60
66
|
key: file.uid,
|
|
61
67
|
file: file,
|
|
@@ -65,7 +71,7 @@ var UploadFile = function UploadFile(_ref) {
|
|
|
65
71
|
handleReTry: handleReTry,
|
|
66
72
|
showDel: showDel,
|
|
67
73
|
isMessage: isMessage,
|
|
68
|
-
isSingle: (
|
|
74
|
+
isSingle: (transformFileList === null || transformFileList === void 0 ? void 0 : transformFileList.length) === 1
|
|
69
75
|
});
|
|
70
76
|
})) : /*#__PURE__*/React.createElement("div", {
|
|
71
77
|
className: classNames(styles.customListWrapper)
|
|
@@ -73,7 +79,7 @@ var UploadFile = function UploadFile(_ref) {
|
|
|
73
79
|
ref: scrollRef,
|
|
74
80
|
className: classNames(styles.customList, _defineProperty({}, styles.customListMessage, isMessage), _defineProperty({}, styles.customListLeft, showLeft), _defineProperty({}, styles.customListRight, showRight)),
|
|
75
81
|
onScroll: checkScroll
|
|
76
|
-
},
|
|
82
|
+
}, transformFileList.map(function (file) {
|
|
77
83
|
return /*#__PURE__*/React.createElement(CustomFile, {
|
|
78
84
|
key: file.uid,
|
|
79
85
|
file: file,
|
|
@@ -15,7 +15,7 @@ var enUS = {
|
|
|
15
15
|
'chatInput.uploadLimitFive': 'Upload limit is 5 files',
|
|
16
16
|
'chatInput.uploadLimitTen': 'Upload limit is 10 files',
|
|
17
17
|
'chatInput.flowUnsupported': 'This button is not supported in the current flow. Please wait for the current flow to finish or follow the instructions on the chat card.',
|
|
18
|
-
'chatInput.uploadFile': '
|
|
18
|
+
'chatInput.uploadFile': 'Supports Word, Excel, images\nUp to 10 files (max 20MB each)',
|
|
19
19
|
'chatInput.newConversation': 'New conversation',
|
|
20
20
|
'chatInput.deepThinkTip': 'System intelligently switches thinking mode',
|
|
21
21
|
'chatInput.deepThinkModeAuto': 'Thinking',
|
|
@@ -15,7 +15,7 @@ var zhCN = {
|
|
|
15
15
|
'chatInput.uploadLimitFive': '最多上传5个文件哦',
|
|
16
16
|
'chatInput.uploadLimitTen': '最多上传10个文件哦',
|
|
17
17
|
'chatInput.flowUnsupported': '当前流程不支持该按钮的使用,请等待正在进行的流程结束或按对话卡片指示继续流程',
|
|
18
|
-
'chatInput.uploadFile': '
|
|
18
|
+
'chatInput.uploadFile': '支持Word、Excel、图片\n最多10个文件(单个不超过20M)',
|
|
19
19
|
'chatInput.newConversation': '新对话',
|
|
20
20
|
'chatInput.deepThinkTip': '系统智能切换思考模式',
|
|
21
21
|
'chatInput.deepThinkModeAuto': '思考',
|
package/dist/types/chat.d.ts
CHANGED
package/dist/types/file.d.ts
CHANGED
|
@@ -14,6 +14,13 @@ export type FileItem = {
|
|
|
14
14
|
process?: number; // 解析进度
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export type HistoryFileItem = {
|
|
18
|
+
fileAddr: string;
|
|
19
|
+
fileName: string;
|
|
20
|
+
fileSize: number;
|
|
21
|
+
fileSizeStr: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
17
24
|
export interface IFileCardProps {
|
|
18
25
|
fileName: string;
|
|
19
26
|
downloadUrl: string;
|