@myun/gimi-chat 0.0.2 → 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,433 @@
|
|
|
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 _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
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; }
|
|
4
|
+
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); } }
|
|
5
|
+
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); }); }; }
|
|
6
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import React from "react";
|
|
14
|
+
import { AIChatInput, Divider } from '@douyinfe/semi-ui';
|
|
15
|
+
import { transformToInputSlots } from "../../utils/chatInputUtil";
|
|
16
|
+
import VoiceCheckDialog from "../voice-check-dialog";
|
|
17
|
+
import VoiceCommunication from "../chat-voice/VoiceCommunication";
|
|
18
|
+
import VoiceRecord from "../chat-voice/VoiceRecord";
|
|
19
|
+
import VoiceRecording from "../voice-recording";
|
|
20
|
+
import deepThinkActive from "../../assets/image/deepthinkActive.png";
|
|
21
|
+
import { Tooltip } from "@douyinfe/semi-ui";
|
|
22
|
+
import styles from "./index.module.scss";
|
|
23
|
+
import FileUpload from "../file-upload";
|
|
24
|
+
import { useAppSelector, useAppDispatch } from "../../store/hooks";
|
|
25
|
+
import { setConversationId, setFileList } from "../../store/slices/gimiMenuSlice";
|
|
26
|
+
import { Toast } from "@douyinfe/semi-ui";
|
|
27
|
+
import useApi from "../../apis/useApi";
|
|
28
|
+
import UploadList from "../upload-list";
|
|
29
|
+
import { FileStatus } from "../../interfaces/fileInterface";
|
|
30
|
+
import LottieImg from "../lottie-img";
|
|
31
|
+
import AIChatDialogue from "../ai-chat-dialogue";
|
|
32
|
+
var extractText = function extractText() {
|
|
33
|
+
var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
34
|
+
return content.map(function (item) {
|
|
35
|
+
if (item.type === 'text' && typeof item.text === 'string') {
|
|
36
|
+
return item.text;
|
|
37
|
+
}
|
|
38
|
+
if (item.content && Array.isArray(item.content)) {
|
|
39
|
+
return extractText(item.content);
|
|
40
|
+
}
|
|
41
|
+
return '';
|
|
42
|
+
}).join('');
|
|
43
|
+
};
|
|
44
|
+
var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
45
|
+
var fileList = useAppSelector(function (state) {
|
|
46
|
+
return state.gimiMenu.fileList;
|
|
47
|
+
});
|
|
48
|
+
var isMsgRecieving = useAppSelector(function (state) {
|
|
49
|
+
return state.gimiMenu.isMsgRecieving;
|
|
50
|
+
});
|
|
51
|
+
var agentObj = useAppSelector(function (state) {
|
|
52
|
+
return state.gimiMenu.agentObj;
|
|
53
|
+
});
|
|
54
|
+
var conversationId = useAppSelector(function (state) {
|
|
55
|
+
return state.gimiMenu.conversationId;
|
|
56
|
+
});
|
|
57
|
+
var messageList = useAppSelector(function (state) {
|
|
58
|
+
return state.gimiMenu.messageList;
|
|
59
|
+
});
|
|
60
|
+
var dispatch = useAppDispatch();
|
|
61
|
+
var inputWrapRef = React.useRef(null);
|
|
62
|
+
var preInputValueRef = React.useRef('');
|
|
63
|
+
var inputRef = React.useRef(null);
|
|
64
|
+
var uploadFileRef = React.useRef(null);
|
|
65
|
+
var conversationIdRef = React.useRef(conversationId);
|
|
66
|
+
conversationIdRef.current = conversationId;
|
|
67
|
+
var agentObjRef = React.useRef(agentObj);
|
|
68
|
+
agentObjRef.current = agentObj;
|
|
69
|
+
var _React$useState = React.useState(false),
|
|
70
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
71
|
+
showChatCommunication = _React$useState2[0],
|
|
72
|
+
setShowChatCommunication = _React$useState2[1];
|
|
73
|
+
var _React$useState3 = React.useState(0),
|
|
74
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
75
|
+
inputWidth = _React$useState4[0],
|
|
76
|
+
setInputWidth = _React$useState4[1];
|
|
77
|
+
var _React$useState5 = React.useState(!!props.defaultPrompt),
|
|
78
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
79
|
+
hasContent = _React$useState6[0],
|
|
80
|
+
setHasContent = _React$useState6[1];
|
|
81
|
+
var _useApi = useApi(),
|
|
82
|
+
createRoomId = _useApi.createRoomId;
|
|
83
|
+
React.useImperativeHandle(ref, function () {
|
|
84
|
+
return {
|
|
85
|
+
getValue: function getValue() {
|
|
86
|
+
return preInputValueRef.current;
|
|
87
|
+
},
|
|
88
|
+
setValue: function setValue(value) {
|
|
89
|
+
var _inputRef$current;
|
|
90
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.setContent(value);
|
|
91
|
+
preInputValueRef.current = value;
|
|
92
|
+
setHasContent(value.trim().length > 0);
|
|
93
|
+
},
|
|
94
|
+
focus: function focus() {
|
|
95
|
+
var _inputRef$current2;
|
|
96
|
+
(_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 || _inputRef$current2.focusEditor('end');
|
|
97
|
+
},
|
|
98
|
+
blur: function blur() {
|
|
99
|
+
var _inputRef$current3;
|
|
100
|
+
(_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 || (_inputRef$current3 = _inputRef$current3.getEditor()) === null || _inputRef$current3 === void 0 || (_inputRef$current3 = _inputRef$current3.commands) === null || _inputRef$current3 === void 0 || _inputRef$current3.blur();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
var onContentChange = React.useCallback(function (content) {
|
|
105
|
+
var value = extractText(content);
|
|
106
|
+
if (value.length > 10000) {
|
|
107
|
+
var _inputRef$current4;
|
|
108
|
+
Toast.warning('最多输入10000个字符');
|
|
109
|
+
value = value.slice(0, 10000);
|
|
110
|
+
(_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 || _inputRef$current4.setContent(value);
|
|
111
|
+
}
|
|
112
|
+
setHasContent(value.trim().length > 0);
|
|
113
|
+
preInputValueRef.current = value;
|
|
114
|
+
}, []);
|
|
115
|
+
React.useEffect(function () {
|
|
116
|
+
var element = inputWrapRef.current;
|
|
117
|
+
if (!element) return;
|
|
118
|
+
var resizeObserver = new ResizeObserver(function (entries) {
|
|
119
|
+
var _iterator = _createForOfIteratorHelper(entries),
|
|
120
|
+
_step;
|
|
121
|
+
try {
|
|
122
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
123
|
+
var entry = _step.value;
|
|
124
|
+
var width = entry.contentRect.width;
|
|
125
|
+
console.log('width', width);
|
|
126
|
+
setInputWidth(width);
|
|
127
|
+
}
|
|
128
|
+
} catch (err) {
|
|
129
|
+
_iterator.e(err);
|
|
130
|
+
} finally {
|
|
131
|
+
_iterator.f();
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
resizeObserver.observe(element);
|
|
135
|
+
return function () {
|
|
136
|
+
resizeObserver.disconnect();
|
|
137
|
+
};
|
|
138
|
+
}, []);
|
|
139
|
+
var handleQuickInput = React.useCallback(function (value) {
|
|
140
|
+
var isReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
141
|
+
if (isReplace) {
|
|
142
|
+
var _inputRef$current5;
|
|
143
|
+
(_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 || _inputRef$current5.setContent(value);
|
|
144
|
+
} else {
|
|
145
|
+
var _inputRef$current6;
|
|
146
|
+
(_inputRef$current6 = inputRef.current) === null || _inputRef$current6 === void 0 || _inputRef$current6.setContent(preInputValueRef.current + value);
|
|
147
|
+
}
|
|
148
|
+
}, []);
|
|
149
|
+
React.useEffect(function () {
|
|
150
|
+
if (!props.isRecording && !props.isVoiceGetting && props.asrText) {
|
|
151
|
+
handleQuickInput(props.asrText, false);
|
|
152
|
+
}
|
|
153
|
+
}, [props.asrText, props.isRecording, props.isVoiceGetting, handleQuickInput]);
|
|
154
|
+
var handleTip = function handleTip() {
|
|
155
|
+
return Toast.info('最多上传一个文件哦');
|
|
156
|
+
};
|
|
157
|
+
var UploadFileTool = React.useMemo(function () {
|
|
158
|
+
if (!props.enableFileUpload || messageList.length > 0) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
return /*#__PURE__*/React.createElement(FileUpload, {
|
|
162
|
+
ref: uploadFileRef,
|
|
163
|
+
accept: props.accept,
|
|
164
|
+
disabled: props.disabled
|
|
165
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
166
|
+
content: '上传文件'
|
|
167
|
+
}, (fileList === null || fileList === void 0 ? void 0 : fileList.length) === 0 ? /*#__PURE__*/React.createElement("div", {
|
|
168
|
+
className: styles.uploadIcon
|
|
169
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
170
|
+
src: 'https://simg01.gaodunwangxiao.com/uploadimgs/tmp/upload/202509/11/83ad4_20250911153220.png',
|
|
171
|
+
alt: ""
|
|
172
|
+
})) : /*#__PURE__*/React.createElement("div", {
|
|
173
|
+
className: styles.uploadIcon,
|
|
174
|
+
onClick: handleTip
|
|
175
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
176
|
+
src: 'https://simg01.gaodunwangxiao.com/uploadimgs/tmp/upload/202509/24/6726e_20250924141448.png',
|
|
177
|
+
alt: ""
|
|
178
|
+
}))));
|
|
179
|
+
}, [props.enableFileUpload, messageList]);
|
|
180
|
+
var openChatCommunication = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
181
|
+
var params, res;
|
|
182
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
183
|
+
while (1) switch (_context.prev = _context.next) {
|
|
184
|
+
case 0:
|
|
185
|
+
if (!isMsgRecieving) {
|
|
186
|
+
_context.next = 2;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
return _context.abrupt("return", Toast.warning('当前流程不支持语音通话'));
|
|
190
|
+
case 2:
|
|
191
|
+
_context.prev = 2;
|
|
192
|
+
_context.next = 5;
|
|
193
|
+
return navigator.mediaDevices.getUserMedia({
|
|
194
|
+
audio: true
|
|
195
|
+
});
|
|
196
|
+
case 5:
|
|
197
|
+
_context.next = 11;
|
|
198
|
+
break;
|
|
199
|
+
case 7:
|
|
200
|
+
_context.prev = 7;
|
|
201
|
+
_context.t0 = _context["catch"](2);
|
|
202
|
+
dispatch({
|
|
203
|
+
type: 'gimiMenu/setShowMicWarning',
|
|
204
|
+
payload: {
|
|
205
|
+
showMicWarning: true
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
throw new Error('需要麦克风访问权限');
|
|
209
|
+
case 11:
|
|
210
|
+
if (conversationIdRef.current) {
|
|
211
|
+
_context.next = 25;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
params = {
|
|
215
|
+
content: '新对话',
|
|
216
|
+
conversationType: agentObjRef.current.conversationType,
|
|
217
|
+
botId: agentObjRef.current.botId,
|
|
218
|
+
isSystemAuto: 1
|
|
219
|
+
};
|
|
220
|
+
_context.prev = 13;
|
|
221
|
+
_context.next = 16;
|
|
222
|
+
return createRoomId(params);
|
|
223
|
+
case 16:
|
|
224
|
+
res = _context.sent;
|
|
225
|
+
if (res && res.status === 0) {
|
|
226
|
+
dispatch(setConversationId(res.result));
|
|
227
|
+
setShowChatCommunication(true);
|
|
228
|
+
} else {
|
|
229
|
+
Toast.error(res.message);
|
|
230
|
+
}
|
|
231
|
+
_context.next = 23;
|
|
232
|
+
break;
|
|
233
|
+
case 20:
|
|
234
|
+
_context.prev = 20;
|
|
235
|
+
_context.t1 = _context["catch"](13);
|
|
236
|
+
console.log('error', _context.t1);
|
|
237
|
+
case 23:
|
|
238
|
+
_context.next = 26;
|
|
239
|
+
break;
|
|
240
|
+
case 25:
|
|
241
|
+
// 不是gimi首页,直接打开会话
|
|
242
|
+
setShowChatCommunication(true);
|
|
243
|
+
case 26:
|
|
244
|
+
case "end":
|
|
245
|
+
return _context.stop();
|
|
246
|
+
}
|
|
247
|
+
}, _callee, null, [[2, 7], [13, 20]]);
|
|
248
|
+
})), [dispatch, isMsgRecieving]);
|
|
249
|
+
var stopRecording = React.useCallback( /*#__PURE__*/function () {
|
|
250
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(enableInput) {
|
|
251
|
+
var _props$shortAsrClick;
|
|
252
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
253
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
254
|
+
case 0:
|
|
255
|
+
_context2.next = 2;
|
|
256
|
+
return (_props$shortAsrClick = props.shortAsrClick) === null || _props$shortAsrClick === void 0 ? void 0 : _props$shortAsrClick.call(props, !enableInput);
|
|
257
|
+
case 2:
|
|
258
|
+
case "end":
|
|
259
|
+
return _context2.stop();
|
|
260
|
+
}
|
|
261
|
+
}, _callee2);
|
|
262
|
+
}));
|
|
263
|
+
return function (_x) {
|
|
264
|
+
return _ref2.apply(this, arguments);
|
|
265
|
+
};
|
|
266
|
+
}(), [props.shortAsrClick]);
|
|
267
|
+
var VoiceTools = React.useMemo(function () {
|
|
268
|
+
var _agentObjRef$current;
|
|
269
|
+
if (!props.enableVoiceChat && !props.enableVoiceRecord) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
return /*#__PURE__*/React.createElement(VoiceCheckDialog, {
|
|
273
|
+
trigger: /*#__PURE__*/React.createElement(React.Fragment, null, props.enableVoiceChat && ((_agentObjRef$current = agentObjRef.current) === null || _agentObjRef$current === void 0 ? void 0 : _agentObjRef$current.isEnableVoiceCall) === 1 && /*#__PURE__*/React.createElement(VoiceCommunication, {
|
|
274
|
+
disabled: props.disabled || props.disableVoiceCommunication || props.isVoiceGetting || isMsgRecieving,
|
|
275
|
+
onClick: openChatCommunication
|
|
276
|
+
}), props.enableVoiceRecord && /*#__PURE__*/React.createElement(VoiceRecord, {
|
|
277
|
+
onClick: props.shortAsrClick,
|
|
278
|
+
disabled: props.disabled || isMsgRecieving || props.isVoiceGetting
|
|
279
|
+
}))
|
|
280
|
+
});
|
|
281
|
+
}, [props.enableVoiceChat, props.enableVoiceRecord, props.disabled, props.disableVoiceCommunication, props.isVoiceGetting, isMsgRecieving, openChatCommunication, props.shortAsrClick]);
|
|
282
|
+
var renderActionArea = React.useCallback(function (renderProps) {
|
|
283
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
284
|
+
className: renderProps.className,
|
|
285
|
+
key: "action_area"
|
|
286
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
287
|
+
style: {
|
|
288
|
+
display: 'flex',
|
|
289
|
+
alignItems: 'center'
|
|
290
|
+
}
|
|
291
|
+
}, VoiceTools, UploadFileTool, /*#__PURE__*/React.createElement(Divider, {
|
|
292
|
+
layout: "vertical",
|
|
293
|
+
style: {
|
|
294
|
+
marginLeft: 8
|
|
295
|
+
}
|
|
296
|
+
})), renderProps.menuItem);
|
|
297
|
+
}, [VoiceTools, UploadFileTool]);
|
|
298
|
+
var onMessageSend = React.useCallback(function (content) {
|
|
299
|
+
var _props$onSend;
|
|
300
|
+
var inputContents = content.inputContents || [];
|
|
301
|
+
var text = extractText(inputContents);
|
|
302
|
+
(_props$onSend = props.onSend) === null || _props$onSend === void 0 || _props$onSend.call(props, text);
|
|
303
|
+
}, []);
|
|
304
|
+
var renderConfigureArea = React.useCallback(function () {
|
|
305
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
306
|
+
trigger: 'click',
|
|
307
|
+
content: "\u7CFB\u7EDF\u667A\u80FD\u5207\u6362\u601D\u8003\u6A21\u5F0F"
|
|
308
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
309
|
+
className: styles.deepthink
|
|
310
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
311
|
+
width: 14,
|
|
312
|
+
src: deepThinkActive,
|
|
313
|
+
className: styles.imgs,
|
|
314
|
+
alt: ""
|
|
315
|
+
}), /*#__PURE__*/React.createElement("span", null, "\u6DF1\u5EA6\u601D\u8003:\xA0\xA0\u81EA\u52A8")));
|
|
316
|
+
}, []);
|
|
317
|
+
var stopSSe = function stopSSe() {
|
|
318
|
+
if (uploadFileRef.current) {
|
|
319
|
+
var _uploadFileRef$curren;
|
|
320
|
+
(_uploadFileRef$curren = uploadFileRef.current) === null || _uploadFileRef$curren === void 0 || _uploadFileRef$curren.abortUpload();
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
var handleDelFile = function handleDelFile() {
|
|
324
|
+
stopSSe();
|
|
325
|
+
dispatch(setFileList({
|
|
326
|
+
fileList: []
|
|
327
|
+
}));
|
|
328
|
+
};
|
|
329
|
+
var handleReTry = function handleReTry(file) {
|
|
330
|
+
var currentFileList = fileList || [];
|
|
331
|
+
var _file = currentFileList.find(function (item) {
|
|
332
|
+
return item.uid === file.uid;
|
|
333
|
+
});
|
|
334
|
+
if ((_file === null || _file === void 0 ? void 0 : _file.status) === FileStatus.ANALYSE_FAILED) {
|
|
335
|
+
var _uploadFileRef$curren2;
|
|
336
|
+
(_uploadFileRef$curren2 = uploadFileRef.current) === null || _uploadFileRef$curren2 === void 0 || _uploadFileRef$curren2.handleSSEFileAnalyize(_file);
|
|
337
|
+
} else {
|
|
338
|
+
var _uploadFileRef$curren3;
|
|
339
|
+
(_uploadFileRef$curren3 = uploadFileRef.current) === null || _uploadFileRef$curren3 === void 0 || _uploadFileRef$curren3.retryUpload(_file === null || _file === void 0 ? void 0 : _file.uid);
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
var renderReference = React.useCallback(function () {
|
|
343
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
344
|
+
className: styles.reference,
|
|
345
|
+
key: "reference"
|
|
346
|
+
}, !props.isRecording && (fileList === null || fileList === void 0 ? void 0 : fileList.length) > 0 && messageList.length === 0 && /*#__PURE__*/React.createElement(UploadList, {
|
|
347
|
+
file: fileList[0],
|
|
348
|
+
handleReTry: handleReTry,
|
|
349
|
+
handleDelFile: handleDelFile
|
|
350
|
+
}), props.isVoiceGetting && /*#__PURE__*/React.createElement("div", {
|
|
351
|
+
style: {
|
|
352
|
+
display: 'flex',
|
|
353
|
+
alignItems: 'start',
|
|
354
|
+
height: '60px'
|
|
355
|
+
}
|
|
356
|
+
}, /*#__PURE__*/React.createElement(LottieImg, {
|
|
357
|
+
name: "aiLoading",
|
|
358
|
+
size: [20, 40]
|
|
359
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
360
|
+
style: {
|
|
361
|
+
flex: 1
|
|
362
|
+
}
|
|
363
|
+
}, "\u6B63\u5728\u83B7\u53D6\u8BED\u97F3\u5185\u5BB9...")));
|
|
364
|
+
}, [fileList, props.isRecording, props.isVoiceGetting, messageList]);
|
|
365
|
+
var handleHangUp = function handleHangUp() {
|
|
366
|
+
var _props$onHistoryReloa;
|
|
367
|
+
(_props$onHistoryReloa = props.onHistoryReload) === null || _props$onHistoryReloa === void 0 || _props$onHistoryReloa.call(props);
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// const showDefaultPrompt = messageList.length === 0
|
|
371
|
+
|
|
372
|
+
React.useEffect(function () {
|
|
373
|
+
if (messageList.length === 0 && !conversationIdRef.current) {
|
|
374
|
+
var _inputRef$current7;
|
|
375
|
+
var defaultContent = transformToInputSlots(props.defaultPrompt || '');
|
|
376
|
+
(_inputRef$current7 = inputRef.current) === null || _inputRef$current7 === void 0 || _inputRef$current7.setContent(defaultContent);
|
|
377
|
+
setHasContent(!!props.defaultPrompt);
|
|
378
|
+
preInputValueRef.current = props.defaultPrompt || '';
|
|
379
|
+
} else {
|
|
380
|
+
var _inputRef$current8;
|
|
381
|
+
(_inputRef$current8 = inputRef.current) === null || _inputRef$current8 === void 0 || _inputRef$current8.setContent('');
|
|
382
|
+
setHasContent(false);
|
|
383
|
+
}
|
|
384
|
+
}, [props.defaultPrompt, messageList.length]);
|
|
385
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
386
|
+
className: styles.inputWrap,
|
|
387
|
+
ref: inputWrapRef
|
|
388
|
+
}, props.isRecording ? /*#__PURE__*/React.createElement(VoiceRecording, {
|
|
389
|
+
recordingCount: props.recordingCount,
|
|
390
|
+
stopRecording: stopRecording,
|
|
391
|
+
containerWidth: inputWidth
|
|
392
|
+
}) : /*#__PURE__*/React.createElement(AIChatInput, _extends({}, props, {
|
|
393
|
+
ref: inputRef,
|
|
394
|
+
style: {
|
|
395
|
+
width: '100%'
|
|
396
|
+
},
|
|
397
|
+
placeholder: props.placeholder || '',
|
|
398
|
+
references: [{
|
|
399
|
+
type: 'text',
|
|
400
|
+
id: '123'
|
|
401
|
+
}],
|
|
402
|
+
defaultContent: props.showDefaultPrompt ? transformToInputSlots(props.defaultPrompt || '') : '',
|
|
403
|
+
onContentChange: onContentChange
|
|
404
|
+
// 输入框底部右侧操作区域
|
|
405
|
+
,
|
|
406
|
+
renderActionArea: renderActionArea
|
|
407
|
+
// 输入框底部左侧操作区域
|
|
408
|
+
,
|
|
409
|
+
renderConfigureArea: renderConfigureArea
|
|
410
|
+
// 自定义引用区域
|
|
411
|
+
,
|
|
412
|
+
renderReference: renderReference,
|
|
413
|
+
onStopGenerate: props.onInterrupt
|
|
414
|
+
// 上传文件配置开始
|
|
415
|
+
,
|
|
416
|
+
showUploadButton: false,
|
|
417
|
+
showUploadFile: false
|
|
418
|
+
// 上传文件配置结束
|
|
419
|
+
,
|
|
420
|
+
canSend: !props.disabled && hasContent,
|
|
421
|
+
onMessageSend: onMessageSend,
|
|
422
|
+
generating: isMsgRecieving
|
|
423
|
+
})), showChatCommunication && /*#__PURE__*/React.createElement(AIChatDialogue, {
|
|
424
|
+
paper: {
|
|
425
|
+
enableCaptions: false,
|
|
426
|
+
conversationId: conversationId,
|
|
427
|
+
botId: agentObj.botId
|
|
428
|
+
},
|
|
429
|
+
setSpeech: setShowChatCommunication,
|
|
430
|
+
handleHangUp: handleHangUp
|
|
431
|
+
}));
|
|
432
|
+
});
|
|
433
|
+
export default ChatInput;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.inputWrap {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.deepthink {
|
|
8
|
+
padding: 0 8px;
|
|
9
|
+
height: 32px;
|
|
10
|
+
border-radius: 18px;
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
color: #4086ff;
|
|
16
|
+
background-color: #f1f7ff;
|
|
17
|
+
|
|
18
|
+
span {
|
|
19
|
+
margin-left: 4px;
|
|
20
|
+
font-family: PingFangSC, PingFang SC;
|
|
21
|
+
font-weight: 400;
|
|
22
|
+
font-size: 14px;
|
|
23
|
+
line-height: 14px;
|
|
24
|
+
text-align: right;
|
|
25
|
+
font-style: normal;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.imgs {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.uploadIcon {
|
|
36
|
+
width: 32px;
|
|
37
|
+
height: 32px;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
img {
|
|
40
|
+
width: 100%;
|
|
41
|
+
height: 100%;
|
|
42
|
+
object-fit: cover;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
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
|
+
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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { Toast, Tooltip } from '@douyinfe/semi-ui';
|
|
9
|
+
// import useVoiceFirstUse from '@/hooks/useVoiceFirstUse';
|
|
10
|
+
|
|
11
|
+
var ICON_ADDRESS = 'https://simg01.gaodunwangxiao.com/uploadimgs/tmp/upload/202601/12/0812c_20260112171004.png';
|
|
12
|
+
var VoiceCommunication = function VoiceCommunication(props) {
|
|
13
|
+
var _React$useState = React.useState(false),
|
|
14
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
15
|
+
showToast = _React$useState2[0],
|
|
16
|
+
setShowToast = _React$useState2[1];
|
|
17
|
+
// const { isVoiceCallFirstUse } = useVoiceFirstUse('voiceCall');
|
|
18
|
+
var isVoiceCallFirstUse = false;
|
|
19
|
+
var timerRef = React.useRef(undefined);
|
|
20
|
+
React.useEffect(function () {
|
|
21
|
+
if (isVoiceCallFirstUse) {
|
|
22
|
+
setShowToast(true);
|
|
23
|
+
if (timerRef.current) {
|
|
24
|
+
clearTimeout(timerRef.current);
|
|
25
|
+
}
|
|
26
|
+
timerRef.current = setTimeout(function () {
|
|
27
|
+
setShowToast(false);
|
|
28
|
+
}, 10000);
|
|
29
|
+
}
|
|
30
|
+
return function () {
|
|
31
|
+
if (timerRef.current) {
|
|
32
|
+
clearTimeout(timerRef.current);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}, [isVoiceCallFirstUse]);
|
|
36
|
+
var handleClick = function handleClick() {
|
|
37
|
+
if (props.disabled) {
|
|
38
|
+
Toast.warning('当前流程不支持语音通话');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
props.onClick();
|
|
42
|
+
};
|
|
43
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
44
|
+
content: '语音通话',
|
|
45
|
+
visible: showToast,
|
|
46
|
+
onVisibleChange: function onVisibleChange(isVisible) {
|
|
47
|
+
return setShowToast(isVisible);
|
|
48
|
+
}
|
|
49
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
style: {
|
|
51
|
+
display: 'flex',
|
|
52
|
+
alignItems: 'center',
|
|
53
|
+
justifyContent: 'center',
|
|
54
|
+
width: '32px',
|
|
55
|
+
height: '32px',
|
|
56
|
+
cursor: props.disabled ? 'not-allowed' : 'pointer',
|
|
57
|
+
fontSize: '20px'
|
|
58
|
+
},
|
|
59
|
+
onClick: handleClick
|
|
60
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
61
|
+
style: {
|
|
62
|
+
width: '32px',
|
|
63
|
+
height: '32px'
|
|
64
|
+
},
|
|
65
|
+
src: ICON_ADDRESS,
|
|
66
|
+
alt: "\u8BED\u97F3\u901A\u8BDD"
|
|
67
|
+
})));
|
|
68
|
+
};
|
|
69
|
+
export default VoiceCommunication;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Tooltip, Toast } from '@douyinfe/semi-ui';
|
|
3
|
+
var ICON_ADDRESS = 'https://simg01.gaodunwangxiao.com/uploadimgs/tmp/upload/202601/04/be8de_20260104155638.png';
|
|
4
|
+
var VoiceRecord = function VoiceRecord(props) {
|
|
5
|
+
var handleClick = function handleClick() {
|
|
6
|
+
if (props.disabled) {
|
|
7
|
+
Toast.warning('当前流程不支持语音输入');
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
props.onClick();
|
|
11
|
+
};
|
|
12
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
13
|
+
content: '语音输入'
|
|
14
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
style: {
|
|
16
|
+
display: 'flex',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
width: '32px',
|
|
20
|
+
height: '32px',
|
|
21
|
+
cursor: props.disabled ? 'not-allowed' : 'pointer',
|
|
22
|
+
fontSize: '20px'
|
|
23
|
+
},
|
|
24
|
+
onClick: handleClick
|
|
25
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
26
|
+
style: {
|
|
27
|
+
width: '32px',
|
|
28
|
+
height: '32px'
|
|
29
|
+
},
|
|
30
|
+
src: ICON_ADDRESS,
|
|
31
|
+
alt: "\u8BED\u97F3\u8F93\u5165"
|
|
32
|
+
})));
|
|
33
|
+
};
|
|
34
|
+
export default VoiceRecord;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popconfirm, Button } from '@douyinfe/semi-ui';
|
|
3
|
+
import { IconDeleteStroked } from '@douyinfe/semi-icons';
|
|
4
|
+
var ConversationDelete = function ConversationDelete(_ref) {
|
|
5
|
+
var onDelete = _ref.onDelete;
|
|
6
|
+
var onConfirm = function onConfirm() {
|
|
7
|
+
onDelete();
|
|
8
|
+
};
|
|
9
|
+
var onCancel = function onCancel() {
|
|
10
|
+
// 取消删除
|
|
11
|
+
};
|
|
12
|
+
return /*#__PURE__*/React.createElement(Popconfirm, {
|
|
13
|
+
title: "\u786E\u5B9A\u662F\u5426\u8981\u5220\u9664\u4F1A\u8BDD\uFF1F",
|
|
14
|
+
content: "\u6B64\u64CD\u4F5C\u5C06\u4E0D\u53EF\u9006",
|
|
15
|
+
onConfirm: onConfirm,
|
|
16
|
+
onCancel: onCancel
|
|
17
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
18
|
+
icon: /*#__PURE__*/React.createElement(IconDeleteStroked, {
|
|
19
|
+
size: "large"
|
|
20
|
+
}),
|
|
21
|
+
theme: "borderless"
|
|
22
|
+
}));
|
|
23
|
+
};
|
|
24
|
+
export default ConversationDelete;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import styles from "./index.module.scss";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export default function LoadingDots() {
|
|
4
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
5
|
+
className: styles.loading_dots
|
|
6
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
7
|
+
className: styles.loading_dots__dot
|
|
8
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
9
|
+
className: styles.loading_dots__dot
|
|
10
|
+
}));
|
|
11
|
+
}
|