@myun/gimi-chat 0.0.3 → 0.0.4
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/apis/fetch.d.ts +64 -0
- package/dist/apis/fetch.js +512 -0
- package/dist/apis/useApi.d.ts +57 -0
- package/dist/apis/useApi.js +378 -0
- package/dist/assets/image/Subtract.png +0 -0
- package/dist/assets/image/ai-logo.png +0 -0
- package/dist/assets/image/copyIcon.png +0 -0
- package/dist/assets/image/deepthinkActive.png +0 -0
- package/dist/assets/image/empty-img-dark.png +0 -0
- package/dist/assets/image/empty-img.png +0 -0
- package/dist/assets/image/like_active.png +0 -0
- package/dist/assets/image/love.png +0 -0
- package/dist/assets/image/retry.png +0 -0
- package/dist/assets/image/soundOut.png +0 -0
- package/dist/assets/image/unlike_active.png +0 -0
- package/dist/assets/image/unlove.png +0 -0
- package/dist/assets/lottie/ai-bg.json +1704 -0
- package/dist/assets/lottie/ai-loading.json +192 -0
- package/dist/assets/lottie/ai-output-loading.json +272 -0
- package/dist/assets/lottie/ai-output-normal.json +17694 -0
- package/dist/assets/lottie/ai-output-strengthen.json +17321 -0
- package/dist/assets/lottie/ai-voice-play.json +1 -0
- package/dist/assets/lottie/living.json +705 -0
- package/dist/assets/lottie/myun-living.json +726 -0
- package/dist/assets/lottie/myun-loading.json +530 -0
- package/dist/components/ai-chat-dialogue/index.d.ts +16 -0
- package/dist/components/ai-chat-dialogue/index.js +1056 -0
- package/dist/components/ai-chat-dialogue/index.module.scss +272 -0
- package/dist/components/ai-chat-dialogue/message-parser.d.ts +36 -0
- package/dist/components/ai-chat-dialogue/message-parser.js +52 -0
- package/dist/components/ai-chat-dialogue/tlv.d.ts +7 -0
- package/dist/components/ai-chat-dialogue/tlv.js +32 -0
- package/dist/components/ai-chat-dialogue/volc-voice-call-client.d.ts +47 -0
- package/dist/components/ai-chat-dialogue/volc-voice-call-client.js +246 -0
- package/dist/components/ai-correction/index.d.ts +5 -0
- package/dist/components/ai-correction/index.js +45 -0
- package/dist/components/ai-loading/index.d.ts +3 -0
- package/dist/components/ai-loading/index.js +14 -0
- package/dist/components/ai-loading/index.module.scss +11 -0
- package/dist/components/answer-item/index.d.ts +27 -0
- package/dist/components/answer-item/index.js +194 -0
- package/dist/components/answer-item/index.module.scss +295 -0
- package/dist/components/ask-card/index.d.ts +10 -0
- package/dist/components/ask-card/index.js +76 -0
- package/dist/components/ask-card/index.module.scss +125 -0
- package/dist/components/chat-input/index.d.ts +31 -0
- package/dist/components/chat-input/index.js +433 -0
- package/dist/components/chat-input/index.module.scss +44 -0
- package/dist/components/chat-voice/VoiceCommunication.d.ts +7 -0
- package/dist/components/chat-voice/VoiceCommunication.js +69 -0
- package/dist/components/chat-voice/VoiceRecord.d.ts +7 -0
- package/dist/components/chat-voice/VoiceRecord.js +34 -0
- package/dist/components/conversation-delete/index.d.ts +5 -0
- package/dist/components/conversation-delete/index.js +24 -0
- package/dist/components/dots-loading/index.d.ts +2 -0
- package/dist/components/dots-loading/index.js +11 -0
- package/dist/components/dots-loading/index.module.scss +45 -0
- package/dist/components/empty/index.d.ts +9 -0
- package/dist/components/empty/index.js +32 -0
- package/dist/components/empty/index.module.scss +27 -0
- package/dist/components/excel-components/ExcelCard.d.ts +11 -0
- package/dist/components/excel-components/ExcelCard.js +35 -0
- package/dist/components/excel-components/ExcelExcuting.d.ts +10 -0
- package/dist/components/excel-components/ExcelExcuting.js +263 -0
- package/dist/components/excel-components/ExcelFailCard.d.ts +9 -0
- package/dist/components/excel-components/ExcelFailCard.js +20 -0
- package/dist/components/excel-components/ExcelSuccessCard.d.ts +5 -0
- package/dist/components/excel-components/ExcelSuccessCard.js +50 -0
- package/dist/components/excel-components/index.module.scss +210 -0
- package/dist/components/excel-components/styles.module.scss +186 -0
- package/dist/components/file-card/fileCardSidebar.d.ts +8 -0
- package/dist/components/file-card/fileCardSidebar.js +56 -0
- package/dist/components/file-card/index.d.ts +15 -0
- package/dist/components/file-card/index.js +97 -0
- package/dist/components/file-card/index.module.scss +139 -0
- package/dist/components/file-preview/index.d.ts +3 -0
- package/dist/components/file-preview/index.js +229 -0
- package/dist/components/file-preview/index.module.scss +120 -0
- package/dist/components/file-upload/index.d.ts +16 -0
- package/dist/components/file-upload/index.js +238 -0
- package/dist/components/file-upload/uploadV1.d.ts +16 -0
- package/dist/components/file-upload/uploadV1.js +267 -0
- package/dist/components/gimi-sidebar/index.d.ts +17 -0
- package/dist/components/gimi-sidebar/index.js +41 -0
- package/dist/components/gimi-sidebar/index.module.scss +136 -0
- package/dist/components/header/index.d.ts +5 -0
- package/dist/components/header/index.js +20 -0
- package/dist/components/header/index.module.scss +26 -0
- package/dist/components/iconfont-com/index.d.ts +11 -0
- package/dist/components/iconfont-com/index.js +29 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/knowledge-trace/KnowledgeIconComponent.d.ts +7 -0
- package/dist/components/knowledge-trace/KnowledgeIconComponent.js +101 -0
- package/dist/components/knowledge-trace/classList.d.ts +6 -0
- package/dist/components/knowledge-trace/classList.js +72 -0
- package/dist/components/knowledge-trace/documentList.d.ts +6 -0
- package/dist/components/knowledge-trace/documentList.js +75 -0
- package/dist/components/knowledge-trace/index.d.ts +18 -0
- package/dist/components/knowledge-trace/index.js +155 -0
- package/dist/components/knowledge-trace/index.module.scss +262 -0
- package/dist/components/knowledge-trace/interfaces.d.ts +166 -0
- package/dist/components/knowledge-trace/interfaces.js +1 -0
- package/dist/components/knowledge-trace/videoList.d.ts +6 -0
- package/dist/components/knowledge-trace/videoList.js +91 -0
- package/dist/components/lottie-img/index.d.ts +8 -0
- package/dist/components/lottie-img/index.js +99 -0
- package/dist/components/message-actions/CopyButton.d.ts +7 -0
- package/dist/components/message-actions/CopyButton.js +33 -0
- package/dist/components/message-actions/LikeButton.d.ts +7 -0
- package/dist/components/message-actions/LikeButton.js +34 -0
- package/dist/components/message-actions/RegenerateButton.d.ts +5 -0
- package/dist/components/message-actions/RegenerateButton.js +27 -0
- package/dist/components/message-actions/UnLikeButton.d.ts +7 -0
- package/dist/components/message-actions/UnLikeButton.js +34 -0
- package/dist/components/message-actions/VoicePlay.d.ts +10 -0
- package/dist/components/message-actions/VoicePlay.js +74 -0
- package/dist/components/message-list/index.d.ts +19 -0
- package/dist/components/message-list/index.js +167 -0
- package/dist/components/message-list/index.module.scss +304 -0
- package/dist/components/no-microphone-root/index.d.ts +6 -0
- package/dist/components/no-microphone-root/index.js +36 -0
- package/dist/components/no-microphone-root/index.module.scss +42 -0
- package/dist/components/preset-agent-content/index.d.ts +8 -0
- package/dist/components/preset-agent-content/index.js +24 -0
- package/dist/components/preset-agent-content/index.module.scss +48 -0
- package/dist/components/quoted-content/index.d.ts +0 -0
- package/dist/components/quoted-content/index.js +171 -0
- package/dist/components/quoted-content/index.module.scss +76 -0
- package/dist/components/reasoning-content/index.d.ts +6 -0
- package/dist/components/reasoning-content/index.js +116 -0
- package/dist/components/reasoning-content/index.module.scss +164 -0
- package/dist/components/reference-content/index.d.ts +28 -0
- package/dist/components/reference-content/index.js +125 -0
- package/dist/components/reference-content/index.module.scss +73 -0
- package/dist/components/templates/CommonChat.d.ts +5 -0
- package/dist/components/templates/CommonChat.js +218 -0
- package/dist/components/templates/GimiChatComponent.d.ts +4 -0
- package/dist/components/templates/GimiChatComponent.js +23 -0
- package/dist/components/templates/demo/demo.d.ts +2 -0
- package/dist/components/templates/demo/demo.js +110 -0
- package/dist/components/templates/index.module.scss +119 -0
- package/dist/components/upload-list/index.d.ts +15 -0
- package/dist/components/upload-list/index.js +90 -0
- package/dist/components/upload-list/index.module.scss +119 -0
- package/dist/components/voice-bars/index.d.ts +4 -0
- package/dist/components/voice-bars/index.js +174 -0
- package/dist/components/voice-check-dialog/index.d.ts +8 -0
- package/dist/components/voice-check-dialog/index.js +163 -0
- package/dist/components/voice-check-dialog/index.module.scss +9 -0
- package/dist/components/voice-recording/index.d.ts +9 -0
- package/dist/components/voice-recording/index.js +54 -0
- package/dist/components/voice-recording/index.module.scss +41 -0
- package/dist/components/work-flow-content/demo.d.ts +3 -0
- package/dist/components/work-flow-content/demo.js +11 -0
- package/dist/components/work-flow-content/index.d.ts +6 -0
- package/dist/components/work-flow-content/index.js +55 -0
- package/dist/components/work-flow-content/index.module.scss +23 -0
- package/dist/constants.d.ts +24 -0
- package/dist/constants.js +24 -0
- package/dist/hooks/useChatActions.d.ts +12 -0
- package/dist/hooks/useChatActions.js +207 -0
- package/dist/hooks/useChatHistory.d.ts +8 -0
- package/dist/hooks/useChatHistory.js +225 -0
- package/dist/hooks/useChatMessage.d.ts +49 -0
- package/dist/hooks/useChatMessage.js +87 -0
- package/dist/hooks/useChatRecommend.d.ts +8 -0
- package/dist/hooks/useChatRecommend.js +126 -0
- package/dist/hooks/useChatStream.d.ts +20 -0
- package/dist/hooks/useChatStream.js +244 -0
- package/dist/hooks/useChatUI.d.ts +32 -0
- package/dist/hooks/useChatUI.js +134 -0
- package/dist/hooks/useChatVoice.d.ts +11 -0
- package/dist/hooks/useChatVoice.js +379 -0
- package/dist/hooks/useCommonChatAPI.d.ts +27 -0
- package/dist/hooks/useCommonChatAPI.js +1276 -0
- package/dist/hooks/useFile.d.ts +13 -0
- package/dist/hooks/useFile.js +288 -0
- package/dist/hooks/useKnowledgeService.d.ts +17 -0
- package/dist/hooks/useKnowledgeService.js +210 -0
- package/dist/hooks/useLastEventId.d.ts +8 -0
- package/dist/hooks/useLastEventId.js +66 -0
- package/dist/hooks/useLongPoll.d.ts +3 -0
- package/dist/hooks/useLongPoll.js +111 -0
- package/dist/hooks/useScroll.d.ts +4 -0
- package/dist/hooks/useScroll.js +172 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/chatMessage.d.ts +139 -0
- package/dist/interfaces/fileInterface.d.ts +10 -0
- package/dist/interfaces/fileInterface.js +11 -0
- package/dist/interfaces/knowledgeTrace.d.ts +177 -0
- package/dist/store/hooks.d.ts +4 -0
- package/dist/store/hooks.js +3 -0
- package/dist/store/index.d.ts +7 -0
- package/dist/store/index.js +7 -0
- package/dist/store/slices/gimiMenuSlice.d.ts +95 -0
- package/dist/store/slices/gimiMenuSlice.js +251 -0
- package/dist/utils/chatInputUtil.d.ts +19 -0
- package/dist/utils/chatInputUtil.js +45 -0
- package/dist/utils/tools.d.ts +50 -0
- package/dist/utils/tools.js +474 -0
- package/dist/utils/voice-stream.d.ts +119 -0
- package/dist/utils/voice-stream.js +1162 -0
- package/package.json +2 -3
- package/LICENSE +0 -21
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { usePureChatActions } from "../../hooks/useChatActions";
|
|
2
|
+
import likeIcon from "../../assets/image/like_active.png";
|
|
3
|
+
import love from "../../assets/image/love.png";
|
|
4
|
+
import { Tooltip } from '@douyinfe/semi-ui';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
var LikeButton = function LikeButton(_ref) {
|
|
7
|
+
var item = _ref.item,
|
|
8
|
+
onLikeCallback = _ref.onLikeCallback;
|
|
9
|
+
var _usePureChatActions = usePureChatActions(),
|
|
10
|
+
handleUnlove = _usePureChatActions.handleUnlove;
|
|
11
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
12
|
+
content: "".concat(item.mark === 2 ? '已点赞' : '点赞')
|
|
13
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
style: {
|
|
15
|
+
display: 'flex',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
cursor: 'pointer',
|
|
18
|
+
userSelect: 'none'
|
|
19
|
+
},
|
|
20
|
+
onClick: function onClick() {
|
|
21
|
+
handleUnlove(item, 'love');
|
|
22
|
+
onLikeCallback === null || onLikeCallback === void 0 || onLikeCallback();
|
|
23
|
+
}
|
|
24
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
25
|
+
width: 18,
|
|
26
|
+
height: 18,
|
|
27
|
+
style: {
|
|
28
|
+
display: 'flex',
|
|
29
|
+
alignItems: 'center'
|
|
30
|
+
},
|
|
31
|
+
src: item.mark === 2 ? likeIcon : love
|
|
32
|
+
})));
|
|
33
|
+
};
|
|
34
|
+
export default LikeButton;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// import { IChatMessageItem } from '../../interfaces/chatMessage';
|
|
2
|
+
// import useChatActions from '../../hooks/useChatActions';
|
|
3
|
+
import { Tooltip } from '@douyinfe/semi-ui';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { IconRedoStroked } from '@douyinfe/semi-icons';
|
|
6
|
+
var RegenerateButton = function RegenerateButton(_ref) {
|
|
7
|
+
var onRegenerateClick = _ref.onRegenerateClick;
|
|
8
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
9
|
+
content: "\u91CD\u65B0\u751F\u6210"
|
|
10
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
11
|
+
style: {
|
|
12
|
+
display: 'flex',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
cursor: 'pointer',
|
|
15
|
+
userSelect: 'none'
|
|
16
|
+
},
|
|
17
|
+
onClick: function onClick() {
|
|
18
|
+
onRegenerateClick === null || onRegenerateClick === void 0 || onRegenerateClick();
|
|
19
|
+
}
|
|
20
|
+
}, /*#__PURE__*/React.createElement(IconRedoStroked, {
|
|
21
|
+
style: {
|
|
22
|
+
width: 18,
|
|
23
|
+
height: 18
|
|
24
|
+
}
|
|
25
|
+
})));
|
|
26
|
+
};
|
|
27
|
+
export default RegenerateButton;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { usePureChatActions } from "../../hooks/useChatActions";
|
|
2
|
+
import unloveActive from "../../assets/image/unlike_active.png";
|
|
3
|
+
import unlove from "../../assets/image/unlove.png";
|
|
4
|
+
import { Tooltip } from '@douyinfe/semi-ui';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
var UnLikeButton = function UnLikeButton(_ref) {
|
|
7
|
+
var item = _ref.item,
|
|
8
|
+
onUnLikeCallback = _ref.onUnLikeCallback;
|
|
9
|
+
var _usePureChatActions = usePureChatActions(),
|
|
10
|
+
handleUnlove = _usePureChatActions.handleUnlove;
|
|
11
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
12
|
+
content: "".concat(item.mark === 1 ? '已点踩' : '点踩')
|
|
13
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
style: {
|
|
15
|
+
display: 'flex',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
cursor: 'pointer',
|
|
18
|
+
userSelect: 'none'
|
|
19
|
+
},
|
|
20
|
+
onClick: function onClick() {
|
|
21
|
+
handleUnlove(item, 'unlove');
|
|
22
|
+
onUnLikeCallback === null || onUnLikeCallback === void 0 || onUnLikeCallback();
|
|
23
|
+
}
|
|
24
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
25
|
+
width: 18,
|
|
26
|
+
height: 18,
|
|
27
|
+
style: {
|
|
28
|
+
display: 'flex',
|
|
29
|
+
alignItems: 'center'
|
|
30
|
+
},
|
|
31
|
+
src: item.mark === 1 ? unloveActive : unlove
|
|
32
|
+
})));
|
|
33
|
+
};
|
|
34
|
+
export default UnLikeButton;
|
|
@@ -0,0 +1,74 @@
|
|
|
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 _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
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import soundOutIcon from "../../assets/image/soundOut.png";
|
|
7
|
+
import { Tooltip } from '@douyinfe/semi-ui';
|
|
8
|
+
import { useAppSelector, useAppDispatch } from "../../store/hooks";
|
|
9
|
+
import { setCurrentMessageId } from "../../store/slices/gimiMenuSlice";
|
|
10
|
+
import LottieImg from "../lottie-img";
|
|
11
|
+
var getCleanReadText = function getCleanReadText(text) {
|
|
12
|
+
// 移除<knowledge>标签及内容
|
|
13
|
+
var newText = text.replace(/<knowledge>.*?<\/knowledge>/g, '').replace(/<excel>.*?<\/excel>/g, '');
|
|
14
|
+
return newText.trim();
|
|
15
|
+
};
|
|
16
|
+
var VoicePlay = function VoicePlay(props) {
|
|
17
|
+
var text = props.text,
|
|
18
|
+
messageId = props.messageId,
|
|
19
|
+
playTTSByText = props.playTTSByText,
|
|
20
|
+
stopTTSByText = props.stopTTSByText,
|
|
21
|
+
isVoicePlaying = props.isVoicePlaying;
|
|
22
|
+
var cleanedText = getCleanReadText(text);
|
|
23
|
+
var currentMessageId = useAppSelector(function (state) {
|
|
24
|
+
return state.gimiMenu.currentMessageId;
|
|
25
|
+
});
|
|
26
|
+
var dispatch = useAppDispatch();
|
|
27
|
+
var isActive = messageId === currentMessageId && isVoicePlaying;
|
|
28
|
+
var handleClick = /*#__PURE__*/function () {
|
|
29
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
30
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
31
|
+
while (1) switch (_context.prev = _context.next) {
|
|
32
|
+
case 0:
|
|
33
|
+
if (isVoicePlaying && messageId === currentMessageId) {
|
|
34
|
+
stopTTSByText();
|
|
35
|
+
} else {
|
|
36
|
+
dispatch(setCurrentMessageId({
|
|
37
|
+
currentMessageId: messageId
|
|
38
|
+
}));
|
|
39
|
+
playTTSByText(cleanedText);
|
|
40
|
+
}
|
|
41
|
+
case 1:
|
|
42
|
+
case "end":
|
|
43
|
+
return _context.stop();
|
|
44
|
+
}
|
|
45
|
+
}, _callee);
|
|
46
|
+
}));
|
|
47
|
+
return function handleClick() {
|
|
48
|
+
return _ref.apply(this, arguments);
|
|
49
|
+
};
|
|
50
|
+
}();
|
|
51
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
52
|
+
content: isActive ? '暂停朗读' : '语音朗读'
|
|
53
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
style: {
|
|
55
|
+
display: 'flex',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
justifyContent: 'center',
|
|
58
|
+
cursor: 'pointer'
|
|
59
|
+
},
|
|
60
|
+
onClick: handleClick
|
|
61
|
+
}, isActive ? /*#__PURE__*/React.createElement(LottieImg, {
|
|
62
|
+
name: "aiVoicePlay",
|
|
63
|
+
size: [30, 20]
|
|
64
|
+
}) : /*#__PURE__*/React.createElement("img", {
|
|
65
|
+
width: 18,
|
|
66
|
+
height: 18,
|
|
67
|
+
style: {
|
|
68
|
+
display: 'flex',
|
|
69
|
+
alignItems: 'center'
|
|
70
|
+
},
|
|
71
|
+
src: soundOutIcon
|
|
72
|
+
})));
|
|
73
|
+
};
|
|
74
|
+
export default VoicePlay;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MessageConfig } from '../../types/chat';
|
|
3
|
+
interface Iprops {
|
|
4
|
+
chatList: any[];
|
|
5
|
+
handleSend: (val: string, agent?: any, isSystemAuto?: boolean) => void;
|
|
6
|
+
inputModelRef: React.MutableRefObject<any>;
|
|
7
|
+
msgLoading: boolean;
|
|
8
|
+
onSucessExcel: (value: any) => void;
|
|
9
|
+
onFailureExcel: (value: any, id: any) => void;
|
|
10
|
+
onRetryExcel: (value: any, id: any) => void;
|
|
11
|
+
chatUI: any;
|
|
12
|
+
isPlaying: boolean;
|
|
13
|
+
playTTSByText: (text: string) => void;
|
|
14
|
+
stopTTSByText: () => void;
|
|
15
|
+
model: 'sidebar' | 'fullscreen';
|
|
16
|
+
onRegenerateClick?: () => void;
|
|
17
|
+
}
|
|
18
|
+
declare const MessageList: React.FC<Iprops & MessageConfig>;
|
|
19
|
+
export default MessageList;
|
|
@@ -0,0 +1,167 @@
|
|
|
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 _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
4
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import styles from "./index.module.scss";
|
|
8
|
+
import { Spin } from '@douyinfe/semi-ui';
|
|
9
|
+
import { References } from "../reference-content";
|
|
10
|
+
import { replaceBraces } from "../../utils/tools";
|
|
11
|
+
import UploadList from "../upload-list";
|
|
12
|
+
import AnswerItem from "../answer-item";
|
|
13
|
+
import { useCallback } from 'react';
|
|
14
|
+
import LottieImg from "../lottie-img";
|
|
15
|
+
import { useGimiFileUpload } from "../../hooks/useFile";
|
|
16
|
+
import { FileStatus } from "../../interfaces/fileInterface";
|
|
17
|
+
import useChatActions from "../../hooks/useChatActions";
|
|
18
|
+
import CopyButton from "../message-actions/CopyButton";
|
|
19
|
+
var MessageList = function MessageList(_ref) {
|
|
20
|
+
var chatList = _ref.chatList,
|
|
21
|
+
handleSend = _ref.handleSend,
|
|
22
|
+
inputModelRef = _ref.inputModelRef,
|
|
23
|
+
msgLoading = _ref.msgLoading,
|
|
24
|
+
onSucessExcel = _ref.onSucessExcel,
|
|
25
|
+
onFailureExcel = _ref.onFailureExcel,
|
|
26
|
+
onRetryExcel = _ref.onRetryExcel,
|
|
27
|
+
chatUI = _ref.chatUI,
|
|
28
|
+
isPlaying = _ref.isPlaying,
|
|
29
|
+
playTTSByText = _ref.playTTSByText,
|
|
30
|
+
stopTTSByText = _ref.stopTTSByText,
|
|
31
|
+
enableCopy = _ref.enableCopy,
|
|
32
|
+
enableLike = _ref.enableLike,
|
|
33
|
+
enableUnLike = _ref.enableUnLike,
|
|
34
|
+
enableRegenerate = _ref.enableRegenerate,
|
|
35
|
+
enableVoicePlay = _ref.enableVoicePlay,
|
|
36
|
+
model = _ref.model,
|
|
37
|
+
onRegenerateClick = _ref.onRegenerateClick,
|
|
38
|
+
onCopyCallback = _ref.onCopyCallback,
|
|
39
|
+
onLikeCallback = _ref.onLikeCallback,
|
|
40
|
+
onUnLikeCallback = _ref.onUnLikeCallback;
|
|
41
|
+
var _useGimiFileUpload = useGimiFileUpload(),
|
|
42
|
+
handleSSEFileAnalyize = _useGimiFileUpload.handleSSEFileAnalyize,
|
|
43
|
+
fileUpload = _useGimiFileUpload.fileUpload;
|
|
44
|
+
var handleReTry = function handleReTry(file) {
|
|
45
|
+
if (file.status === FileStatus.ANALYSE_FAILED) {
|
|
46
|
+
handleSSEFileAnalyize(file);
|
|
47
|
+
} else {
|
|
48
|
+
fileUpload(file);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// 使用 useChatActions hook 管理用户操作
|
|
53
|
+
// 注意:由于 handleSend 和 startChat 的复杂依赖,暂时保留部分原有函数
|
|
54
|
+
var chatActions = useChatActions(chatUI.showCopyId, inputModelRef, handleSend);
|
|
55
|
+
// 使用 chatActions hook 提供的函数
|
|
56
|
+
var showOpera = chatActions.showOpera,
|
|
57
|
+
showCommend = chatActions.showCommend,
|
|
58
|
+
handleClickAskList = chatActions.handleClickAskList;
|
|
59
|
+
var handleClickPromptWord = function handleClickPromptWord(prompt) {
|
|
60
|
+
handleSend(prompt);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// 搜索弹框 - 使用 chatUI hook
|
|
64
|
+
// const handleShowSearchResult = useCallback(
|
|
65
|
+
// async (v: any) => {
|
|
66
|
+
// if (v.messageId && v.messageId?.startsWith('msg_')) {
|
|
67
|
+
// const searchIndex = chatList.findIndex((item) => item.id === v.questionId);
|
|
68
|
+
// chatUI.setSearchStr(chatList[searchIndex]?.query);
|
|
69
|
+
// }
|
|
70
|
+
// chatUI.showSearchResult(v.messageId ? v.messageId : v.chatId, chatList.find((item) => item.id === v.questionId)?.query);
|
|
71
|
+
// },
|
|
72
|
+
// [chatList, chatUI]
|
|
73
|
+
// );
|
|
74
|
+
|
|
75
|
+
// 视频播放 - 使用 chatUI hook
|
|
76
|
+
// const handleClickVideo = useCallback(
|
|
77
|
+
// (content: string, id: string, index: number) => {
|
|
78
|
+
// if (id === chatUI.selectedItem?.id && chatUI.selectedItem?.index === index) {
|
|
79
|
+
// chatUI.closePanel();
|
|
80
|
+
// } else {
|
|
81
|
+
// chatUI.showVideo(content, id, index);
|
|
82
|
+
// }
|
|
83
|
+
// },
|
|
84
|
+
// [chatUI]
|
|
85
|
+
// );
|
|
86
|
+
|
|
87
|
+
// 课程推荐 - 使用 chatUI hook
|
|
88
|
+
var handleShowCourse = useCallback(function (v) {
|
|
89
|
+
chatUI.showCourse(v.messageId ? v.messageId : v.chatId, v.videoResourceList);
|
|
90
|
+
}, [chatUI]);
|
|
91
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
className: classNames(styles.main)
|
|
93
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
className: classNames(model === 'sidebar' ? styles.small_container : styles.container)
|
|
95
|
+
}, chatList.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
96
|
+
className: styles.textWrap
|
|
97
|
+
}, chatList.map(function (v) {
|
|
98
|
+
var _v$quoteTeachModelLis, _v$quoteProductList;
|
|
99
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
100
|
+
key: v.id
|
|
101
|
+
}, v.isSystemAuto !== 1 && /*#__PURE__*/React.createElement("div", {
|
|
102
|
+
key: String(v.id),
|
|
103
|
+
className: classNames(styles.textItem, _defineProperty({}, styles.question, (v === null || v === void 0 ? void 0 : v.type) === 0)),
|
|
104
|
+
onMouseLeave: function onMouseLeave() {
|
|
105
|
+
return chatUI.setShowCopyId(0);
|
|
106
|
+
},
|
|
107
|
+
onMouseEnter: function onMouseEnter() {
|
|
108
|
+
if (!v.loading) chatUI.setShowCopyId(v.id);
|
|
109
|
+
}
|
|
110
|
+
}, (v === null || v === void 0 ? void 0 : v.type) === 0 && /*#__PURE__*/React.createElement(React.Fragment, null, v.status !== 1 && /*#__PURE__*/React.createElement("div", {
|
|
111
|
+
className: styles.qusetionOpera
|
|
112
|
+
}, v.status === 0 && /*#__PURE__*/React.createElement(Spin, {
|
|
113
|
+
size: "small"
|
|
114
|
+
})), (((_v$quoteTeachModelLis = v.quoteTeachModelList) === null || _v$quoteTeachModelLis === void 0 ? void 0 : _v$quoteTeachModelLis.length) > 0 || ((_v$quoteProductList = v.quoteProductList) === null || _v$quoteProductList === void 0 ? void 0 : _v$quoteProductList.length) > 0) && /*#__PURE__*/React.createElement(References, {
|
|
115
|
+
quoteProductList: v.quoteProductList,
|
|
116
|
+
quoteTeachModelList: v.quoteTeachModelList
|
|
117
|
+
}), v.content && /*#__PURE__*/React.createElement("div", {
|
|
118
|
+
className: styles.title,
|
|
119
|
+
dangerouslySetInnerHTML: {
|
|
120
|
+
__html: replaceBraces(v.content)
|
|
121
|
+
}
|
|
122
|
+
}), v.messageFiles &&
|
|
123
|
+
/*#__PURE__*/
|
|
124
|
+
// 增加fileUrl校验,确保文件已上传
|
|
125
|
+
React.createElement("div", {
|
|
126
|
+
className: styles.listBox
|
|
127
|
+
}, /*#__PURE__*/React.createElement(UploadList, {
|
|
128
|
+
file: v.messageFiles,
|
|
129
|
+
showDel: false,
|
|
130
|
+
handleDelFile: function handleDelFile() {},
|
|
131
|
+
handleReTry: handleReTry
|
|
132
|
+
})), v.content && /*#__PURE__*/React.createElement("div", {
|
|
133
|
+
className: styles.copyBtn
|
|
134
|
+
}, /*#__PURE__*/React.createElement(CopyButton, {
|
|
135
|
+
item: v,
|
|
136
|
+
onCopyCallback: onCopyCallback
|
|
137
|
+
}))), (v === null || v === void 0 ? void 0 : v.type) === 1 && /*#__PURE__*/React.createElement(AnswerItem, {
|
|
138
|
+
item: v,
|
|
139
|
+
showOpera: showOpera,
|
|
140
|
+
onSucess: onSucessExcel,
|
|
141
|
+
onFailure: onFailureExcel,
|
|
142
|
+
onRetry: onRetryExcel,
|
|
143
|
+
onCopyCallback: onCopyCallback,
|
|
144
|
+
onLikeCallback: onLikeCallback,
|
|
145
|
+
onUnLikeCallback: onUnLikeCallback,
|
|
146
|
+
showCommend: showCommend,
|
|
147
|
+
handleClickPromptWord: handleClickPromptWord,
|
|
148
|
+
handleShowCourse: handleShowCourse,
|
|
149
|
+
handleClickAskList: handleClickAskList,
|
|
150
|
+
playTTSByText: playTTSByText,
|
|
151
|
+
stopTTSByText: stopTTSByText,
|
|
152
|
+
isVoicePlaying: isPlaying,
|
|
153
|
+
onRegenerateClick: onRegenerateClick,
|
|
154
|
+
enableCopy: enableCopy,
|
|
155
|
+
enableLike: enableLike,
|
|
156
|
+
enableUnLike: enableUnLike,
|
|
157
|
+
enableRegenerate: enableRegenerate,
|
|
158
|
+
enableVoicePlay: enableVoicePlay
|
|
159
|
+
})));
|
|
160
|
+
}), msgLoading && /*#__PURE__*/React.createElement("div", {
|
|
161
|
+
className: styles.answerLoading
|
|
162
|
+
}, /*#__PURE__*/React.createElement(LottieImg, {
|
|
163
|
+
name: "aiLoading",
|
|
164
|
+
size: [20, 40]
|
|
165
|
+
})))));
|
|
166
|
+
};
|
|
167
|
+
export default MessageList;
|