@myun/gimi-chat 0.9.8 → 0.9.10
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/client/core/index.css +1 -0
- package/dist/components/excel-components/index.module.css +0 -1
- package/dist/components/file-card/index.module.css +0 -1
- package/dist/components/knowledge-trace/KnowledgeIconComponent.js +77 -5
- package/dist/components/knowledge-trace/classList.d.ts +1 -0
- package/dist/components/knowledge-trace/classList.js +4 -2
- package/dist/components/knowledge-trace/documentList.d.ts +1 -0
- package/dist/components/knowledge-trace/documentList.js +4 -2
- package/dist/components/knowledge-trace/index.module.css +26 -2
- package/dist/components/knowledge-trace/videoList.d.ts +1 -0
- package/dist/components/knowledge-trace/videoList.js +4 -2
- package/dist/components/reasoning-search/index.d.ts +1 -1
- package/dist/hooks/useCommonChatAPI.js +18 -10
- package/dist/hooks/useKnowledgeService.d.ts +4 -1
- package/dist/hooks/useKnowledgeService.js +70 -35
- package/dist/i18n/GimiChatI18nProvider.js +1 -1
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
2
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
3
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
4
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
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
|
+
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
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
11
|
import styles from "./index.module.css";
|
|
8
12
|
import { knowledgeConstants } from "../../constants";
|
|
9
13
|
import { useAppDispatch, useAppSelector } from "../../store/hooks";
|
|
10
14
|
import { openSidebar } from "../../store/slices/gimiMenuSlice";
|
|
11
|
-
import React from 'react';
|
|
15
|
+
import React, { useMemo, useState } from 'react';
|
|
12
16
|
import { useTranslation } from 'react-i18next';
|
|
17
|
+
import { Popover } from '@douyinfe/semi-ui';
|
|
18
|
+
import useKnowledgeService from "../../hooks/useKnowledgeService";
|
|
19
|
+
import VideoList from "./videoList";
|
|
20
|
+
import ClassList from "./classList";
|
|
21
|
+
import DocumentList from "./documentList";
|
|
22
|
+
import AiLoading from "../ai-loading";
|
|
23
|
+
var Empty = function Empty() {
|
|
24
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
style: {
|
|
26
|
+
marginTop: '180px',
|
|
27
|
+
textAlign: 'center'
|
|
28
|
+
}
|
|
29
|
+
}, "\u6682\u65E0\u6570\u636E");
|
|
30
|
+
};
|
|
13
31
|
var KnowledgeIcon = function KnowledgeIcon(_ref) {
|
|
14
32
|
var url = _ref.url;
|
|
15
33
|
var _useTranslation = useTranslation(),
|
|
@@ -27,6 +45,10 @@ export var KnowledgeIconComponent = function KnowledgeIconComponent(_ref2) {
|
|
|
27
45
|
var type = _ref2.type,
|
|
28
46
|
resources = _ref2.resources,
|
|
29
47
|
messageId = _ref2.messageId;
|
|
48
|
+
var _useState = useState(false),
|
|
49
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
50
|
+
showPanel = _useState2[0],
|
|
51
|
+
setShowPanel = _useState2[1];
|
|
30
52
|
var _useTranslation2 = useTranslation(),
|
|
31
53
|
t = _useTranslation2.t;
|
|
32
54
|
var dispatch = useAppDispatch();
|
|
@@ -40,7 +62,50 @@ export var KnowledgeIconComponent = function KnowledgeIconComponent(_ref2) {
|
|
|
40
62
|
});
|
|
41
63
|
var isLastMessage = lastMessageId !== undefined && lastMessageId === messageId;
|
|
42
64
|
var iconUrl = type === 'video' ? knowledgeConstants.VIDEO_ICON_KNOWLADGE_TRACE_ADDRESS : type === 'document' ? knowledgeConstants.DOCUMENT_ICON_ADDRESS : knowledgeConstants.CLASS_ICON_ADDRESS;
|
|
65
|
+
var kowledgeTrace = {
|
|
66
|
+
type: type,
|
|
67
|
+
resources: resources || []
|
|
68
|
+
};
|
|
69
|
+
var _useKnowledgeService = useKnowledgeService({
|
|
70
|
+
showPanel: showPanel,
|
|
71
|
+
kowledgeTrace: [kowledgeTrace]
|
|
72
|
+
}),
|
|
73
|
+
videoSliceList = _useKnowledgeService.videoSliceList,
|
|
74
|
+
documentList = _useKnowledgeService.documentList,
|
|
75
|
+
productList = _useKnowledgeService.productList,
|
|
76
|
+
isLoading = _useKnowledgeService.isLoading;
|
|
77
|
+
var hoverPanelContent = useMemo(function () {
|
|
78
|
+
if (isLoading) return /*#__PURE__*/React.createElement("div", {
|
|
79
|
+
style: {
|
|
80
|
+
marginTop: "100px"
|
|
81
|
+
}
|
|
82
|
+
}, /*#__PURE__*/React.createElement(AiLoading, null));
|
|
83
|
+
switch (type) {
|
|
84
|
+
case 'video':
|
|
85
|
+
return videoSliceList !== null && videoSliceList !== void 0 && videoSliceList.length ? /*#__PURE__*/React.createElement(VideoList, {
|
|
86
|
+
list: videoSliceList,
|
|
87
|
+
hiddenTitle: true
|
|
88
|
+
}) : /*#__PURE__*/React.createElement(Empty, null);
|
|
89
|
+
case 'product':
|
|
90
|
+
return productList !== null && productList !== void 0 && productList.length ? /*#__PURE__*/React.createElement(ClassList, {
|
|
91
|
+
list: productList,
|
|
92
|
+
hiddenTitle: true
|
|
93
|
+
}) : /*#__PURE__*/React.createElement(Empty, null);
|
|
94
|
+
case 'document':
|
|
95
|
+
return documentList !== null && documentList !== void 0 && documentList.length ? /*#__PURE__*/React.createElement(DocumentList, {
|
|
96
|
+
list: documentList,
|
|
97
|
+
hiddenTitle: true
|
|
98
|
+
}) : /*#__PURE__*/React.createElement(Empty, null);
|
|
99
|
+
default:
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}, [showPanel, videoSliceList, productList, documentList, isLoading]);
|
|
103
|
+
var onVisibleChange = React.useCallback(function (visible) {
|
|
104
|
+
setShowPanel(visible);
|
|
105
|
+
}, []);
|
|
43
106
|
var handleIconClick = React.useCallback(function () {
|
|
107
|
+
// 先不要了
|
|
108
|
+
return;
|
|
44
109
|
if (isMsgRecieving && isLastMessage) return; // 最新一条正在流式输出的消息,不打开溯源面板
|
|
45
110
|
dispatch(openSidebar({
|
|
46
111
|
type: 'knowledgeTrace',
|
|
@@ -53,7 +118,13 @@ export var KnowledgeIconComponent = function KnowledgeIconComponent(_ref2) {
|
|
|
53
118
|
}
|
|
54
119
|
}));
|
|
55
120
|
}, [isMsgRecieving, isLastMessage, dispatch, messageId, resources, type]);
|
|
56
|
-
return /*#__PURE__*/React.createElement(
|
|
121
|
+
return /*#__PURE__*/React.createElement(Popover, {
|
|
122
|
+
content: /*#__PURE__*/React.createElement(React.Fragment, null, hoverPanelContent),
|
|
123
|
+
visible: showPanel,
|
|
124
|
+
onVisibleChange: onVisibleChange,
|
|
125
|
+
className: "knowledgeHoverPanel",
|
|
126
|
+
position: "bottomLeft"
|
|
127
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
57
128
|
className: styles.icon_btn,
|
|
58
129
|
onClick: handleIconClick
|
|
59
130
|
}, /*#__PURE__*/React.createElement(KnowledgeIcon, {
|
|
@@ -61,15 +132,16 @@ export var KnowledgeIconComponent = function KnowledgeIconComponent(_ref2) {
|
|
|
61
132
|
}), /*#__PURE__*/React.createElement("span", null, t('trace.countByType', {
|
|
62
133
|
count: resources === null || resources === void 0 ? void 0 : resources.length,
|
|
63
134
|
type: type === 'video' ? t('knowledgeTrace.type.video') : type === 'product' ? t('knowledgeTrace.type.course') : t('knowledgeTrace.type.document')
|
|
64
|
-
})));
|
|
135
|
+
}))));
|
|
65
136
|
};
|
|
66
137
|
var KnowledgeIconGroup = function KnowledgeIconGroup(_ref3) {
|
|
67
138
|
var content = _ref3.content,
|
|
68
139
|
messageId = _ref3.messageId;
|
|
140
|
+
var parseArr = [];
|
|
69
141
|
var knowledgeMap = React.useMemo(function () {
|
|
70
142
|
var returnMap = new Map();
|
|
71
143
|
try {
|
|
72
|
-
|
|
144
|
+
parseArr = JSON.parse(content);
|
|
73
145
|
if (!Array.isArray(parseArr)) return returnMap;
|
|
74
146
|
parseArr.forEach(function (item) {
|
|
75
147
|
var orgArr = returnMap.get(item.type) || [];
|
|
@@ -60,12 +60,14 @@ var ClassItem = function ClassItem(_ref) {
|
|
|
60
60
|
}, t('trace.course.invalid'))));
|
|
61
61
|
};
|
|
62
62
|
var ClassList = function ClassList(_ref2) {
|
|
63
|
-
var list = _ref2.list
|
|
63
|
+
var list = _ref2.list,
|
|
64
|
+
_ref2$hiddenTitle = _ref2.hiddenTitle,
|
|
65
|
+
hiddenTitle = _ref2$hiddenTitle === void 0 ? false : _ref2$hiddenTitle;
|
|
64
66
|
var _useTranslation2 = useTranslation(),
|
|
65
67
|
t = _useTranslation2.t;
|
|
66
68
|
return /*#__PURE__*/React.createElement("div", {
|
|
67
69
|
className: styles.knowledgeList
|
|
68
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
70
|
+
}, !hiddenTitle && /*#__PURE__*/React.createElement("span", {
|
|
69
71
|
className: styles.total
|
|
70
72
|
}, t('trace.course.total', {
|
|
71
73
|
count: (list === null || list === void 0 ? void 0 : list.length) || 0
|
|
@@ -63,12 +63,14 @@ var FileItem = function FileItem(_ref) {
|
|
|
63
63
|
}, t('trace.document.invalid'))));
|
|
64
64
|
};
|
|
65
65
|
var DocumentList = function DocumentList(_ref2) {
|
|
66
|
-
var list = _ref2.list
|
|
66
|
+
var list = _ref2.list,
|
|
67
|
+
_ref2$hiddenTitle = _ref2.hiddenTitle,
|
|
68
|
+
hiddenTitle = _ref2$hiddenTitle === void 0 ? false : _ref2$hiddenTitle;
|
|
67
69
|
var _useTranslation2 = useTranslation(),
|
|
68
70
|
t = _useTranslation2.t;
|
|
69
71
|
return /*#__PURE__*/React.createElement("div", {
|
|
70
72
|
className: styles.knowledgeList
|
|
71
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
73
|
+
}, !hiddenTitle && /*#__PURE__*/React.createElement("span", {
|
|
72
74
|
className: styles.total
|
|
73
75
|
}, t('trace.document.total', {
|
|
74
76
|
count: (list === null || list === void 0 ? void 0 : list.length) || 0
|
|
@@ -78,12 +78,12 @@
|
|
|
78
78
|
z-index: 2;
|
|
79
79
|
}
|
|
80
80
|
.knowledgeList .knowledge {
|
|
81
|
-
background-color: #
|
|
81
|
+
background-color: #F7F9FC;
|
|
82
82
|
border-radius: 12px;
|
|
83
83
|
display: flex;
|
|
84
84
|
align-items: center;
|
|
85
85
|
gap: 10px;
|
|
86
|
-
padding: 10px;
|
|
86
|
+
padding: 10px 16px;
|
|
87
87
|
position: relative;
|
|
88
88
|
}
|
|
89
89
|
.knowledgeList .knowledge:hover {
|
|
@@ -257,4 +257,28 @@
|
|
|
257
257
|
.icon_btn_active {
|
|
258
258
|
background-color: #4086ff;
|
|
259
259
|
color: #ffffff;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
:global(.knowledgeHoverPanel) {
|
|
263
|
+
position: relative;
|
|
264
|
+
overflow-y: auto;
|
|
265
|
+
width: 360px;
|
|
266
|
+
height: 388px;
|
|
267
|
+
padding: 16px 12px 0px 12px;
|
|
268
|
+
border-radius: 16px;
|
|
269
|
+
border: 1px solid #E9EBF2;
|
|
270
|
+
background: #FFF;
|
|
271
|
+
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
|
|
272
|
+
z-index: 2;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
:global(.bottomMask) {
|
|
276
|
+
position: sticky;
|
|
277
|
+
bottom: 0;
|
|
278
|
+
margin: -66px -12px 0;
|
|
279
|
+
height: 66px;
|
|
280
|
+
border-radius: 0 0 16px 16px;
|
|
281
|
+
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.5) 20.67%, rgba(255, 255, 255, 0.9) 52.4%, #FFF 100%);
|
|
282
|
+
pointer-events: none;
|
|
283
|
+
z-index: 1;
|
|
260
284
|
}
|
|
@@ -78,12 +78,14 @@ var VideoItem = function VideoItem(_ref) {
|
|
|
78
78
|
};
|
|
79
79
|
var VideoList = function VideoList(_ref2) {
|
|
80
80
|
var list = _ref2.list,
|
|
81
|
-
onCurrentTraceVideoClick = _ref2.onCurrentTraceVideoClick
|
|
81
|
+
onCurrentTraceVideoClick = _ref2.onCurrentTraceVideoClick,
|
|
82
|
+
_ref2$hiddenTitle = _ref2.hiddenTitle,
|
|
83
|
+
hiddenTitle = _ref2$hiddenTitle === void 0 ? false : _ref2$hiddenTitle;
|
|
82
84
|
var _useTranslation2 = useTranslation(),
|
|
83
85
|
t = _useTranslation2.t;
|
|
84
86
|
return /*#__PURE__*/React.createElement("div", {
|
|
85
87
|
className: styles.knowledgeList
|
|
86
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
88
|
+
}, !hiddenTitle && /*#__PURE__*/React.createElement("span", {
|
|
87
89
|
className: styles.total
|
|
88
90
|
}, t('trace.video.total', {
|
|
89
91
|
count: (list === null || list === void 0 ? void 0 : list.length) || 0
|
|
@@ -23,7 +23,7 @@ import React, { useRef } from 'react';
|
|
|
23
23
|
import { useTranslation } from 'react-i18next';
|
|
24
24
|
import { Toast } from "@douyinfe/semi-ui";
|
|
25
25
|
import { useAppDispatch, useAppSelector } from "../store/hooks";
|
|
26
|
-
import { setMessageList, setFileList, setConversationId, setAgentDetail, setAutoLoadConversation, updateState, closeSidebar } from "../store/slices/gimiMenuSlice";
|
|
26
|
+
import { setMessageList, setFileList, setConversationId, setAgentDetail, setBusinessParams, setAutoLoadConversation, updateState, closeSidebar } from "../store/slices/gimiMenuSlice";
|
|
27
27
|
import { fileValidation, parseMessageContent, processString } from "../utils/tools";
|
|
28
28
|
import { filterPropmptFromUserInput } from "../utils/tools";
|
|
29
29
|
import { useChatMessage } from "./useChatMessage";
|
|
@@ -993,7 +993,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
993
993
|
}, [conversationId, dispatch, clearQuotesFromRedux, streamEsAbortRef]);
|
|
994
994
|
var fetchAgentDetail = React.useCallback( /*#__PURE__*/function () {
|
|
995
995
|
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(agentId) {
|
|
996
|
-
var res;
|
|
996
|
+
var res, _res$result2, _businessParamsRef$cu;
|
|
997
997
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
998
998
|
while (1) switch (_context12.prev = _context12.next) {
|
|
999
999
|
case 0:
|
|
@@ -1003,29 +1003,37 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
1003
1003
|
case 3:
|
|
1004
1004
|
res = _context12.sent;
|
|
1005
1005
|
if (!(res.status === 0)) {
|
|
1006
|
-
_context12.next =
|
|
1006
|
+
_context12.next = 10;
|
|
1007
1007
|
break;
|
|
1008
1008
|
}
|
|
1009
1009
|
dispatch(setAgentDetail({
|
|
1010
1010
|
agentDetail: res.result
|
|
1011
1011
|
}));
|
|
1012
|
+
if (((_res$result2 = res.result) === null || _res$result2 === void 0 ? void 0 : _res$result2.businessType) === 7) {
|
|
1013
|
+
dispatch(setBusinessParams(_objectSpread(_objectSpread({}, businessParamsRef.current), {}, {
|
|
1014
|
+
sysInfo: {
|
|
1015
|
+
platform: businessParamsRef.current.platform,
|
|
1016
|
+
agencyId: (_businessParamsRef$cu = businessParamsRef.current) === null || _businessParamsRef$cu === void 0 ? void 0 : _businessParamsRef$cu.agencyId
|
|
1017
|
+
}
|
|
1018
|
+
})));
|
|
1019
|
+
}
|
|
1012
1020
|
return _context12.abrupt("return", res.result);
|
|
1013
|
-
case
|
|
1021
|
+
case 10:
|
|
1014
1022
|
Toast.error(res.message);
|
|
1015
1023
|
return _context12.abrupt("return", null);
|
|
1016
|
-
case
|
|
1017
|
-
_context12.next =
|
|
1024
|
+
case 12:
|
|
1025
|
+
_context12.next = 18;
|
|
1018
1026
|
break;
|
|
1019
|
-
case
|
|
1020
|
-
_context12.prev =
|
|
1027
|
+
case 14:
|
|
1028
|
+
_context12.prev = 14;
|
|
1021
1029
|
_context12.t0 = _context12["catch"](0);
|
|
1022
1030
|
console.log('error', _context12.t0);
|
|
1023
1031
|
return _context12.abrupt("return", null);
|
|
1024
|
-
case
|
|
1032
|
+
case 18:
|
|
1025
1033
|
case "end":
|
|
1026
1034
|
return _context12.stop();
|
|
1027
1035
|
}
|
|
1028
|
-
}, _callee12, null, [[0,
|
|
1036
|
+
}, _callee12, null, [[0, 14]]);
|
|
1029
1037
|
}));
|
|
1030
1038
|
return function (_x17) {
|
|
1031
1039
|
return _ref14.apply(this, arguments);
|
|
@@ -8,7 +8,10 @@ interface IProps {
|
|
|
8
8
|
}[];
|
|
9
9
|
qutoType?: 'teachModel' | 'product';
|
|
10
10
|
}
|
|
11
|
-
declare const useKnowledgeService: (props: IProps[]
|
|
11
|
+
declare const useKnowledgeService: (props: IProps[] | {
|
|
12
|
+
showPanel?: boolean;
|
|
13
|
+
kowledgeTrace?: IProps[];
|
|
14
|
+
}) => {
|
|
12
15
|
isLoading: boolean;
|
|
13
16
|
documentList: ITeachingModuleResource[];
|
|
14
17
|
videoSliceList: IVideoResource[];
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
2
6
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
7
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
8
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -166,43 +170,74 @@ var useKnowledgeService = function useKnowledgeService(props) {
|
|
|
166
170
|
return _ref4.apply(this, arguments);
|
|
167
171
|
};
|
|
168
172
|
}();
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
173
|
+
var init = /*#__PURE__*/function () {
|
|
174
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
175
|
+
var kowledgeTraceList, _props$kowledgeTrace, promiseList;
|
|
176
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
177
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
178
|
+
case 0:
|
|
179
|
+
kowledgeTraceList = [];
|
|
180
|
+
if (!Array.isArray(props)) {
|
|
181
|
+
_context4.next = 7;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
if (props !== null && props !== void 0 && props.length) {
|
|
185
|
+
_context4.next = 4;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
return _context4.abrupt("return");
|
|
189
|
+
case 4:
|
|
190
|
+
kowledgeTraceList.push.apply(kowledgeTraceList, _toConsumableArray(props));
|
|
191
|
+
_context4.next = 10;
|
|
192
|
+
break;
|
|
193
|
+
case 7:
|
|
194
|
+
if (!(!((_props$kowledgeTrace = props.kowledgeTrace) !== null && _props$kowledgeTrace !== void 0 && _props$kowledgeTrace.length) || !props.showPanel)) {
|
|
195
|
+
_context4.next = 9;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
return _context4.abrupt("return");
|
|
199
|
+
case 9:
|
|
200
|
+
kowledgeTraceList.push.apply(kowledgeTraceList, _toConsumableArray(props.kowledgeTrace || []));
|
|
201
|
+
case 10:
|
|
202
|
+
if (!(Array.isArray(props) && (props === null || props === void 0 ? void 0 : props.length) === 0)) {
|
|
188
203
|
_context4.next = 12;
|
|
189
204
|
break;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
}
|
|
206
|
+
return _context4.abrupt("return");
|
|
207
|
+
case 12:
|
|
208
|
+
setIsloading(true);
|
|
209
|
+
_context4.prev = 13;
|
|
210
|
+
promiseList = [];
|
|
211
|
+
kowledgeTraceList.forEach(function (item) {
|
|
212
|
+
var callFun = item.type === 'video' ? getVideos : item.type === 'document' ? getDocuments : getProducts;
|
|
213
|
+
promiseList.push(callFun(item));
|
|
214
|
+
});
|
|
215
|
+
_context4.next = 18;
|
|
216
|
+
return Promise.allSettled(promiseList);
|
|
217
|
+
case 18:
|
|
218
|
+
setIsloading(false);
|
|
219
|
+
_context4.next = 24;
|
|
220
|
+
break;
|
|
221
|
+
case 21:
|
|
222
|
+
_context4.prev = 21;
|
|
223
|
+
_context4.t0 = _context4["catch"](13);
|
|
224
|
+
console.error(_context4.t0);
|
|
225
|
+
case 24:
|
|
226
|
+
case "end":
|
|
227
|
+
return _context4.stop();
|
|
228
|
+
}
|
|
229
|
+
}, _callee4, null, [[13, 21]]);
|
|
230
|
+
}));
|
|
231
|
+
return function init() {
|
|
232
|
+
return _ref5.apply(this, arguments);
|
|
233
|
+
};
|
|
234
|
+
}();
|
|
235
|
+
React.useEffect(function () {
|
|
236
|
+
// if(Array.isArray(props) || props?.showPanel) {
|
|
237
|
+
// init();
|
|
238
|
+
// }
|
|
239
|
+
init();
|
|
240
|
+
}, [JSON.stringify(props)]);
|
|
206
241
|
return {
|
|
207
242
|
isLoading: isLoading,
|
|
208
243
|
documentList: documentList,
|
|
@@ -10,7 +10,7 @@ var GimiChatI18nProvider = function GimiChatI18nProvider(_ref) {
|
|
|
10
10
|
locale: locale,
|
|
11
11
|
messages: messages
|
|
12
12
|
});
|
|
13
|
-
}, [messages]);
|
|
13
|
+
}, [messages, locale]);
|
|
14
14
|
React.useEffect(function () {
|
|
15
15
|
var resources = createGimiChatResources(messages);
|
|
16
16
|
var nextLocale = resolveGimiChatLocale(locale, resources);
|