@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.
Files changed (206) hide show
  1. package/dist/apis/fetch.d.ts +64 -0
  2. package/dist/apis/fetch.js +512 -0
  3. package/dist/apis/useApi.d.ts +57 -0
  4. package/dist/apis/useApi.js +378 -0
  5. package/dist/assets/image/Subtract.png +0 -0
  6. package/dist/assets/image/ai-logo.png +0 -0
  7. package/dist/assets/image/copyIcon.png +0 -0
  8. package/dist/assets/image/deepthinkActive.png +0 -0
  9. package/dist/assets/image/empty-img-dark.png +0 -0
  10. package/dist/assets/image/empty-img.png +0 -0
  11. package/dist/assets/image/like_active.png +0 -0
  12. package/dist/assets/image/love.png +0 -0
  13. package/dist/assets/image/retry.png +0 -0
  14. package/dist/assets/image/soundOut.png +0 -0
  15. package/dist/assets/image/unlike_active.png +0 -0
  16. package/dist/assets/image/unlove.png +0 -0
  17. package/dist/assets/lottie/ai-bg.json +1704 -0
  18. package/dist/assets/lottie/ai-loading.json +192 -0
  19. package/dist/assets/lottie/ai-output-loading.json +272 -0
  20. package/dist/assets/lottie/ai-output-normal.json +17694 -0
  21. package/dist/assets/lottie/ai-output-strengthen.json +17321 -0
  22. package/dist/assets/lottie/ai-voice-play.json +1 -0
  23. package/dist/assets/lottie/living.json +705 -0
  24. package/dist/assets/lottie/myun-living.json +726 -0
  25. package/dist/assets/lottie/myun-loading.json +530 -0
  26. package/dist/components/ai-chat-dialogue/index.d.ts +16 -0
  27. package/dist/components/ai-chat-dialogue/index.js +1056 -0
  28. package/dist/components/ai-chat-dialogue/index.module.scss +272 -0
  29. package/dist/components/ai-chat-dialogue/message-parser.d.ts +36 -0
  30. package/dist/components/ai-chat-dialogue/message-parser.js +52 -0
  31. package/dist/components/ai-chat-dialogue/tlv.d.ts +7 -0
  32. package/dist/components/ai-chat-dialogue/tlv.js +32 -0
  33. package/dist/components/ai-chat-dialogue/volc-voice-call-client.d.ts +47 -0
  34. package/dist/components/ai-chat-dialogue/volc-voice-call-client.js +246 -0
  35. package/dist/components/ai-correction/index.d.ts +5 -0
  36. package/dist/components/ai-correction/index.js +45 -0
  37. package/dist/components/ai-loading/index.d.ts +3 -0
  38. package/dist/components/ai-loading/index.js +14 -0
  39. package/dist/components/ai-loading/index.module.scss +11 -0
  40. package/dist/components/answer-item/index.d.ts +27 -0
  41. package/dist/components/answer-item/index.js +194 -0
  42. package/dist/components/answer-item/index.module.scss +295 -0
  43. package/dist/components/ask-card/index.d.ts +10 -0
  44. package/dist/components/ask-card/index.js +76 -0
  45. package/dist/components/ask-card/index.module.scss +125 -0
  46. package/dist/components/chat-input/index.d.ts +31 -0
  47. package/dist/components/chat-input/index.js +433 -0
  48. package/dist/components/chat-input/index.module.scss +44 -0
  49. package/dist/components/chat-voice/VoiceCommunication.d.ts +7 -0
  50. package/dist/components/chat-voice/VoiceCommunication.js +69 -0
  51. package/dist/components/chat-voice/VoiceRecord.d.ts +7 -0
  52. package/dist/components/chat-voice/VoiceRecord.js +34 -0
  53. package/dist/components/conversation-delete/index.d.ts +5 -0
  54. package/dist/components/conversation-delete/index.js +24 -0
  55. package/dist/components/dots-loading/index.d.ts +2 -0
  56. package/dist/components/dots-loading/index.js +11 -0
  57. package/dist/components/dots-loading/index.module.scss +45 -0
  58. package/dist/components/empty/index.d.ts +9 -0
  59. package/dist/components/empty/index.js +32 -0
  60. package/dist/components/empty/index.module.scss +27 -0
  61. package/dist/components/excel-components/ExcelCard.d.ts +11 -0
  62. package/dist/components/excel-components/ExcelCard.js +35 -0
  63. package/dist/components/excel-components/ExcelExcuting.d.ts +10 -0
  64. package/dist/components/excel-components/ExcelExcuting.js +263 -0
  65. package/dist/components/excel-components/ExcelFailCard.d.ts +9 -0
  66. package/dist/components/excel-components/ExcelFailCard.js +20 -0
  67. package/dist/components/excel-components/ExcelSuccessCard.d.ts +5 -0
  68. package/dist/components/excel-components/ExcelSuccessCard.js +50 -0
  69. package/dist/components/excel-components/index.module.scss +210 -0
  70. package/dist/components/excel-components/styles.module.scss +186 -0
  71. package/dist/components/file-card/fileCardSidebar.d.ts +8 -0
  72. package/dist/components/file-card/fileCardSidebar.js +56 -0
  73. package/dist/components/file-card/index.d.ts +15 -0
  74. package/dist/components/file-card/index.js +97 -0
  75. package/dist/components/file-card/index.module.scss +139 -0
  76. package/dist/components/file-preview/index.d.ts +3 -0
  77. package/dist/components/file-preview/index.js +229 -0
  78. package/dist/components/file-preview/index.module.scss +120 -0
  79. package/dist/components/file-upload/index.d.ts +16 -0
  80. package/dist/components/file-upload/index.js +238 -0
  81. package/dist/components/file-upload/uploadV1.d.ts +16 -0
  82. package/dist/components/file-upload/uploadV1.js +267 -0
  83. package/dist/components/gimi-sidebar/index.d.ts +17 -0
  84. package/dist/components/gimi-sidebar/index.js +41 -0
  85. package/dist/components/gimi-sidebar/index.module.scss +136 -0
  86. package/dist/components/header/index.d.ts +5 -0
  87. package/dist/components/header/index.js +20 -0
  88. package/dist/components/header/index.module.scss +26 -0
  89. package/dist/components/iconfont-com/index.d.ts +11 -0
  90. package/dist/components/iconfont-com/index.js +29 -0
  91. package/dist/components/index.d.ts +1 -0
  92. package/dist/components/index.js +1 -0
  93. package/dist/components/knowledge-trace/KnowledgeIconComponent.d.ts +7 -0
  94. package/dist/components/knowledge-trace/KnowledgeIconComponent.js +101 -0
  95. package/dist/components/knowledge-trace/classList.d.ts +6 -0
  96. package/dist/components/knowledge-trace/classList.js +72 -0
  97. package/dist/components/knowledge-trace/documentList.d.ts +6 -0
  98. package/dist/components/knowledge-trace/documentList.js +75 -0
  99. package/dist/components/knowledge-trace/index.d.ts +18 -0
  100. package/dist/components/knowledge-trace/index.js +155 -0
  101. package/dist/components/knowledge-trace/index.module.scss +262 -0
  102. package/dist/components/knowledge-trace/interfaces.d.ts +166 -0
  103. package/dist/components/knowledge-trace/interfaces.js +1 -0
  104. package/dist/components/knowledge-trace/videoList.d.ts +6 -0
  105. package/dist/components/knowledge-trace/videoList.js +91 -0
  106. package/dist/components/lottie-img/index.d.ts +8 -0
  107. package/dist/components/lottie-img/index.js +99 -0
  108. package/dist/components/message-actions/CopyButton.d.ts +7 -0
  109. package/dist/components/message-actions/CopyButton.js +33 -0
  110. package/dist/components/message-actions/LikeButton.d.ts +7 -0
  111. package/dist/components/message-actions/LikeButton.js +34 -0
  112. package/dist/components/message-actions/RegenerateButton.d.ts +5 -0
  113. package/dist/components/message-actions/RegenerateButton.js +27 -0
  114. package/dist/components/message-actions/UnLikeButton.d.ts +7 -0
  115. package/dist/components/message-actions/UnLikeButton.js +34 -0
  116. package/dist/components/message-actions/VoicePlay.d.ts +10 -0
  117. package/dist/components/message-actions/VoicePlay.js +74 -0
  118. package/dist/components/message-list/index.d.ts +19 -0
  119. package/dist/components/message-list/index.js +167 -0
  120. package/dist/components/message-list/index.module.scss +304 -0
  121. package/dist/components/no-microphone-root/index.d.ts +6 -0
  122. package/dist/components/no-microphone-root/index.js +36 -0
  123. package/dist/components/no-microphone-root/index.module.scss +42 -0
  124. package/dist/components/preset-agent-content/index.d.ts +8 -0
  125. package/dist/components/preset-agent-content/index.js +24 -0
  126. package/dist/components/preset-agent-content/index.module.scss +48 -0
  127. package/dist/components/quoted-content/index.d.ts +0 -0
  128. package/dist/components/quoted-content/index.js +171 -0
  129. package/dist/components/quoted-content/index.module.scss +76 -0
  130. package/dist/components/reasoning-content/index.d.ts +6 -0
  131. package/dist/components/reasoning-content/index.js +116 -0
  132. package/dist/components/reasoning-content/index.module.scss +164 -0
  133. package/dist/components/reference-content/index.d.ts +28 -0
  134. package/dist/components/reference-content/index.js +125 -0
  135. package/dist/components/reference-content/index.module.scss +73 -0
  136. package/dist/components/templates/CommonChat.d.ts +5 -0
  137. package/dist/components/templates/CommonChat.js +218 -0
  138. package/dist/components/templates/GimiChatComponent.d.ts +4 -0
  139. package/dist/components/templates/GimiChatComponent.js +23 -0
  140. package/dist/components/templates/demo/demo.d.ts +2 -0
  141. package/dist/components/templates/demo/demo.js +110 -0
  142. package/dist/components/templates/index.module.scss +119 -0
  143. package/dist/components/upload-list/index.d.ts +15 -0
  144. package/dist/components/upload-list/index.js +90 -0
  145. package/dist/components/upload-list/index.module.scss +119 -0
  146. package/dist/components/voice-bars/index.d.ts +4 -0
  147. package/dist/components/voice-bars/index.js +174 -0
  148. package/dist/components/voice-check-dialog/index.d.ts +8 -0
  149. package/dist/components/voice-check-dialog/index.js +163 -0
  150. package/dist/components/voice-check-dialog/index.module.scss +9 -0
  151. package/dist/components/voice-recording/index.d.ts +9 -0
  152. package/dist/components/voice-recording/index.js +54 -0
  153. package/dist/components/voice-recording/index.module.scss +41 -0
  154. package/dist/components/work-flow-content/demo.d.ts +3 -0
  155. package/dist/components/work-flow-content/demo.js +11 -0
  156. package/dist/components/work-flow-content/index.d.ts +6 -0
  157. package/dist/components/work-flow-content/index.js +55 -0
  158. package/dist/components/work-flow-content/index.module.scss +23 -0
  159. package/dist/constants.d.ts +24 -0
  160. package/dist/constants.js +24 -0
  161. package/dist/hooks/useChatActions.d.ts +12 -0
  162. package/dist/hooks/useChatActions.js +207 -0
  163. package/dist/hooks/useChatHistory.d.ts +8 -0
  164. package/dist/hooks/useChatHistory.js +225 -0
  165. package/dist/hooks/useChatMessage.d.ts +49 -0
  166. package/dist/hooks/useChatMessage.js +87 -0
  167. package/dist/hooks/useChatRecommend.d.ts +8 -0
  168. package/dist/hooks/useChatRecommend.js +126 -0
  169. package/dist/hooks/useChatStream.d.ts +20 -0
  170. package/dist/hooks/useChatStream.js +244 -0
  171. package/dist/hooks/useChatUI.d.ts +32 -0
  172. package/dist/hooks/useChatUI.js +134 -0
  173. package/dist/hooks/useChatVoice.d.ts +11 -0
  174. package/dist/hooks/useChatVoice.js +379 -0
  175. package/dist/hooks/useCommonChatAPI.d.ts +27 -0
  176. package/dist/hooks/useCommonChatAPI.js +1276 -0
  177. package/dist/hooks/useFile.d.ts +13 -0
  178. package/dist/hooks/useFile.js +288 -0
  179. package/dist/hooks/useKnowledgeService.d.ts +17 -0
  180. package/dist/hooks/useKnowledgeService.js +210 -0
  181. package/dist/hooks/useLastEventId.d.ts +8 -0
  182. package/dist/hooks/useLastEventId.js +66 -0
  183. package/dist/hooks/useLongPoll.d.ts +3 -0
  184. package/dist/hooks/useLongPoll.js +111 -0
  185. package/dist/hooks/useScroll.d.ts +4 -0
  186. package/dist/hooks/useScroll.js +172 -0
  187. package/dist/index.d.ts +1 -0
  188. package/dist/index.js +1 -0
  189. package/dist/interfaces/chatMessage.d.ts +139 -0
  190. package/dist/interfaces/fileInterface.d.ts +10 -0
  191. package/dist/interfaces/fileInterface.js +11 -0
  192. package/dist/interfaces/knowledgeTrace.d.ts +177 -0
  193. package/dist/store/hooks.d.ts +4 -0
  194. package/dist/store/hooks.js +3 -0
  195. package/dist/store/index.d.ts +7 -0
  196. package/dist/store/index.js +7 -0
  197. package/dist/store/slices/gimiMenuSlice.d.ts +95 -0
  198. package/dist/store/slices/gimiMenuSlice.js +251 -0
  199. package/dist/utils/chatInputUtil.d.ts +19 -0
  200. package/dist/utils/chatInputUtil.js +45 -0
  201. package/dist/utils/tools.d.ts +50 -0
  202. package/dist/utils/tools.js +474 -0
  203. package/dist/utils/voice-stream.d.ts +119 -0
  204. package/dist/utils/voice-stream.js +1162 -0
  205. package/package.json +2 -3
  206. package/LICENSE +0 -21
