@myun/gimi-chat 0.3.6 → 0.3.8
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.js +8 -2
- package/dist/components/chat-input/index.module.css +42 -0
- package/dist/components/file-card/fileCardSidebar.d.ts +1 -1
- package/dist/components/file-card/fileCardSidebar.js +2 -2
- package/dist/components/gimi-sidebar/index.module.css +1 -0
- package/dist/components/knowledge-trace/index.d.ts +1 -1
- package/dist/components/knowledge-trace/index.js +2 -2
- package/dist/components/quoted-content/index.js +17 -13
- package/dist/components/quoted-content/index.module.css +23 -6
- package/dist/components/templates/CommonChat.js +9 -1
- package/dist/hooks/useChatStream.js +2 -1
- package/dist/hooks/useCommonChatAPI.js +10 -11
- package/dist/types/chat.d.ts +6 -0
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
|
@@ -296,6 +296,12 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
296
296
|
}))
|
|
297
297
|
});
|
|
298
298
|
}, [props.enableVoiceChat, props.enableVoiceRecord, props.disabled, props.disableVoiceCommunication, props.isVoiceGetting, isMsgRecieving, openChatCommunication, props.shortAsrClick, agentObj === null || agentObj === void 0 ? void 0 : agentObj.isEnableVoiceCall]);
|
|
299
|
+
var renderQuotedContent = React.useMemo(function () {
|
|
300
|
+
if (!props.enableSourceQuote) {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
return /*#__PURE__*/React.createElement(QuotedContent, null);
|
|
304
|
+
}, [props.enableSourceQuote]);
|
|
299
305
|
var renderActionArea = React.useCallback(function (renderProps) {
|
|
300
306
|
return /*#__PURE__*/React.createElement("div", {
|
|
301
307
|
className: renderProps.className,
|
|
@@ -305,13 +311,13 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
305
311
|
display: 'flex',
|
|
306
312
|
alignItems: 'center'
|
|
307
313
|
}
|
|
308
|
-
},
|
|
314
|
+
}, renderQuotedContent, VoiceTools, UploadFileTool, /*#__PURE__*/React.createElement(Divider, {
|
|
309
315
|
layout: "vertical",
|
|
310
316
|
style: {
|
|
311
317
|
marginLeft: 8
|
|
312
318
|
}
|
|
313
319
|
})), renderProps.menuItem);
|
|
314
|
-
}, [VoiceTools, UploadFileTool,
|
|
320
|
+
}, [VoiceTools, UploadFileTool, renderQuotedContent]);
|
|
315
321
|
var onMessageSend = React.useCallback(function (content) {
|
|
316
322
|
var _props$onSend;
|
|
317
323
|
var inputContents = content.inputContents || [];
|
|
@@ -48,4 +48,46 @@
|
|
|
48
48
|
margin: 0px 10px 10px 10px;
|
|
49
49
|
padding: 16px;
|
|
50
50
|
max-width: 800px;
|
|
51
|
+
max-height: 400px;
|
|
52
|
+
overflow-y: auto;
|
|
53
|
+
scrollbar-width: thin;
|
|
54
|
+
scrollbar-color: #d1d1d1 transparent;
|
|
55
|
+
}
|
|
56
|
+
.chatInput::-webkit-scrollbar {
|
|
57
|
+
width: 4px;
|
|
58
|
+
}
|
|
59
|
+
.chatInput::-webkit-scrollbar-thumb {
|
|
60
|
+
background-color: #d1d1d1;
|
|
61
|
+
border-radius: 2px;
|
|
62
|
+
border: none;
|
|
63
|
+
}
|
|
64
|
+
.chatInput::-webkit-scrollbar-track {
|
|
65
|
+
background-color: transparent;
|
|
66
|
+
border: none;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.reference {
|
|
70
|
+
max-height: 180px;
|
|
71
|
+
overflow: auto;
|
|
72
|
+
flex: 1;
|
|
73
|
+
scrollbar-width: thin;
|
|
74
|
+
scrollbar-color: #d1d1d1 transparent;
|
|
75
|
+
}
|
|
76
|
+
.reference::-webkit-scrollbar {
|
|
77
|
+
width: 4px;
|
|
78
|
+
}
|
|
79
|
+
.reference::-webkit-scrollbar-thumb {
|
|
80
|
+
background-color: #d1d1d1;
|
|
81
|
+
border-radius: 2px;
|
|
82
|
+
border: none;
|
|
83
|
+
}
|
|
84
|
+
.reference::-webkit-scrollbar-track {
|
|
85
|
+
background-color: transparent;
|
|
86
|
+
border: none;
|
|
87
|
+
}
|
|
88
|
+
.reference .references {
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-wrap: wrap;
|
|
91
|
+
align-items: center;
|
|
92
|
+
padding-top: 5px;
|
|
51
93
|
}
|
|
@@ -7,7 +7,7 @@ import ReactDOM from 'react-dom';
|
|
|
7
7
|
import styles from "./index.module.css";
|
|
8
8
|
import { FileCard } from ".";
|
|
9
9
|
var FileCardSideBar = function FileCardSideBar(props) {
|
|
10
|
-
var
|
|
10
|
+
var sidebarTargetElm = props.sidebarTargetElm,
|
|
11
11
|
isOverFlow = props.isOverFlow,
|
|
12
12
|
className = props.className,
|
|
13
13
|
style = props.style;
|
|
@@ -48,7 +48,7 @@ var FileCardSideBar = function FileCardSideBar(props) {
|
|
|
48
48
|
})));
|
|
49
49
|
};
|
|
50
50
|
if (isOverFlow) {
|
|
51
|
-
var targetElm =
|
|
51
|
+
var targetElm = sidebarTargetElm || document.getElementById('myun_gimi_design_chat');
|
|
52
52
|
if (!targetElm) return null;
|
|
53
53
|
return /*#__PURE__*/ReactDOM.createPortal(renderContent(), targetElm);
|
|
54
54
|
}
|
|
@@ -18,7 +18,7 @@ import AiLoading from "../ai-loading";
|
|
|
18
18
|
import ReactDOM from 'react-dom';
|
|
19
19
|
import GimiSideBar from "../gimi-sidebar";
|
|
20
20
|
var KonwledgeTrace = function KonwledgeTrace(_ref) {
|
|
21
|
-
var
|
|
21
|
+
var sidebarTargetElm = _ref.sidebarTargetElm,
|
|
22
22
|
chatList = _ref.chatList,
|
|
23
23
|
isOverFlow = _ref.isOverFlow,
|
|
24
24
|
className = _ref.className,
|
|
@@ -146,7 +146,7 @@ var KonwledgeTrace = function KonwledgeTrace(_ref) {
|
|
|
146
146
|
})) : tabContent));
|
|
147
147
|
};
|
|
148
148
|
if (isOverFlow && (kowledgeTraceList === null || kowledgeTraceList === void 0 ? void 0 : kowledgeTraceList.length) > 0) {
|
|
149
|
-
var targetElm =
|
|
149
|
+
var targetElm = sidebarTargetElm || document.getElementById('myun_gimi_design_chat');
|
|
150
150
|
if (!targetElm) return null;
|
|
151
151
|
return /*#__PURE__*/ReactDOM.createPortal(renderContent(), targetElm);
|
|
152
152
|
}
|
|
@@ -14,7 +14,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
14
14
|
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; }
|
|
15
15
|
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; } }
|
|
16
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
-
import { Input, Toast, Table, Popover,
|
|
17
|
+
import { Input, Toast, Table, Popover, Tooltip } from '@douyinfe/semi-ui';
|
|
18
18
|
import styles from "./index.module.css";
|
|
19
19
|
import { useCallback, useRef, useState } from 'react';
|
|
20
20
|
import IconFontCom from "../iconfont-com";
|
|
@@ -32,8 +32,8 @@ var tabList = [{
|
|
|
32
32
|
}
|
|
33
33
|
// { key: 'course', displayName: '课程' },
|
|
34
34
|
];
|
|
35
|
-
var quotoIcon = 'https://simg01.gaodunwangxiao.com/
|
|
36
|
-
var isActiveQuotoIcon = 'https://simg01.gaodunwangxiao.com/
|
|
35
|
+
var quotoIcon = 'https://simg01.gaodunwangxiao.com/uploadimgs/tmp/upload/202601/30/be6d9_20260130135139.png';
|
|
36
|
+
var isActiveQuotoIcon = 'https://simg01.gaodunwangxiao.com/uploadimgs/tmp/upload/202601/30/8e64c_20260130135037.png';
|
|
37
37
|
var QuotedContent = function QuotedContent() {
|
|
38
38
|
var _useState = useState('video'),
|
|
39
39
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -74,6 +74,7 @@ var QuotedContent = function QuotedContent() {
|
|
|
74
74
|
title: '名称',
|
|
75
75
|
dataIndex: 'name',
|
|
76
76
|
key: 'name',
|
|
77
|
+
width: '100%',
|
|
77
78
|
render: function render(text) {
|
|
78
79
|
return /*#__PURE__*/React.createElement("span", {
|
|
79
80
|
className: styles.listItem
|
|
@@ -82,7 +83,8 @@ var QuotedContent = function QuotedContent() {
|
|
|
82
83
|
className: styles.img,
|
|
83
84
|
src: activeKey === 'video' ? knowledgeConstants.VIDEO_ICON_ADDRESS : knowledgeConstants.CLASS_ICON_BIG_ADDRESS
|
|
84
85
|
}), /*#__PURE__*/React.createElement("span", {
|
|
85
|
-
className: styles.text
|
|
86
|
+
className: styles.text,
|
|
87
|
+
title: text
|
|
86
88
|
}, text));
|
|
87
89
|
}
|
|
88
90
|
}];
|
|
@@ -206,12 +208,8 @@ var QuotedContent = function QuotedContent() {
|
|
|
206
208
|
return /*#__PURE__*/React.createElement("div", {
|
|
207
209
|
style: {
|
|
208
210
|
padding: 12,
|
|
209
|
-
width:
|
|
210
|
-
|
|
211
|
-
}, /*#__PURE__*/React.createElement(Space, {
|
|
212
|
-
style: {
|
|
213
|
-
width: '100%',
|
|
214
|
-
height: '100%'
|
|
211
|
+
width: 380,
|
|
212
|
+
position: 'relative'
|
|
215
213
|
}
|
|
216
214
|
}, /*#__PURE__*/React.createElement("div", {
|
|
217
215
|
className: styles.quotedContent
|
|
@@ -260,22 +258,28 @@ var QuotedContent = function QuotedContent() {
|
|
|
260
258
|
}
|
|
261
259
|
};
|
|
262
260
|
}
|
|
263
|
-
})))))
|
|
261
|
+
})))));
|
|
264
262
|
};
|
|
265
263
|
return /*#__PURE__*/React.createElement(Popover, {
|
|
266
264
|
visible: showmodel,
|
|
267
265
|
content: renderContent,
|
|
268
266
|
trigger: "custom",
|
|
269
267
|
stopPropagation: true,
|
|
270
|
-
onClickOutSide: handleClose
|
|
268
|
+
onClickOutSide: handleClose,
|
|
269
|
+
position: "bottomLeft",
|
|
270
|
+
spacing: 6
|
|
271
271
|
}, /*#__PURE__*/React.createElement("div", {
|
|
272
272
|
className: "".concat(styles.quotationIcon, " ").concat(showmodel && styles.isActive),
|
|
273
273
|
onClick: function onClick() {
|
|
274
274
|
return setShowmodel(true);
|
|
275
275
|
}
|
|
276
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
277
|
+
content: "\u5F15\u7528\u8BFE\u7A0B",
|
|
278
|
+
position: "top",
|
|
279
|
+
visible: showmodel ? false : undefined
|
|
276
280
|
}, /*#__PURE__*/React.createElement("img", {
|
|
277
281
|
src: showmodel ? isActiveQuotoIcon : quotoIcon,
|
|
278
282
|
alt: ""
|
|
279
|
-
})));
|
|
283
|
+
}))));
|
|
280
284
|
};
|
|
281
285
|
export default QuotedContent;
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: column;
|
|
6
6
|
height: 100%;
|
|
7
|
+
width: 100%;
|
|
8
|
+
overflow: hidden;
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
.searchInput {
|
|
@@ -11,6 +13,7 @@
|
|
|
11
13
|
font-size: 12px;
|
|
12
14
|
padding: 0 10px;
|
|
13
15
|
border-radius: 8px;
|
|
16
|
+
width: 100%;
|
|
14
17
|
}
|
|
15
18
|
.searchInput input::placeholder {
|
|
16
19
|
color: #7d91b3;
|
|
@@ -18,18 +21,25 @@
|
|
|
18
21
|
|
|
19
22
|
.content {
|
|
20
23
|
padding-top: 10px;
|
|
24
|
+
width: 100%;
|
|
25
|
+
overflow: hidden;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
.newtab {
|
|
24
29
|
padding-bottom: 10px;
|
|
30
|
+
width: 100%;
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-wrap: nowrap;
|
|
33
|
+
overflow-x: auto;
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
.tabItem {
|
|
28
37
|
font-size: 14px;
|
|
29
38
|
padding: 5px 10px;
|
|
30
|
-
margin:
|
|
39
|
+
margin-right: 16px;
|
|
31
40
|
border-radius: 8px;
|
|
32
41
|
cursor: pointer;
|
|
42
|
+
flex-shrink: 0;
|
|
33
43
|
}
|
|
34
44
|
.tabItem:hover {
|
|
35
45
|
background-color: #f7f7fc;
|
|
@@ -45,29 +55,35 @@
|
|
|
45
55
|
.tabContent {
|
|
46
56
|
overflow: auto;
|
|
47
57
|
height: 200px;
|
|
58
|
+
width: 100%;
|
|
48
59
|
}
|
|
49
60
|
.tabContent .table {
|
|
50
61
|
table-layout: fixed;
|
|
51
|
-
|
|
52
|
-
.tabContent .table :global(.semi-table-row-cell) span {
|
|
53
|
-
width: 270px;
|
|
62
|
+
width: 100%;
|
|
54
63
|
}
|
|
55
64
|
.tabContent .table :global(.semi-table-row-cell) {
|
|
56
65
|
font-size: 12px;
|
|
57
66
|
border: none !important;
|
|
58
|
-
|
|
67
|
+
padding: 8px 0;
|
|
59
68
|
overflow: hidden;
|
|
60
69
|
text-overflow: ellipsis;
|
|
70
|
+
white-space: nowrap;
|
|
71
|
+
max-width: 0;
|
|
72
|
+
}
|
|
73
|
+
.tabContent .table :global(.semi-table-tbody .semi-table-row) {
|
|
74
|
+
width: 100%;
|
|
61
75
|
}
|
|
62
76
|
.tabContent .table .listItem {
|
|
63
77
|
display: flex;
|
|
64
78
|
align-items: center;
|
|
65
79
|
cursor: pointer;
|
|
66
80
|
width: 100%;
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
min-width: 0;
|
|
67
83
|
}
|
|
68
84
|
.tabContent .table .listItem .img {
|
|
69
85
|
width: 16px;
|
|
70
|
-
margin-right:
|
|
86
|
+
margin-right: 8px;
|
|
71
87
|
flex-shrink: 0;
|
|
72
88
|
}
|
|
73
89
|
.tabContent .table .listItem .text {
|
|
@@ -75,6 +91,7 @@
|
|
|
75
91
|
overflow: hidden;
|
|
76
92
|
text-overflow: ellipsis;
|
|
77
93
|
white-space: nowrap;
|
|
94
|
+
min-width: 0;
|
|
78
95
|
}
|
|
79
96
|
|
|
80
97
|
.tabContent::-webkit-scrollbar {
|
|
@@ -2,7 +2,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { store } from "../../store";
|
|
4
4
|
import { useAppDispatch, useAppSelector } from "../../store/hooks";
|
|
5
|
-
import { setBaseUrl, setToken, setPlatform, setConversationId, setAgentDetail, setBussinessParams } from "../../store/slices/gimiMenuSlice";
|
|
5
|
+
import { setBaseUrl, setToken, setPlatform, setConversationId, setAgentDetail, setBussinessParams, setQuoteTeachModelList } from "../../store/slices/gimiMenuSlice";
|
|
6
6
|
import useCommonChatAPI from "../../hooks/useCommonChatAPI";
|
|
7
7
|
import { replaceBraces } from "../../utils/tools";
|
|
8
8
|
import styles from "./index.module.css";
|
|
@@ -130,6 +130,14 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
130
130
|
React.useEffect(function () {
|
|
131
131
|
dispatch(setBussinessParams(bussinessParams || {}));
|
|
132
132
|
}, [bussinessParams, dispatch]);
|
|
133
|
+
React.useEffect(function () {
|
|
134
|
+
var _props$initQuoteSourc;
|
|
135
|
+
if ((_props$initQuoteSourc = props.initQuoteSource) !== null && _props$initQuoteSourc !== void 0 && _props$initQuoteSourc.teachModelId) {
|
|
136
|
+
dispatch(setQuoteTeachModelList({
|
|
137
|
+
quoteTeachModelList: [props.initQuoteSource]
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
}, [props.initQuoteSource, dispatch]);
|
|
133
141
|
var disableVoiceCommunication = React.useMemo(function () {
|
|
134
142
|
var lastedMessage = messageList[messageList.length - 1];
|
|
135
143
|
var content = (lastedMessage === null || lastedMessage === void 0 ? void 0 : lastedMessage.content) || '';
|
|
@@ -158,7 +158,8 @@ export var useChatStream = function useChatStream(platform) {
|
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
160
|
} else if (_dataObj.ERROR || _dataObj.moduleType === 'FAILED') {
|
|
161
|
-
|
|
161
|
+
var errorMessage = '内容过大,请精简后开启新对话';
|
|
162
|
+
Toast.error(_dataObj.ERROR === errorMessage ? errorMessage : '服务异常');
|
|
162
163
|
onErrorComplete === null || onErrorComplete === void 0 || onErrorComplete();
|
|
163
164
|
return;
|
|
164
165
|
} else if (data.status && data.status !== 0 && !_dataObj.ERROR) {
|
|
@@ -796,39 +796,38 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
796
796
|
isSystemAuto = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : false;
|
|
797
797
|
conversationId = _args9.length > 3 ? _args9[3] : undefined;
|
|
798
798
|
value = val.trim();
|
|
799
|
-
console.log('initAttachments', initAttachments);
|
|
800
799
|
if (!(!value && !isSystemAuto)) {
|
|
801
|
-
_context9.next =
|
|
800
|
+
_context9.next = 6;
|
|
802
801
|
break;
|
|
803
802
|
}
|
|
804
803
|
return _context9.abrupt("return");
|
|
805
|
-
case
|
|
804
|
+
case 6:
|
|
806
805
|
if (navigator.onLine) {
|
|
807
|
-
_context9.next =
|
|
806
|
+
_context9.next = 9;
|
|
808
807
|
break;
|
|
809
808
|
}
|
|
810
809
|
Toast.error('无法连接到网络');
|
|
811
810
|
return _context9.abrupt("return");
|
|
812
|
-
case
|
|
813
|
-
if (!(status === 2 ||
|
|
814
|
-
_context9.next =
|
|
811
|
+
case 9:
|
|
812
|
+
if (!(status === 2 || msgLoading)) {
|
|
813
|
+
_context9.next = 12;
|
|
815
814
|
break;
|
|
816
815
|
}
|
|
817
816
|
Toast.error('AI正在输出中,请稍后');
|
|
818
817
|
return _context9.abrupt("return");
|
|
819
|
-
case
|
|
818
|
+
case 12:
|
|
820
819
|
chatInputConfig === null || chatInputConfig === void 0 || (_chatInputConfig$onBe = chatInputConfig.onBeforeSend) === null || _chatInputConfig$onBe === void 0 || _chatInputConfig$onBe.call(chatInputConfig, value);
|
|
821
820
|
|
|
822
821
|
// 设置inputModel
|
|
823
822
|
fillInputModel(value, messageListRef.current);
|
|
824
823
|
fileValidationMsg = fileValidation(fileListRef.current);
|
|
825
824
|
if (!fileValidationMsg) {
|
|
826
|
-
_context9.next =
|
|
825
|
+
_context9.next = 18;
|
|
827
826
|
break;
|
|
828
827
|
}
|
|
829
828
|
Toast.error(fileValidationMsg);
|
|
830
829
|
return _context9.abrupt("return");
|
|
831
|
-
case
|
|
830
|
+
case 18:
|
|
832
831
|
if (isPlaying) {
|
|
833
832
|
// 点击发送按钮时,先停止播放
|
|
834
833
|
stopTTSByText === null || stopTTSByText === void 0 || stopTTSByText();
|
|
@@ -860,7 +859,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
860
859
|
// 系统自动上传,直接开始会话,不更新列表
|
|
861
860
|
startChat([].concat(_toConsumableArray(prevChatList), [userChat]), isSystemAuto, conversationId);
|
|
862
861
|
}
|
|
863
|
-
case
|
|
862
|
+
case 25:
|
|
864
863
|
case "end":
|
|
865
864
|
return _context9.stop();
|
|
866
865
|
}
|
package/dist/types/chat.d.ts
CHANGED
|
@@ -115,6 +115,12 @@ export interface CommonChatProps {
|
|
|
115
115
|
showHeader?: boolean;
|
|
116
116
|
initSendValue?: string;
|
|
117
117
|
initAttachments?: FileItem[];
|
|
118
|
+
initQuoteSource?: {
|
|
119
|
+
teachModelId: number;
|
|
120
|
+
teachModelName: string;
|
|
121
|
+
type?: string;
|
|
122
|
+
duration: number;
|
|
123
|
+
};
|
|
118
124
|
chatInputConfig?: IAIInputProps;
|
|
119
125
|
platform?: 'myun' | 'preview' | 'damai';
|
|
120
126
|
businessType: 'correction' | 'chat';
|