@@ -0,0 +1,474 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
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
+ 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); }
6
+ 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; }
7
+ 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; }
8
+ 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; }
9
+ 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; }
10
+ 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; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
+ 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); }
13
+ 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); }
14
+ 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); } }
15
+ 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); }); }; }
16
+ import { FileStatus } from "../interfaces/fileInterface";
17
+ import { set, cloneDeep } from 'lodash';
18
+ export function downloadExcelByUrl(_x) {
19
+ return _downloadExcelByUrl.apply(this, arguments);
20
+ }
21
+ function _downloadExcelByUrl() {
22
+ _downloadExcelByUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(url) {
23
+ var fileName,
24
+ response,
25
+ blob,
26
+ objectUrl,
27
+ link,
28
+ _args2 = arguments;
29
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
30
+ while (1) switch (_context2.prev = _context2.next) {
31
+ case 0:
32
+ fileName = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : '文件下载.xlsx';
33
+ _context2.prev = 1;
34
+ _context2.next = 4;
35
+ return fetch(url);
36
+ case 4:
37
+ response = _context2.sent;
38
+ if (response.ok) {
39
+ _context2.next = 7;
40
+ break;
41
+ }
42
+ throw new Error('文件下载失败');
43
+ case 7:
44
+ _context2.next = 9;
45
+ return response.blob();
46
+ case 9:
47
+ blob = _context2.sent;
48
+ objectUrl = URL.createObjectURL(blob); // 创建a标签下载
49
+ link = document.createElement('a');
50
+ link.href = objectUrl;
51
+ link.download = fileName;
52
+ document.body.appendChild(link);
53
+ link.click();
54
+
55
+ // 清理资源
56
+ setTimeout(function () {
57
+ document.body.removeChild(link);
58
+ URL.revokeObjectURL(objectUrl); // 释放内存
59
+ }, 0);
60
+ _context2.next = 22;
61
+ break;
62
+ case 19:
63
+ _context2.prev = 19;
64
+ _context2.t0 = _context2["catch"](1);
65
+ console.error('下载失败:', _context2.t0);
66
+ case 22:
67
+ case "end":
68
+ return _context2.stop();
69
+ }
70
+ }, _callee2, null, [[1, 19]]);
71
+ }));
72
+ return _downloadExcelByUrl.apply(this, arguments);
73
+ }
74
+ export function parseMessageContent(str) {
75
+ var result = {
76
+ moduleInfo: null,
77
+ content: ''
78
+ };
79
+ if (typeof str !== 'string') return result;
80
+ try {
81
+ var parsedRs = JSON.parse(str);
82
+ // 单工作流模式,返回是object
83
+ if (Object.prototype.toString.call(parsedRs) === '[object Object]') {
84
+ // 有content属性: 文本节点
85
+ if ('content' in parsedRs) {
86
+ result.content = String(parsedRs.content);
87
+ // ask/skill: 操作节点
88
+ } else if (parsedRs.moduleType === 'ask' || parsedRs.moduleType === 'skill') {
89
+ result.moduleInfo = parsedRs;
90
+ // 如果没有moduleType,说明就是字符串content,直接设值
91
+ } else {
92
+ result.content = str;
93
+ }
94
+ }
95
+ // react编排模式是数组, 处理数组
96
+ if (Array.isArray(parsedRs)) {
97
+ parsedRs.forEach(function (item) {
98
+ if (item.moduleType === 'ask' || item.moduleType === 'skill') {
99
+ result.moduleInfo = item;
100
+ } else {
101
+ result.content = String(item.content);
102
+ }
103
+ });
104
+ }
105
+ } catch (error) {
106
+ result.content = str;
107
+ }
108
+ return result;
109
+ }
110
+ export function processString(str) {
111
+ var _parseMessageContent = parseMessageContent(str),
112
+ content = _parseMessageContent.content;
113
+ return content;
114
+ }
115
+ export var getKnowledgeTraceListFromConent = function getKnowledgeTraceListFromConent(matchMessage, sendMessage) {
116
+ var _sendMessage$quoteTea, _sendMessage$quotePro;
117
+ var rawItems = [];
118
+ if (!matchMessage) return [];
119
+ var qutoTeachModuleIds = (sendMessage === null || sendMessage === void 0 || (_sendMessage$quoteTea = sendMessage.quoteTeachModelList) === null || _sendMessage$quoteTea === void 0 ? void 0 : _sendMessage$quoteTea.map(function (item) {
120
+ return item.teachModelId;
121
+ })) || [];
122
+ var quoteProductIds = (sendMessage === null || sendMessage === void 0 || (_sendMessage$quotePro = sendMessage.quoteProductList) === null || _sendMessage$quotePro === void 0 ? void 0 : _sendMessage$quotePro.map(function (item) {
123
+ return item.productId;
124
+ })) || [];
125
+ var tryParseJson = function tryParseJson(str) {
126
+ if (!str || typeof str !== 'string') return null;
127
+ try {
128
+ return JSON.parse(str);
129
+ } catch (e) {
130
+ return null;
131
+ }
132
+ };
133
+ var filter = function filter() {
134
+ var content = processString(matchMessage.content || '');
135
+ if (!content) return;
136
+ var regex = /<knowledge>([\s\S]*?)<\/knowledge>/gi;
137
+ var match;
138
+ var _loop = function _loop() {
139
+ var inner = match[1].trim();
140
+ if (!inner) return 1; // continue
141
+
142
+ // 多种尝试解析策略,兼容转义/HTML 实体等情况
143
+ var parsed = tryParseJson(inner) || tryParseJson(inner.replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&amp;/g, '&')) || tryParseJson(inner.replace(/\\"/g, '"')) || (inner.startsWith('"') ? function () {
144
+ try {
145
+ return JSON.parse(JSON.parse(inner));
146
+ } catch (e) {
147
+ return null;
148
+ }
149
+ }() : null) || tryParseJson(inner.replace(/\\/g, ''));
150
+ if (!parsed) {
151
+ // 尝试从字符串中提取 JSON 数组/对象片段
152
+ var arrayMatch = inner.match(/(\[([\s\S]*?)\])/);
153
+ if (arrayMatch) {
154
+ parsed = tryParseJson(arrayMatch[1]) || tryParseJson(arrayMatch[1].replace(/\\"/g, '"'));
155
+ } else {
156
+ var objMatch = inner.match(/(\{[\s\S]*\})/);
157
+ if (objMatch) {
158
+ parsed = tryParseJson(objMatch[1]) || tryParseJson(objMatch[1].replace(/\\"/g, '"'));
159
+ }
160
+ }
161
+ }
162
+ if (parsed) {
163
+ if (Array.isArray(parsed)) {
164
+ parsed.forEach(function (item) {
165
+ return rawItems.push(item);
166
+ });
167
+ } else {
168
+ rawItems.push(parsed);
169
+ }
170
+ }
171
+ };
172
+ while ((match = regex.exec(content)) !== null) {
173
+ if (_loop()) continue;
174
+ }
175
+ };
176
+ filter();
177
+ // 聚合:按 type 分组
178
+ var grouped = rawItems.reduce(function (acc, item) {
179
+ var _item$type;
180
+ if (!item || _typeof(item) !== 'object') return acc;
181
+ var type = String((_item$type = item.type) !== null && _item$type !== void 0 ? _item$type : '').trim();
182
+ var id = item.id === undefined || item.id === null ? '' : String(item.id);
183
+ var productIds = item.productIds || [];
184
+ if (!type) return acc;
185
+ if (!acc[type]) acc[type] = [];
186
+ var applyProductIds = qutoTeachModuleIds.length > 0 ? qutoTeachModuleIds : quoteProductIds.length > 0 ? quoteProductIds : productIds;
187
+ acc[type].push({
188
+ id: id,
189
+ productIds: applyProductIds
190
+ });
191
+ return acc;
192
+ }, {});
193
+
194
+ // 转成数组格式 [{type, ids: []}]
195
+ var knowledgeList = Object.keys(grouped).map(function (type) {
196
+ return _objectSpread(_objectSpread({
197
+ type: type,
198
+ resources: grouped[type]
199
+ }, qutoTeachModuleIds.length > 0 && {
200
+ qutoType: 'teachModel'
201
+ }), quoteProductIds.length > 0 && {
202
+ qutoType: 'product'
203
+ });
204
+ });
205
+ return knowledgeList;
206
+ };
207
+
208
+ /**
209
+ * 指数退避重试逻辑
210
+ * @param fn 要执行的异步函数
211
+ * @param options 重试配置
212
+ */
213
+ export var retryWithExponentialBackoff = /*#__PURE__*/function () {
214
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fn, options) {
215
+ var maxRetries, initialDelay, factor, onRetry, attempt, delay, wait, response;
216
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
217
+ while (1) switch (_context.prev = _context.next) {
218
+ case 0:
219
+ maxRetries = options.maxRetries, initialDelay = options.initialDelay, factor = options.factor, onRetry = options.onRetry;
220
+ attempt = 0;
221
+ delay = initialDelay;
222
+ wait = function wait(delay) {
223
+ return new Promise(function (resolve) {
224
+ setTimeout(resolve, delay);
225
+ });
226
+ };
227
+ case 4:
228
+ if (!(attempt <= maxRetries)) {
229
+ _context.next = 23;
230
+ break;
231
+ }
232
+ _context.prev = 5;
233
+ _context.next = 8;
234
+ return fn();
235
+ case 8:
236
+ response = _context.sent;
237
+ return _context.abrupt("return", response);
238
+ case 12:
239
+ _context.prev = 12;
240
+ _context.t0 = _context["catch"](5);
241
+ if (!(attempt === maxRetries)) {
242
+ _context.next = 16;
243
+ break;
244
+ }
245
+ throw _context.t0;
246
+ case 16:
247
+ if (onRetry) {
248
+ onRetry(attempt); // 调用重试回调
249
+ }
250
+ _context.next = 19;
251
+ return wait(delay);
252
+ case 19:
253
+ // 延迟
254
+ delay *= factor; // 指数增长
255
+ attempt++;
256
+ case 21:
257
+ _context.next = 4;
258
+ break;
259
+ case 23:
260
+ case "end":
261
+ return _context.stop();
262
+ }
263
+ }, _callee, null, [[5, 12]]);
264
+ }));
265
+ return function retryWithExponentialBackoff(_x2, _x3) {
266
+ return _ref.apply(this, arguments);
267
+ };
268
+ }();
269
+
270
+ /**
271
+ * 将秒数转换为中文格式时间字符串 (时长xxx分钟)
272
+ * @param seconds - 待转换的秒数(必须为非负整数)
273
+ * @returns 格式化后的中文时间字符串
274
+ */
275
+ export function formatSecondsToChinese(seconds) {
276
+ // 边界值处理:确保输入为非负整数,非法值返回默认值 "0分"
277
+ if (typeof seconds !== 'number' || isNaN(seconds) || seconds < 0) {
278
+ console.warn('输入秒数必须为非负整数,已返回默认值 "0"');
279
+ return 0;
280
+ }
281
+
282
+ // 向下取整秒数后,按分钟向上取整(任何大于0的秒数都会被视为至少1分)
283
+ var totalSeconds = Math.floor(seconds);
284
+ var minutes = Math.ceil(totalSeconds / 60);
285
+ return minutes;
286
+ }
287
+ export function replaceBraces(str) {
288
+ if (str === null || str === '') {
289
+ return str === '' ? '' : String(str);
290
+ }
291
+ var inputStr = String(str);
292
+ // 添加s修饰符,使.能匹配换行符
293
+ return inputStr.replace(/\{\{([\s\S]*?)\}\}/g, '[$1]');
294
+ }
295
+
296
+ /**
297
+ * 将字节数转换为KB或MB格式的字符串
298
+ * @param {number} bytes - 字节数
299
+ * @returns {string} 格式化后的大小字符串(**KB 或 **MB)
300
+ */
301
+ export function formatSizeToKB(bytes) {
302
+ // 边界值处理:确保输入为非负数
303
+ if (typeof bytes !== 'number' || isNaN(bytes) || bytes < 0) {
304
+ return '0KB';
305
+ }
306
+
307
+ // 换算成MB
308
+ var mb = bytes / (1024 * 1024);
309
+
310
+ // 如果大于等于1MB,返回MB格式
311
+ if (mb >= 1) {
312
+ return "".concat(mb.toFixed(2), "MB");
313
+ }
314
+
315
+ // 小于1MB,返回KB格式
316
+ var kb = bytes / 1024;
317
+ return "".concat(kb.toFixed(2), "KB");
318
+ }
319
+ export var fileValidation = function fileValidation(fileList) {
320
+ if ((fileList === null || fileList === void 0 ? void 0 : fileList.length) === 0) return '';
321
+ switch (fileList[0].status) {
322
+ case FileStatus.UPLOAD_FAILED:
323
+ return '文件上传失败,请重试';
324
+ case FileStatus.ANALYSE_FAILED:
325
+ return '文件解析失败,请重试';
326
+ case FileStatus.UPLOADING:
327
+ return '文件正在上传中,请稍后';
328
+ case FileStatus.PADDING:
329
+ return '文件正在解析中,请稍后';
330
+ case FileStatus.RETRING:
331
+ return '文件正在重试处理中,请稍后';
332
+ default:
333
+ return '';
334
+ }
335
+ };
336
+
337
+ /**
338
+ * 过滤用户输出中与默认模版相同的模板部分
339
+ * @param {*} prompt 我要生成一个{{模版名称}}....
340
+ * @param {*} input 用户输入的内容
341
+ * @returns
342
+ */
343
+ export function filterPropmptFromUserInput(prompt, input) {
344
+ if (!prompt) return input || '';
345
+ if (!input) return '';
346
+ var filterInput = input;
347
+ // 正则表达式匹配{{任意内容}},非贪婪模式避免匹配过多
348
+ var regex = /\[(.*?)\]/g;
349
+ // 匹配prompt中所有符合格式的内容,返回数组(无匹配则返回空数组)
350
+ var matchArr = prompt.replaceAll('{{', '[').replaceAll('}}', ']').match(regex) || [];
351
+ matchArr.forEach(function (match) {
352
+ filterInput = filterInput.replace(match, '').trim();
353
+ });
354
+ return filterInput;
355
+ }
356
+ export var updatedSkillResult = function updatedSkillResult(resData) {
357
+ return resData.map(function (item) {
358
+ // 判断条件:moduleType 是 'skill' 且 skillResult 存在有效值
359
+ if (item.moduleType === 'skill' && item !== null && item !== void 0 && item.skillResult) {
360
+ var _item$moduleInfo$data;
361
+ // 深拷贝当前项,避免修改原对象
362
+ var updatedItem = cloneDeep(item);
363
+ var detail = (_item$moduleInfo$data = item.moduleInfo.data.results) === null || _item$moduleInfo$data === void 0 ? void 0 : _item$moduleInfo$data.skillResult;
364
+ // 提取有效的 skillResult 数据
365
+ var validSkillResult = _objectSpread({}, item.skillResult);
366
+ if ((item === null || item === void 0 ? void 0 : item.skillResult.requestStatus) === 0) {
367
+ validSkillResult.message = detail === null || detail === void 0 ? void 0 : detail.message;
368
+ validSkillResult.skillType = detail === null || detail === void 0 ? void 0 : detail.skillType;
369
+ }
370
+ // 赋值到目标位置(这里可以根据需要调整赋值逻辑)
371
+ set(updatedItem, 'moduleInfo.data.results.skillResult', validSkillResult);
372
+ return updatedItem;
373
+ }
374
+ // 不符合条件的项直接返回原项
375
+ return item;
376
+ });
377
+ };
378
+ export function getValueFromDynamicKey(jsonStr) {
379
+ if (!jsonStr) {
380
+ return null;
381
+ }
382
+ try {
383
+ // 解析JSON字符串为对象
384
+ var obj = JSON.parse(jsonStr);
385
+
386
+ // 获取对象的第一个键(无论键名是什么)
387
+ var firstKey = Object.keys(obj)[0];
388
+
389
+ // 返回对应的值
390
+ return obj[firstKey];
391
+ } catch (e) {
392
+ // 处理解析错误,返回null或其他默认值
393
+ console.error('解析失败:', e);
394
+ return null;
395
+ }
396
+ }
397
+ var checkHasRetry = function checkHasRetry(skillResult, isLast) {
398
+ if (!skillResult) return true;
399
+ if (isLast && parseInt(skillResult === null || skillResult === void 0 ? void 0 : skillResult.requestStatus, 10) === 2) {
400
+ return false;
401
+ }
402
+ return true;
403
+ };
404
+ export function getSelectValue(content, moduleInfo, isLastItem, nextItem) {
405
+ if (!content) return null;
406
+ if ((moduleInfo === null || moduleInfo === void 0 ? void 0 : moduleInfo.moduleType) !== 'ask') return null;
407
+ if (isLastItem) return null;
408
+ if (!nextItem) return null;
409
+ return getValueFromDynamicKey("".concat(nextItem.inputModel));
410
+ }
411
+ export function getDisableUploadFile(content, moduleInfo, isLastItem) {
412
+ if (!content) return true;
413
+ if ((moduleInfo === null || moduleInfo === void 0 ? void 0 : moduleInfo.moduleType) !== 'ask') return true;
414
+ return !isLastItem;
415
+ }
416
+ export function formatFields(dataList, chatList) {
417
+ // 创建一个以 chatId 为键的映射,存储 role === 0 的数据
418
+ var roleZeroMap = new Map();
419
+
420
+ // 第一次遍历:收集所有 role === 0 的数据
421
+ dataList.forEach(function (item) {
422
+ if (item.role === 0 && item.chatId !== null) {
423
+ roleZeroMap.set(item.chatId, {
424
+ relatedCount: item.relatedCount,
425
+ relatedCourseRecommendation: item.relatedCourseRecommendation,
426
+ sectionId: item.sectionId,
427
+ questionId: item.id,
428
+ videoResourceList: item.videoResourceList,
429
+ query: item.query,
430
+ vipLevel: item.vipLevel,
431
+ needSearch: item.needSearch,
432
+ relatedResourceList: item.relatedResourceList,
433
+ reasoningStatus: item.reasoningContentState
434
+ });
435
+ }
436
+ });
437
+ var allMessages = [].concat(_toConsumableArray(dataList), _toConsumableArray(chatList));
438
+
439
+ // 第二次遍历:为 role === 1 的数据赋值
440
+ dataList.forEach(function (item, index) {
441
+ if (item.role === 1 && item.chatId !== null && roleZeroMap.has(item.chatId)) {
442
+ var _roleZeroData$related;
443
+ var roleZeroData = roleZeroMap.get(item.chatId);
444
+ item.relatedCount = roleZeroData.relatedCount;
445
+ item.relatedCourseRecommendation = roleZeroData.relatedCourseRecommendation ? JSON.parse(roleZeroData.relatedCourseRecommendation) : [];
446
+ item.questionId = roleZeroData.questionId;
447
+ item.sectionId = roleZeroData.sectionId;
448
+ item.videoResourceList = roleZeroData.videoResourceList;
449
+ item.query = roleZeroData.query;
450
+ item.needSearch = roleZeroData.needSearch;
451
+ item.relatedResourceList = roleZeroData.relatedResourceList ? JSON.parse(((_roleZeroData$related = roleZeroData.relatedResourceList.find(function (item) {
452
+ return item.type === 3;
453
+ })) === null || _roleZeroData$related === void 0 ? void 0 : _roleZeroData$related.content) || '[]') : [];
454
+ item.vipLevel = roleZeroData.vipLevel;
455
+ item.expand = false; // 是否展开
456
+ item.reasoningStatus = item.reasoningContentState ? 2 : 3; // 推理状态 1 正在推理 2 推理完成 3 停止
457
+ var _parseMessageContent2 = parseMessageContent(item.content || ''),
458
+ moduleInfo = _parseMessageContent2.moduleInfo,
459
+ content = _parseMessageContent2.content;
460
+ item.stop = item.contentState ? 0 : 1; // 推理状态 0 推理完成 1 停止
461
+ // item.moduleType = item.content ? JSON.parse(item.content).moduleType : null;
462
+ item.moduleInfo = moduleInfo;
463
+ if (content) {
464
+ item.content = content;
465
+ }
466
+ var isLastItem = index === allMessages.length - 1;
467
+ var nextItem = allMessages[index + 1];
468
+ item.selectValue = getSelectValue(item.content, moduleInfo, isLastItem, nextItem);
469
+ item.reTryed = checkHasRetry(item.skillResult, index === dataList.length - 1); // 最新的一个skill生成结果失败,才可以重试
470
+ item.disableUploadFile = getDisableUploadFile(item.content, moduleInfo, isLastItem);
471
+ }
472
+ });
473
+ return dataList;
474
+ }
@@ -0,0 +1,119 @@
1
+ declare type HandlerModeType = 'asr_only' | 'tts_only' | 'short_asr_only';
2
+ declare type EngineModelType = '16k_zh' | '8k_zh';
3
+ /** 一句话播放相关配置 */
4
+ interface Configuration {
5
+ /** 引擎模型 */
6
+ engineModel?: EngineModelType;
7
+ /** 是否过滤脏字 */
8
+ filterDirty?: 1 | 0;
9
+ /** 是否过滤语气词 */
10
+ filterModal?: 1 | 0;
11
+ /** 是否过滤标点 */
12
+ filterPunc?: 1 | 0;
13
+ /** 是否数字智能转换 */
14
+ convertNum?: 1 | 0;
15
+ }
16
+ /** WebSocket 消息类型 */
17
+ interface WebSocketMessage {
18
+ type: string;
19
+ stage?: string;
20
+ message?: string;
21
+ [key: string]: any;
22
+ }
23
+ /** 语音消息回调类型 */
24
+ declare type VoiceMessageCallback = (data: WebSocketMessage, modeType: HandlerModeType | null) => void;
25
+ /**
26
+ * WebSocket 启动指令参数类型定义
27
+ * 对应 start 指令的消息体结构
28
+ */
29
+ export interface StartMessageParams {
30
+ /** 指令类型 - 固定值 "start" */
31
+ type?: 'start';
32
+ /**
33
+ * 工作模式
34
+ * - asr_only: 仅语音识别模式
35
+ * - tts_only: 仅语音合成模式
36
+ * - short_asr_only: 一句话语音识别模式(目前用的腾讯云)
37
+ */
38
+ mode?: HandlerModeType;
39
+ /** 预留字段 - 用户ID */
40
+ userId?: string;
41
+ /**
42
+ * ASR配置(ASR模式必填)
43
+ * 仅在 mode 为 asr_only/short_asr_only 时生效
44
+ */
45
+ asr?: {
46
+ /** 音频格式 - 固定值 "pcm" */
47
+ format: 'pcm';
48
+ /** 采样率 - 固定值 16000 */
49
+ sampleRate: 16000;
50
+ /** 位深度 - 固定值 16 */
51
+ bits: 16;
52
+ /** 声道数 - 固定值 1(单声道) */
53
+ channel: 1;
54
+ /** 是否启用标点符号 - 可选,默认 false */
55
+ enablePunctuation?: boolean;
56
+ };
57
+ /**
58
+ * TTS配置(TTS模式必填)
59
+ * 仅在 mode 为 tts_only 时生效
60
+ */
61
+ tts?: {
62
+ /** 音色类型(必填)- 如 "zh_female_shuangkuaisisi_emo_v2_mars_bigtts" */
63
+ voiceType: string;
64
+ /** 语速 - 可选,范围 0.5-2.0,默认 1.0(1.2表示加快20%) */
65
+ speed?: number;
66
+ /** 音量 - 可选,范围 0.1-3.0,默认 1.0(1.5表示提高50%) */
67
+ volume?: number;
68
+ /** 音调 - 可选,范围 0.5-2.0,默认 1.0 */
69
+ pitch?: number;
70
+ };
71
+ }
72
+ declare class VoiceRecorder {
73
+ private mediaRecorder;
74
+ private audioPlayer;
75
+ private ws;
76
+ private onMessageCallback;
77
+ setOnMessageCallback(cb: VoiceMessageCallback): void;
78
+ private ttsSessionId;
79
+ private networkBound;
80
+ private handleOffline;
81
+ private handleOnline;
82
+ private bindNetworkEvents;
83
+ private unbindNetworkEvents;
84
+ private initStreamingAudioPlayer;
85
+ convertFloat32ToInt16(float32Array: Float32Array): Int16Array;
86
+ connectHandler(modeType: HandlerModeType): Promise<void>;
87
+ startHandler(modeType: HandlerModeType, msgPrams?: StartMessageParams | null): Promise<void>;
88
+ toggleRecord(): Promise<void>;
89
+ stopRecordingEvent(): Promise<void>;
90
+ endHandler(): Promise<void>;
91
+ disconnectHandler(): Promise<void>;
92
+ recordingCancel(data: {
93
+ modeType?: string;
94
+ }): Promise<void>;
95
+ recordAndRecognize: () => Promise<void>;
96
+ recordingClick(data: {
97
+ modeType?: string;
98
+ }, msgPrams?: StartMessageParams | null, callBack?: () => void): Promise<void>;
99
+ writeString(view: DataView, offset: number, string: string): void;
100
+ /**
101
+ * 创建标准 WAV 格式的 Blob
102
+ * @param {Int16Array} pcmData - PCM 音频数据
103
+ * @param {number} sampleRate - 采样率
104
+ * @param {number} numChannels - 声道数
105
+ * @param {number} bitsPerSample - 位深度
106
+ * @returns {Blob} WAV 格式的 Blob
107
+ */
108
+ createWavBlob(pcmData: Int16Array, sampleRate: number, numChannels: number, bitsPerSample: number): Blob;
109
+ blobToBase64(blob: Blob): Promise<string>;
110
+ toggleTencentRecord(configuration?: Configuration | null, onResult?: (result: any) => void): Promise<void>;
111
+ /** 清理tencentRecorder */
112
+ clearTencentRecorder(): void;
113
+ callTencentAsrApi(base64Data: string, configuration?: Configuration | null): Promise<any | null>;
114
+ startTTS(text?: string, msgPrams?: StartMessageParams | null): Promise<void>;
115
+ resetTTSPlayer(): void;
116
+ sendTextForTTS(text: string): Promise<void>;
117
+ }
118
+ declare const VoiceRecorderEvent: VoiceRecorder;
119
+ export default VoiceRecorderEvent;