@blueking/ai-ui-sdk 0.0.14 → 0.0.15-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/dist/assets/images/ai.png +0 -0
  2. package/dist/assets/images/user.png +0 -0
  3. package/dist/assets/svg/picture-fail.svg +1 -0
  4. package/dist/common/chart-helper.d.ts +1 -1
  5. package/dist/common/chart-helper.js +173 -0
  6. package/dist/common/util.d.ts +31 -0
  7. package/dist/common/util.js +177 -0
  8. package/dist/component/render-image/index.script.vue.js +37 -0
  9. package/dist/component/render-image/index.vue.d.ts +6 -0
  10. package/dist/component/render-image/index.vue.js +3 -0
  11. package/dist/component/render-input/index.script.vue.js +205 -0
  12. package/dist/component/render-input/index.vue.css +134 -0
  13. package/dist/component/render-input/index.vue.d.ts +18 -0
  14. package/dist/component/render-input/index.vue.js +5 -0
  15. package/dist/component/render-input/render-drag.script.vue.js +61 -0
  16. package/dist/component/render-input/render-drag.vue.css +32 -0
  17. package/dist/component/render-input/render-drag.vue.d.ts +13 -0
  18. package/dist/component/render-input/render-drag.vue.js +5 -0
  19. package/dist/component/render-input/render-quill.script.vue.js +197 -0
  20. package/dist/component/render-input/render-quill.vue.css +27 -0
  21. package/dist/component/render-input/render-quill.vue.d.ts +24 -0
  22. package/dist/component/render-input/render-quill.vue.js +4 -0
  23. package/dist/component/render-knowledge-icon/index.script.vue.js +40 -0
  24. package/dist/component/render-knowledge-icon/index.vue.css +4 -0
  25. package/dist/component/render-knowledge-icon/index.vue.d.ts +14 -0
  26. package/dist/component/render-knowledge-icon/index.vue.js +5 -0
  27. package/dist/component/render-markdown/mark-down-code.d.ts +2 -0
  28. package/dist/component/render-markdown/mark-down-code.js +171 -0
  29. package/dist/component/render-markdown/mark-down-emoji.d.ts +2 -0
  30. package/dist/component/render-markdown/mark-down-emoji.js +4 -0
  31. package/dist/component/render-markdown/mark-down.d.ts +74 -0
  32. package/dist/component/render-markdown/mark-down.js +147 -0
  33. package/dist/component/render-markdown/mark-down.postcss.css +131 -0
  34. package/dist/component/render-message/image-not-supported-message.script.vue.js +99 -0
  35. package/dist/component/render-message/image-not-supported-message.vue.css +66 -0
  36. package/dist/component/render-message/image-not-supported-message.vue.d.ts +21 -0
  37. package/dist/component/render-message/image-not-supported-message.vue.js +5 -0
  38. package/dist/component/render-message/index.script.vue.js +104 -0
  39. package/dist/component/render-message/index.vue.d.ts +13 -0
  40. package/dist/component/render-message/index.vue.js +3 -0
  41. package/dist/component/render-message/openai-message.script.vue.js +215 -0
  42. package/dist/component/render-message/openai-message.vue.css +98 -0
  43. package/dist/component/render-message/openai-message.vue.d.ts +15 -0
  44. package/dist/component/render-message/openai-message.vue.js +5 -0
  45. package/dist/component/render-message/skeleton-message.script.vue.js +7 -0
  46. package/dist/component/render-message/skeleton-message.vue.css +7 -0
  47. package/dist/component/render-message/skeleton-message.vue.d.ts +2 -0
  48. package/dist/component/render-message/skeleton-message.vue.js +6 -0
  49. package/dist/component/render-message/system-message.script.vue.js +17 -0
  50. package/dist/component/render-message/system-message.vue.css +20 -0
  51. package/dist/component/render-message/system-message.vue.d.ts +6 -0
  52. package/dist/component/render-message/system-message.vue.js +5 -0
  53. package/dist/component/render-message/time-message.script.vue.js +41 -0
  54. package/dist/component/render-message/time-message.vue.css +14 -0
  55. package/dist/component/render-message/time-message.vue.d.ts +6 -0
  56. package/dist/component/render-message/time-message.vue.js +5 -0
  57. package/dist/component/render-message/token-expired-message.script.vue.js +78 -0
  58. package/dist/component/render-message/token-expired-message.vue.css +60 -0
  59. package/dist/component/render-message/token-expired-message.vue.d.ts +15 -0
  60. package/dist/component/render-message/token-expired-message.vue.js +5 -0
  61. package/dist/component/render-message/user-message.script.vue.js +241 -0
  62. package/dist/component/render-message/user-message.vue.css +100 -0
  63. package/dist/component/render-message/user-message.vue.d.ts +21 -0
  64. package/dist/component/render-message/user-message.vue.js +5 -0
  65. package/dist/css/fonts/iconcool.eot +0 -0
  66. package/dist/css/fonts/iconcool.svg +53 -0
  67. package/dist/css/fonts/iconcool.ttf +0 -0
  68. package/dist/css/fonts/iconcool.woff +0 -0
  69. package/dist/css/iconcool.js +10 -0
  70. package/dist/css/style.css +43 -0
  71. package/dist/event/index.d.ts +4 -0
  72. package/dist/event/index.js +18 -0
  73. package/dist/hooks/use-chat.d.ts +844 -20
  74. package/dist/hooks/use-chat.js +565 -0
  75. package/dist/hooks/use-click-proxy.js +77 -0
  76. package/dist/hooks/use-http.d.ts +15 -0
  77. package/dist/hooks/use-http.js +48 -0
  78. package/dist/hooks/use-mouse-drag.d.ts +13 -0
  79. package/dist/hooks/use-mouse-drag.js +59 -0
  80. package/dist/hooks/use-reference-doc.d.ts +1 -1
  81. package/dist/hooks/use-reference-doc.js +185 -0
  82. package/dist/hooks/use-style.js +11 -0
  83. package/dist/hooks/use-summary.d.ts +1 -1
  84. package/dist/hooks/use-summary.js +55 -0
  85. package/dist/hooks/use-think.js +135 -0
  86. package/dist/http/fetch/error-interceptor.d.ts +3 -0
  87. package/dist/http/fetch/error-interceptor.js +28 -0
  88. package/dist/http/fetch/index.d.ts +25 -0
  89. package/dist/http/fetch/index.js +182 -0
  90. package/dist/http/fetch/request-error.d.ts +6 -0
  91. package/dist/http/fetch/request-error.js +25 -0
  92. package/dist/http/fetch/success-interceptor.d.ts +3 -0
  93. package/dist/http/fetch/success-interceptor.js +92 -0
  94. package/dist/http/helper/knowledge.d.ts +43 -0
  95. package/dist/http/helper/knowledge.js +227 -0
  96. package/dist/http/helper/permission.d.ts +7 -0
  97. package/dist/http/helper/permission.js +28 -0
  98. package/dist/http/helper/session.d.ts +31 -0
  99. package/dist/http/helper/session.js +147 -0
  100. package/dist/http/helper/tool.d.ts +13 -0
  101. package/dist/http/helper/tool.js +49 -0
  102. package/dist/main.d.ts +17 -2
  103. package/dist/main.js +29 -239
  104. package/dist/node_modules/bkui-vue/lib/icon/angle-double-down-line.js +191 -0
  105. package/dist/node_modules/bkui-vue/lib/icon/angle-double-left-line.js +191 -0
  106. package/dist/node_modules/bkui-vue/lib/icon/angle-double-left.js +191 -0
  107. package/dist/node_modules/bkui-vue/lib/icon/angle-double-right-line.js +191 -0
  108. package/dist/node_modules/bkui-vue/lib/icon/angle-double-right.js +191 -0
  109. package/dist/node_modules/bkui-vue/lib/icon/angle-double-up-line.js +191 -0
  110. package/dist/node_modules/bkui-vue/lib/icon/angle-down-fill.js +191 -0
  111. package/dist/node_modules/bkui-vue/lib/icon/angle-down-line.js +191 -0
  112. package/dist/node_modules/bkui-vue/lib/icon/angle-down.js +191 -0
  113. package/dist/node_modules/bkui-vue/lib/icon/angle-left.js +191 -0
  114. package/dist/node_modules/bkui-vue/lib/icon/angle-right.js +191 -0
  115. package/dist/node_modules/bkui-vue/lib/icon/angle-up-fill.js +191 -0
  116. package/dist/node_modules/bkui-vue/lib/icon/angle-up.js +191 -0
  117. package/dist/node_modules/bkui-vue/lib/icon/archive-fill.js +191 -0
  118. package/dist/node_modules/bkui-vue/lib/icon/arrows-left.js +191 -0
  119. package/dist/node_modules/bkui-vue/lib/icon/arrows-right.js +191 -0
  120. package/dist/node_modules/bkui-vue/lib/icon/assistant.js +191 -0
  121. package/dist/node_modules/bkui-vue/lib/icon/audio-fill.js +191 -0
  122. package/dist/node_modules/bkui-vue/lib/icon/bk.js +191 -0
  123. package/dist/node_modules/bkui-vue/lib/icon/circle.js +191 -0
  124. package/dist/node_modules/bkui-vue/lib/icon/close-line.js +191 -0
  125. package/dist/node_modules/bkui-vue/lib/icon/close.js +191 -0
  126. package/dist/node_modules/bkui-vue/lib/icon/code.js +191 -0
  127. package/dist/node_modules/bkui-vue/lib/icon/cog-shape.js +191 -0
  128. package/dist/node_modules/bkui-vue/lib/icon/collapse-left.js +191 -0
  129. package/dist/node_modules/bkui-vue/lib/icon/copy-shape.js +191 -0
  130. package/dist/node_modules/bkui-vue/lib/icon/copy.js +191 -0
  131. package/dist/node_modules/bkui-vue/lib/icon/data-shape.js +191 -0
  132. package/dist/node_modules/bkui-vue/lib/icon/del.js +191 -0
  133. package/dist/node_modules/bkui-vue/lib/icon/doc-fill.js +191 -0
  134. package/dist/node_modules/bkui-vue/lib/icon/done.js +191 -0
  135. package/dist/node_modules/bkui-vue/lib/icon/down-shape.js +191 -0
  136. package/dist/node_modules/bkui-vue/lib/icon/down-small.js +191 -0
  137. package/dist/node_modules/bkui-vue/lib/icon/edit-line.js +191 -0
  138. package/dist/node_modules/bkui-vue/lib/icon/ellipsis.js +191 -0
  139. package/dist/node_modules/bkui-vue/lib/icon/enlarge-line.js +191 -0
  140. package/dist/node_modules/bkui-vue/lib/icon/error.js +191 -0
  141. package/dist/node_modules/bkui-vue/lib/icon/excel-fill.js +191 -0
  142. package/dist/node_modules/bkui-vue/lib/icon/exclamation-circle-shape.js +191 -0
  143. package/dist/node_modules/bkui-vue/lib/icon/eye.js +191 -0
  144. package/dist/node_modules/bkui-vue/lib/icon/filliscreen-line.js +191 -0
  145. package/dist/node_modules/bkui-vue/lib/icon/fix-line.js +191 -0
  146. package/dist/node_modules/bkui-vue/lib/icon/fix-shape.js +191 -0
  147. package/dist/node_modules/bkui-vue/lib/icon/folder-open.js +191 -0
  148. package/dist/node_modules/bkui-vue/lib/icon/folder-shape-open.js +191 -0
  149. package/dist/node_modules/bkui-vue/lib/icon/folder-shape.js +191 -0
  150. package/dist/node_modules/bkui-vue/lib/icon/folder.js +191 -0
  151. package/dist/node_modules/bkui-vue/lib/icon/funnel.js +191 -0
  152. package/dist/node_modules/bkui-vue/lib/icon/grag-fill.js +191 -0
  153. package/dist/node_modules/bkui-vue/lib/icon/help-document-fill.js +191 -0
  154. package/dist/node_modules/bkui-vue/lib/icon/help-fill.js +191 -0
  155. package/dist/node_modules/bkui-vue/lib/icon/help.js +191 -0
  156. package/dist/node_modules/bkui-vue/lib/icon/image-fill.js +191 -0
  157. package/dist/node_modules/bkui-vue/lib/icon/img-error.js +191 -0
  158. package/dist/node_modules/bkui-vue/lib/icon/img-placehoulder.js +191 -0
  159. package/dist/node_modules/bkui-vue/lib/icon/index.js +113 -0
  160. package/dist/node_modules/bkui-vue/lib/icon/info-line.js +191 -0
  161. package/dist/node_modules/bkui-vue/lib/icon/info.js +191 -0
  162. package/dist/node_modules/bkui-vue/lib/icon/left-shape.js +191 -0
  163. package/dist/node_modules/bkui-vue/lib/icon/left-turn-line.js +191 -0
  164. package/dist/node_modules/bkui-vue/lib/icon/loading.js +191 -0
  165. package/dist/node_modules/bkui-vue/lib/icon/narrow-line.js +191 -0
  166. package/dist/node_modules/bkui-vue/lib/icon/original.js +191 -0
  167. package/dist/node_modules/bkui-vue/lib/icon/pdf-fill.js +191 -0
  168. package/dist/node_modules/bkui-vue/lib/icon/play-shape.js +191 -0
  169. package/dist/node_modules/bkui-vue/lib/icon/plus.js +191 -0
  170. package/dist/node_modules/bkui-vue/lib/icon/ppt-fill.js +191 -0
  171. package/dist/node_modules/bkui-vue/lib/icon/qq.js +191 -0
  172. package/dist/node_modules/bkui-vue/lib/icon/right-shape.js +191 -0
  173. package/dist/node_modules/bkui-vue/lib/icon/right-turn-line.js +191 -0
  174. package/dist/node_modules/bkui-vue/lib/icon/search.js +191 -0
  175. package/dist/node_modules/bkui-vue/lib/icon/share.js +191 -0
  176. package/dist/node_modules/bkui-vue/lib/icon/spinner.js +191 -0
  177. package/dist/node_modules/bkui-vue/lib/icon/success.js +191 -0
  178. package/dist/node_modules/bkui-vue/lib/icon/switcher-loading.js +191 -0
  179. package/dist/node_modules/bkui-vue/lib/icon/text-all.js +191 -0
  180. package/dist/node_modules/bkui-vue/lib/icon/text-file.js +191 -0
  181. package/dist/node_modules/bkui-vue/lib/icon/text-fill.js +191 -0
  182. package/dist/node_modules/bkui-vue/lib/icon/transfer.js +191 -0
  183. package/dist/node_modules/bkui-vue/lib/icon/tree-application-shape.js +191 -0
  184. package/dist/node_modules/bkui-vue/lib/icon/unfull-screen.js +191 -0
  185. package/dist/node_modules/bkui-vue/lib/icon/unvisible.js +191 -0
  186. package/dist/node_modules/bkui-vue/lib/icon/up-shape.js +191 -0
  187. package/dist/node_modules/bkui-vue/lib/icon/upload.js +191 -0
  188. package/dist/node_modules/bkui-vue/lib/icon/video-fill.js +191 -0
  189. package/dist/node_modules/bkui-vue/lib/icon/warn.js +191 -0
  190. package/dist/node_modules/bkui-vue/lib/icon/weixin-pro.js +191 -0
  191. package/dist/node_modules/bkui-vue/lib/icon/weixin.js +191 -0
  192. package/dist/node_modules/bkui-vue/lib/styles/reset.css +439 -0
  193. package/dist/node_modules/call-bind/index.js +24 -0
  194. package/dist/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
  195. package/dist/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
  196. package/dist/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
  197. package/dist/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
  198. package/dist/node_modules/call-bind-apply-helpers/index.js +15 -0
  199. package/dist/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
  200. package/dist/node_modules/call-bound/index.js +19 -0
  201. package/dist/node_modules/deep-equal/index.js +112 -0
  202. package/dist/node_modules/define-data-property/index.js +56 -0
  203. package/dist/node_modules/define-properties/index.js +47 -0
  204. package/dist/node_modules/dunder-proto/get.js +30 -0
  205. package/dist/node_modules/es-define-property/index.js +14 -0
  206. package/dist/node_modules/es-errors/eval.js +4 -0
  207. package/dist/node_modules/es-errors/index.js +4 -0
  208. package/dist/node_modules/es-errors/range.js +4 -0
  209. package/dist/node_modules/es-errors/ref.js +4 -0
  210. package/dist/node_modules/es-errors/syntax.js +4 -0
  211. package/dist/node_modules/es-errors/type.js +4 -0
  212. package/dist/node_modules/es-errors/uri.js +4 -0
  213. package/dist/node_modules/es-object-atoms/index.js +4 -0
  214. package/dist/node_modules/extend/index.js +117 -0
  215. package/dist/node_modules/fast-diff/diff.js +738 -0
  216. package/dist/node_modules/function-bind/implementation.js +84 -0
  217. package/dist/node_modules/function-bind/index.js +5 -0
  218. package/dist/node_modules/functions-have-names/index.js +31 -0
  219. package/dist/node_modules/get-intrinsic/index.js +378 -0
  220. package/dist/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
  221. package/dist/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
  222. package/dist/node_modules/get-proto/index.js +27 -0
  223. package/dist/node_modules/gopd/gOPD.js +4 -0
  224. package/dist/node_modules/gopd/index.js +15 -0
  225. package/dist/node_modules/has-property-descriptors/index.js +22 -0
  226. package/dist/node_modules/has-symbols/index.js +14 -0
  227. package/dist/node_modules/has-symbols/shams.js +45 -0
  228. package/dist/node_modules/has-tostringtag/shams.js +8 -0
  229. package/dist/node_modules/hasown/index.js +8 -0
  230. package/dist/node_modules/is-arguments/index.js +44 -0
  231. package/dist/node_modules/is-date-object/index.js +27 -0
  232. package/dist/node_modules/is-regex/index.js +69 -0
  233. package/dist/node_modules/math-intrinsics/abs.js +4 -0
  234. package/dist/node_modules/math-intrinsics/floor.js +4 -0
  235. package/dist/node_modules/math-intrinsics/isNaN.js +6 -0
  236. package/dist/node_modules/math-intrinsics/max.js +4 -0
  237. package/dist/node_modules/math-intrinsics/min.js +4 -0
  238. package/dist/node_modules/math-intrinsics/pow.js +4 -0
  239. package/dist/node_modules/math-intrinsics/round.js +4 -0
  240. package/dist/node_modules/math-intrinsics/sign.js +11 -0
  241. package/dist/node_modules/object-is/implementation.js +19 -0
  242. package/dist/node_modules/object-is/index.js +18 -0
  243. package/dist/node_modules/object-is/polyfill.js +7 -0
  244. package/dist/node_modules/object-is/shim.js +14 -0
  245. package/dist/node_modules/object-keys/implementation.js +122 -0
  246. package/dist/node_modules/object-keys/index.js +32 -0
  247. package/dist/node_modules/object-keys/isArguments.js +17 -0
  248. package/dist/node_modules/quill/dist/quill.js +11562 -0
  249. package/dist/node_modules/quill/dist/quill.snow.css +945 -0
  250. package/dist/node_modules/quill-delta/lib/delta.js +344 -0
  251. package/dist/node_modules/quill-delta/lib/op.js +155 -0
  252. package/dist/node_modules/regexp.prototype.flags/implementation.js +39 -0
  253. package/dist/node_modules/regexp.prototype.flags/index.js +18 -0
  254. package/dist/node_modules/regexp.prototype.flags/polyfill.js +39 -0
  255. package/dist/node_modules/regexp.prototype.flags/shim.js +26 -0
  256. package/dist/node_modules/set-function-length/index.js +42 -0
  257. package/dist/node_modules/set-function-name/index.js +23 -0
  258. package/dist/node_modules/x-mavon-editor/dist/css/index.css +1 -0
  259. package/dist/node_modules/x-mavon-editor/dist/font/fontello.eot +0 -0
  260. package/dist/node_modules/x-mavon-editor/dist/font/fontello.svg +72 -0
  261. package/dist/node_modules/x-mavon-editor/dist/font/fontello.ttf +0 -0
  262. package/dist/node_modules/x-mavon-editor/dist/font/fontello.woff +0 -0
  263. package/dist/node_modules/x-mavon-editor/dist/font/fontello.woff2 +0 -0
  264. package/dist/node_modules/x-mavon-editor/dist/highlightjs/highlight.min.js +1150 -0
  265. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/bash.min.js +20 -0
  266. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/css.min.js +31 -0
  267. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/go.min.js +14 -0
  268. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/java.min.js +37 -0
  269. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/javascript.min.js +76 -0
  270. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/json.min.js +7 -0
  271. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/markdown.min.js +31 -0
  272. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/perl.min.js +36 -0
  273. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/php.min.js +37 -0
  274. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/python.min.js +42 -0
  275. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/ruby.min.js +48 -0
  276. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/sql.min.js +17 -0
  277. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/swift.min.js +60 -0
  278. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/typescript.min.js +92 -0
  279. package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/xml.min.js +28 -0
  280. package/dist/node_modules/x-mavon-editor/dist/highlightjs/styles/atom-one-dark.min.css +1 -0
  281. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_AMS-Regular.ttf +0 -0
  282. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_AMS-Regular.woff +0 -0
  283. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  284. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  285. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  286. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  287. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  288. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  289. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  290. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  291. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  292. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  293. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  294. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  295. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  296. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Bold.ttf +0 -0
  297. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Bold.woff +0 -0
  298. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
  299. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  300. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  301. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  302. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Italic.ttf +0 -0
  303. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Italic.woff +0 -0
  304. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
  305. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Regular.ttf +0 -0
  306. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Regular.woff +0 -0
  307. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
  308. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  309. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  310. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  311. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-Italic.ttf +0 -0
  312. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-Italic.woff +0 -0
  313. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
  314. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  315. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  316. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  317. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  318. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  319. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  320. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  321. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  322. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  323. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Script-Regular.ttf +0 -0
  324. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Script-Regular.woff +0 -0
  325. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
  326. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size1-Regular.ttf +0 -0
  327. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size1-Regular.woff +0 -0
  328. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  329. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size2-Regular.ttf +0 -0
  330. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size2-Regular.woff +0 -0
  331. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  332. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size3-Regular.ttf +0 -0
  333. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size3-Regular.woff +0 -0
  334. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  335. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size4-Regular.ttf +0 -0
  336. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size4-Regular.woff +0 -0
  337. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  338. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  339. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  340. package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  341. package/dist/node_modules/x-mavon-editor/dist/katex/katex.min.css +1 -0
  342. package/dist/node_modules/x-mavon-editor/dist/katex/katex.min.js +1 -0
  343. package/dist/node_modules/x-mavon-editor/dist/markdown/github-markdown.min.css +2 -0
  344. package/dist/node_modules/x-mavon-editor/dist/mavon-editor.js +31 -0
  345. package/dist/types/enum.d.ts +44 -0
  346. package/dist/types/enum.js +111 -0
  347. package/dist/types/file.d.ts +13 -0
  348. package/dist/types/file.js +1 -0
  349. package/dist/types/knowledge.d.ts +133 -0
  350. package/dist/types/knowledge.js +1 -0
  351. package/dist/types/model.d.ts +14 -0
  352. package/dist/types/permission.d.ts +48 -0
  353. package/dist/types/permission.js +1 -0
  354. package/dist/types/{type.d.ts → session.d.ts} +84 -23
  355. package/dist/types/session.js +1 -0
  356. package/dist/types/tool.d.ts +60 -0
  357. package/dist/types/tool.js +1 -0
  358. package/package.json +10 -4
  359. package/dist/common/type-transform.d.ts +0 -7
@@ -0,0 +1,565 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _define_property(obj, key, value) {
31
+ if (key in obj) {
32
+ Object.defineProperty(obj, key, {
33
+ value: value,
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true
37
+ });
38
+ } else {
39
+ obj[key] = value;
40
+ }
41
+ return obj;
42
+ }
43
+ function _object_spread(target) {
44
+ for(var i = 1; i < arguments.length; i++){
45
+ var source = arguments[i] != null ? arguments[i] : {};
46
+ var ownKeys = Object.keys(source);
47
+ if (typeof Object.getOwnPropertySymbols === "function") {
48
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
49
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
50
+ }));
51
+ }
52
+ ownKeys.forEach(function(key) {
53
+ _define_property(target, key, source[key]);
54
+ });
55
+ }
56
+ return target;
57
+ }
58
+ import { ref, computed } from 'vue';
59
+ import { HttpErrorCode, SessionContentRole, SessionContentStatus } from '../types/enum.js';
60
+ import { getHtmlContentFromDocuments, removeReferenceDoc } from './use-reference-doc.js';
61
+ import { getHtmlContentFromThink, isThinking, removeThink } from './use-think.js';
62
+ import { useHttp } from './use-http.js';
63
+ import { transferSessionContent2SessionPrompt } from '../http/helper/session.js';
64
+ import { ChatHelper } from '../common/chart-helper.js';
65
+ import { processPromptTemplate, throttle } from '../common/util.js';
66
+ // ai 聊天
67
+ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThink, handleEnd, handleError, requestOptions })=>{
68
+ // 接口
69
+ const { clearSession: clearSessionApi, getSessions: getSessionsApi, plusSession: plusSessionApi, modifySession: modifySessionApi, deleteSession: deleteSessionApi, batchDeleteSessions: batchDeleteSessionsApi, getSession: getSessionApi, getSessionContents: getSessionContentsApi, plusSessionContent: plusSessionContentApi, modifySessionContent: modifySessionContentApi, deleteSessionContent: deleteSessionContentApi, batchDeleteSessionContents: batchDeleteSessionContentsApi } = useHttp(requestOptions.url);
70
+ const startMessage = '内容正在生成中...';
71
+ // 聊天上下文
72
+ const currentSession = ref();
73
+ const sessionLoadingMap = ref({});
74
+ const sessionContents = ref([]);
75
+ const sessionContentsMap = {};
76
+ // 通过计算得到的会话列表
77
+ const calculatedSessionContents = computed(()=>{
78
+ const calculatedSessionContents = [];
79
+ for(let index = sessionContents.value.length - 1; index >= 0; index--){
80
+ const sessionContent = sessionContents.value[index];
81
+ // 向下找到下一个ai回复
82
+ let nextAiSessionContentIndex = index + 1;
83
+ let nextAiSessionContent = sessionContents.value[nextAiSessionContentIndex];
84
+ while(nextAiSessionContent && ![
85
+ SessionContentRole.Ai,
86
+ SessionContentRole.TokenExpired,
87
+ SessionContentRole.ImageNotSupported,
88
+ SessionContentRole.Pause,
89
+ SessionContentRole.Guide
90
+ ].includes(nextAiSessionContent.role)){
91
+ nextAiSessionContentIndex += 1;
92
+ nextAiSessionContent = sessionContents.value[nextAiSessionContentIndex];
93
+ }
94
+ // 系统消息,退出
95
+ if (sessionContent.role === SessionContentRole.System) {
96
+ break;
97
+ }
98
+ // 倒叙添加当前聊天上下文 排除异常答复、异常问题 & 系统消息和时间消息
99
+ if (sessionContent.status !== SessionContentStatus.Fail && !((nextAiSessionContent === null || nextAiSessionContent === void 0 ? void 0 : nextAiSessionContent.status) === SessionContentStatus.Fail && [
100
+ SessionContentRole.User,
101
+ SessionContentRole.UserImage
102
+ ].includes(sessionContent.role)) && ![
103
+ SessionContentRole.Time,
104
+ SessionContentRole.System
105
+ ].includes(sessionContent.role)) {
106
+ calculatedSessionContents.unshift(sessionContent);
107
+ }
108
+ }
109
+ return calculatedSessionContents;
110
+ });
111
+ // 当前会话是否正在加载
112
+ const currentSessionLoading = computed(()=>{
113
+ var _currentSession_value;
114
+ const sessionCode = (_currentSession_value = currentSession.value) === null || _currentSession_value === void 0 ? void 0 : _currentSession_value.sessionCode;
115
+ return sessionCode ? sessionLoadingMap.value[sessionCode] : false;
116
+ });
117
+ // 计算当前的 prompt
118
+ const prompts = computed(()=>{
119
+ var _currentSession_value_roleInfo_content, _currentSession_value_roleInfo, _currentSession_value;
120
+ const rolePrompts = [];
121
+ const userPrompts = [];
122
+ const prompts = [];
123
+ // build rolePrompts
124
+ const latestMatchIndex = sessionContents.value.findLastIndex((sessionContent)=>sessionContent.role === SessionContentRole.System && [
125
+ '已启用角色',
126
+ '已启用模型'
127
+ ].some((key)=>sessionContent.content.includes(key)));
128
+ let index = 0;
129
+ (_currentSession_value = currentSession.value) === null || _currentSession_value === void 0 ? void 0 : (_currentSession_value_roleInfo = _currentSession_value.roleInfo) === null || _currentSession_value_roleInfo === void 0 ? void 0 : (_currentSession_value_roleInfo_content = _currentSession_value_roleInfo.content) === null || _currentSession_value_roleInfo_content === void 0 ? void 0 : _currentSession_value_roleInfo_content.forEach((roleContent)=>{
130
+ const sessionContent = sessionContents.value[latestMatchIndex + 1 + index];
131
+ let nextSessionContent = sessionContents.value[latestMatchIndex + 2 + index];
132
+ if ((sessionContent === null || sessionContent === void 0 ? void 0 : sessionContent.content) === roleContent.content && sessionContent.role !== SessionContentRole.System) {
133
+ rolePrompts.push(transferSessionContent2SessionPrompt(sessionContent));
134
+ index += 1;
135
+ if ((sessionContent === null || sessionContent === void 0 ? void 0 : sessionContent.role) === SessionContentRole.Pause) {
136
+ while(nextSessionContent && nextSessionContent.role === SessionContentRole.System){
137
+ index += 1;
138
+ nextSessionContent = sessionContents.value[latestMatchIndex + 1 + index];
139
+ }
140
+ while(nextSessionContent && [
141
+ SessionContentRole.User,
142
+ SessionContentRole.UserImage
143
+ ].includes(nextSessionContent.role)){
144
+ rolePrompts.push(transferSessionContent2SessionPrompt(nextSessionContent));
145
+ index += 1;
146
+ nextSessionContent = sessionContents.value[latestMatchIndex + 1 + index];
147
+ }
148
+ }
149
+ }
150
+ });
151
+ // build userPrompts
152
+ userPrompts.push(...calculatedSessionContents.value.map(transferSessionContent2SessionPrompt));
153
+ const isSameContent = (startIndex)=>{
154
+ let isSame = true;
155
+ for(let index = startIndex; index < rolePrompts.length; index++){
156
+ var _userPrompts_;
157
+ const rolePrompt = rolePrompts[index];
158
+ if (rolePrompt.content !== ((_userPrompts_ = userPrompts[index - startIndex]) === null || _userPrompts_ === void 0 ? void 0 : _userPrompts_.content)) {
159
+ isSame = false;
160
+ }
161
+ }
162
+ return isSame;
163
+ };
164
+ // 排除在一个系统消息里面,重复的情况
165
+ for(let index = 0; index < rolePrompts.length; index++){
166
+ const rolePrompt = rolePrompts[index];
167
+ if (isSameContent(index)) {
168
+ break;
169
+ } else {
170
+ prompts.push(rolePrompt);
171
+ }
172
+ }
173
+ prompts.push(...userPrompts);
174
+ // 删除引用资料
175
+ prompts.forEach((prompt)=>{
176
+ prompt.content = removeThink(prompt.content);
177
+ prompt.content = removeReferenceDoc(prompt.content);
178
+ });
179
+ return prompts;
180
+ });
181
+ const chatHelper = new ChatHelper({
182
+ handleStart: handleStartChat,
183
+ handleText: handleTextChat,
184
+ handleReferenceDoc: handleReferenceDocChat,
185
+ handleThink: handleThinkChat,
186
+ handleEnd: handleEndChat,
187
+ handleError: handleErrorChat
188
+ });
189
+ // 新增 db
190
+ function plusSessionContent2Db(sessionContent) {
191
+ return plusSessionContentApi(sessionContent).then((result)=>{
192
+ sessionContent.id = result.id;
193
+ sessionContent.createdAt = result.createdAt;
194
+ return sessionContent;
195
+ });
196
+ }
197
+ // 防抖更新 db
198
+ const throttleModifySessionContentApi = throttle((id, sessionContent)=>modifySessionContentApi(sessionContent), 1000);
199
+ // 设置 currentSession
200
+ function setCurrentSession(session) {
201
+ currentSession.value = session;
202
+ // 空session,不处理
203
+ if (!(session === null || session === void 0 ? void 0 : session.sessionCode)) return;
204
+ if (!sessionContentsMap[session.sessionCode]) {
205
+ sessionContentsMap[session.sessionCode] = [];
206
+ }
207
+ sessionContents.value = sessionContentsMap[session.sessionCode];
208
+ }
209
+ // 设置 sessionContents
210
+ function setSessionContents(data) {
211
+ if (!currentSession.value) return;
212
+ sessionContentsMap[currentSession.value.sessionCode] = data;
213
+ sessionContents.value = data;
214
+ }
215
+ // 获取 SessionContent 通过 id
216
+ function getSessionContentById(id, sessionCode) {
217
+ const sessionContents = getSessionContentsBySessionCode(sessionCode);
218
+ return sessionContents.find((item)=>item.id === id);
219
+ }
220
+ // 获取执行中的 SessionContent(最后一个)
221
+ function getLastSessionContentBySessionCode(sessionCode) {
222
+ var _currentSession_value;
223
+ if (((_currentSession_value = currentSession.value) === null || _currentSession_value === void 0 ? void 0 : _currentSession_value.sessionCode) === sessionCode) {
224
+ return sessionContents.value.at(-1);
225
+ }
226
+ return sessionContentsMap[sessionCode].at(-1);
227
+ }
228
+ // 获取 SessionContents
229
+ function getSessionContentsBySessionCode(sessionCode) {
230
+ var _currentSession_value;
231
+ if (((_currentSession_value = currentSession.value) === null || _currentSession_value === void 0 ? void 0 : _currentSession_value.sessionCode) === sessionCode) {
232
+ return sessionContents.value;
233
+ }
234
+ return sessionContentsMap[sessionCode];
235
+ }
236
+ // 新增 sessionContent
237
+ function plusSessionContent(sessionCode, sessionContent) {
238
+ const sessionContents = getSessionContentsBySessionCode(sessionCode);
239
+ sessionContents.push(sessionContent);
240
+ return plusSessionContent2Db(sessionContent);
241
+ }
242
+ // 更新 chatContent
243
+ function updateSessionContent(sessionContent) {
244
+ var _currentSession_value;
245
+ const currentSessionContents = ((_currentSession_value = currentSession.value) === null || _currentSession_value === void 0 ? void 0 : _currentSession_value.sessionCode) === sessionContent.sessionCode ? sessionContents.value : sessionContentsMap[sessionContent.sessionCode];
246
+ const currentSessionContent = currentSessionContents.find((item)=>+(item.id || 0) === +(sessionContent.id || 0));
247
+ if (currentSessionContent) {
248
+ Object.assign(currentSessionContent, sessionContent);
249
+ }
250
+ return throttleModifySessionContentApi(sessionContent.id, sessionContent);
251
+ }
252
+ // 获取待删除的会话id,并从会话列表中删除
253
+ function getDeleteSessionContents(sessionCode, sessionContentIds, relatedDelete) {
254
+ var _currentSession_value;
255
+ const currentSessionContents = ((_currentSession_value = currentSession.value) === null || _currentSession_value === void 0 ? void 0 : _currentSession_value.sessionCode) === sessionCode ? sessionContents.value : sessionContentsMap[sessionCode];
256
+ const deleteSessionContentIds = [];
257
+ sessionContentIds.forEach((sessionContentId)=>{
258
+ const index = currentSessionContents.findIndex((sessionContent)=>sessionContent.id === sessionContentId);
259
+ if (index > -1) {
260
+ const preSessionContent = currentSessionContents[index - 1];
261
+ const nextSessionContent = currentSessionContents[index + 1];
262
+ const nextNextSessionContent = currentSessionContents[index + 2];
263
+ // 删除当前会话
264
+ currentSessionContents.splice(index, 1);
265
+ deleteSessionContentIds.push(sessionContentId);
266
+ // 如果前一个是 hidden 也需要删除
267
+ if ([
268
+ SessionContentRole.Hidden
269
+ ].includes(preSessionContent === null || preSessionContent === void 0 ? void 0 : preSessionContent.role)) {
270
+ const hiddenIndex = currentSessionContents.findIndex((sessionContent)=>sessionContent.id === preSessionContent.id);
271
+ currentSessionContents.splice(hiddenIndex, 1);
272
+ deleteSessionContentIds.push(preSessionContent.id);
273
+ }
274
+ // 如果下一个是ai回复,也需要删掉
275
+ if ((nextSessionContent === null || nextSessionContent === void 0 ? void 0 : nextSessionContent.role) === SessionContentRole.Ai || relatedDelete && [
276
+ SessionContentRole.Ai,
277
+ SessionContentRole.Guide,
278
+ SessionContentRole.TokenExpired,
279
+ SessionContentRole.ImageNotSupported,
280
+ SessionContentRole.Pause
281
+ ].includes(nextSessionContent === null || nextSessionContent === void 0 ? void 0 : nextSessionContent.role)) {
282
+ const nextIndex = currentSessionContents.findIndex((sessionContent)=>sessionContent.id === nextSessionContent.id);
283
+ currentSessionContents.splice(nextIndex, 1);
284
+ deleteSessionContentIds.push(nextSessionContent.id);
285
+ }
286
+ // 如果下下个是 guide,需要删除
287
+ if ([
288
+ SessionContentRole.Guide
289
+ ].includes(nextNextSessionContent === null || nextNextSessionContent === void 0 ? void 0 : nextNextSessionContent.role) && relatedDelete) {
290
+ const nextNextIndex = currentSessionContents.findIndex((sessionContent)=>sessionContent.id === nextNextSessionContent.id);
291
+ currentSessionContents.splice(nextNextIndex, 1);
292
+ deleteSessionContentIds.push(nextNextSessionContent.id);
293
+ }
294
+ }
295
+ });
296
+ return deleteSessionContentIds;
297
+ }
298
+ // 删除聊天内容
299
+ function deleteSessionContent(sessionCode, contentId) {
300
+ const deleteSessionContentIds = getDeleteSessionContents(sessionCode, [
301
+ contentId
302
+ ], true);
303
+ return batchDeleteSessionContentsApi(deleteSessionContentIds);
304
+ }
305
+ // 批量删除
306
+ function deleteSessionContents(sessionCode, contentIds) {
307
+ const deleteSessionContentIds = getDeleteSessionContents(sessionCode, contentIds, false);
308
+ return batchDeleteSessionContentsApi(deleteSessionContentIds);
309
+ }
310
+ function handleStartChat(sessionCode) {
311
+ return _handleStartChat.apply(this, arguments);
312
+ }
313
+ function _handleStartChat() {
314
+ _handleStartChat = // 聊天开始
315
+ _async_to_generator(function*(sessionCode) {
316
+ sessionLoadingMap.value[sessionCode] = true;
317
+ const sessionContent = {
318
+ sessionCode,
319
+ role: SessionContentRole.Ai,
320
+ status: SessionContentStatus.Loading,
321
+ content: startMessage
322
+ };
323
+ // 画布新增
324
+ yield plusSessionContent(sessionCode, sessionContent);
325
+ // 调用cb
326
+ return handleStart === null || handleStart === void 0 ? void 0 : handleStart(sessionCode, sessionContent);
327
+ });
328
+ return _handleStartChat.apply(this, arguments);
329
+ }
330
+ function handleReferenceDocChat(sessionCode, documents, cover) {
331
+ return _handleReferenceDocChat.apply(this, arguments);
332
+ }
333
+ function _handleReferenceDocChat() {
334
+ _handleReferenceDocChat = // 引用资料
335
+ _async_to_generator(function*(sessionCode, documents, cover) {
336
+ const sessionContent = getLastSessionContentBySessionCode(sessionCode);
337
+ const content = getHtmlContentFromDocuments(documents);
338
+ sessionContent.content = cover ? content : sessionContent.content + content;
339
+ yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
340
+ return handleReferenceDoc === null || handleReferenceDoc === void 0 ? void 0 : handleReferenceDoc(sessionCode, sessionContent);
341
+ });
342
+ return _handleReferenceDocChat.apply(this, arguments);
343
+ }
344
+ function handleThinkChat(sessionCode, content, cover, elapsedTime) {
345
+ return _handleThinkChat.apply(this, arguments);
346
+ }
347
+ function _handleThinkChat() {
348
+ _handleThinkChat = // 思考
349
+ _async_to_generator(function*(sessionCode, content, cover, elapsedTime) {
350
+ const sessionContent = getLastSessionContentBySessionCode(sessionCode);
351
+ // 获取思考的html
352
+ sessionContent.content = getHtmlContentFromThink(sessionContent.content, content, cover, elapsedTime);
353
+ // 更新 db
354
+ yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
355
+ // 调用cb
356
+ return handleThink === null || handleThink === void 0 ? void 0 : handleThink(sessionCode, sessionContent);
357
+ });
358
+ return _handleThinkChat.apply(this, arguments);
359
+ }
360
+ function handleTextChat(sessionCode, message, cover) {
361
+ return _handleTextChat.apply(this, arguments);
362
+ }
363
+ function _handleTextChat() {
364
+ _handleTextChat = // 文本
365
+ _async_to_generator(function*(sessionCode, message, cover) {
366
+ const sessionContent = getLastSessionContentBySessionCode(sessionCode);
367
+ if (sessionContent.content === startMessage) {
368
+ sessionContent.content = message;
369
+ } else if (sessionContent.status === SessionContentStatus.Loading) {
370
+ sessionContent.content = cover ? message : sessionContent.content + message;
371
+ } else {
372
+ return;
373
+ }
374
+ // 更新 db
375
+ yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
376
+ // 调用cb
377
+ return handleText === null || handleText === void 0 ? void 0 : handleText(sessionCode, sessionContent);
378
+ });
379
+ return _handleTextChat.apply(this, arguments);
380
+ }
381
+ function handleEndChat(sessionCode, message) {
382
+ return _handleEndChat.apply(this, arguments);
383
+ }
384
+ function _handleEndChat() {
385
+ _handleEndChat = // 聊天结束
386
+ _async_to_generator(function*(sessionCode, message) {
387
+ const sessionContent = getLastSessionContentBySessionCode(sessionCode);
388
+ // 内容正在生成中或者正在思考中
389
+ if (sessionContent.content === startMessage || isThinking(sessionContent.content)) {
390
+ handleErrorChat(sessionCode, '聊天内容已中断');
391
+ return;
392
+ }
393
+ // 防止 error 的情况下异步触发 end 更新了数据
394
+ if (sessionContent.status === SessionContentStatus.Loading) {
395
+ sessionLoadingMap.value[sessionCode] = false;
396
+ // end 的时候,如果 message 有值,则更新 content
397
+ if (message) {
398
+ sessionContent.content = message;
399
+ }
400
+ // 更新状态
401
+ sessionContent.status = SessionContentStatus.Success;
402
+ // 更新 db
403
+ yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
404
+ // 调用cb
405
+ return handleEnd === null || handleEnd === void 0 ? void 0 : handleEnd(sessionCode, sessionContent);
406
+ }
407
+ });
408
+ return _handleEndChat.apply(this, arguments);
409
+ }
410
+ function handleErrorChat(sessionCode, message, code) {
411
+ return _handleErrorChat.apply(this, arguments);
412
+ }
413
+ function _handleErrorChat() {
414
+ _handleErrorChat = // 聊天异常
415
+ _async_to_generator(function*(sessionCode, message, code) {
416
+ const sessionContent = getLastSessionContentBySessionCode(sessionCode);
417
+ sessionContent.status = SessionContentStatus.Fail;
418
+ sessionContent.content = message;
419
+ sessionLoadingMap.value[sessionCode] = false;
420
+ // token 超了,提示 token 不足
421
+ if (code === HttpErrorCode.TokenExpired) {
422
+ sessionContent.content = '抱歉,您的剩余 Token 不足,无法返回回答内容,请先清空当前会话(上下文仍会作为历史记录保留))';
423
+ sessionContent.role = SessionContentRole.TokenExpired;
424
+ }
425
+ if (code === HttpErrorCode.ImageNotSupported) {
426
+ sessionContent.content = '抱歉,当前模型不支持图片内容解析';
427
+ sessionContent.role = SessionContentRole.ImageNotSupported;
428
+ }
429
+ // 更新 db
430
+ yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
431
+ // 调用cb
432
+ return handleError === null || handleError === void 0 ? void 0 : handleError(sessionCode, sessionContent, code);
433
+ });
434
+ return _handleErrorChat.apply(this, arguments);
435
+ }
436
+ // 重新生成对话 仅支持重新生成 ai 的回复
437
+ function reGenerateChat(chatIndex) {
438
+ const chat = sessionContents.value[chatIndex];
439
+ if (chat.role !== SessionContentRole.Ai) {
440
+ return;
441
+ }
442
+ const message = sessionContents.value[chatIndex - 1].content;
443
+ const cite = sessionContents.value[chatIndex - 1].cite;
444
+ sessionContents.value.splice(chatIndex - 1, sessionContents.value.length - chatIndex + 1); // 重新生成时,删除当前的 ai 回复和下方的所有内容
445
+ sendChat({
446
+ message,
447
+ cite
448
+ });
449
+ }
450
+ // 聊天
451
+ function chat({ sessionCode, data, headers }) {
452
+ const sessionContent = getLastSessionContentBySessionCode(sessionCode);
453
+ // 发送请求
454
+ chatHelper.stream({
455
+ sessionCode,
456
+ url: `${requestOptions.url}/chat_completion/`,
457
+ data: _object_spread({
458
+ session_content_id: sessionContent === null || sessionContent === void 0 ? void 0 : sessionContent.id,
459
+ session_code: sessionCode
460
+ }, data),
461
+ headers: headers || (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers)
462
+ });
463
+ }
464
+ // 重新发送聊天, 需要将当前聊天内容以及下方的所有内容删除
465
+ function reSendChat(index, { message, cite }, callback) {
466
+ const chat = sessionContents.value[index];
467
+ if (chat.role !== SessionContentRole.User) {
468
+ return;
469
+ }
470
+ sessionContents.value.splice(index, sessionContents.value.length - index);
471
+ sendChat({
472
+ message,
473
+ cite
474
+ }, callback);
475
+ }
476
+ // 发送聊天
477
+ function sendChat(content, callback) {
478
+ var _currentSession_value, _currentSession_value1, _currentSession_value2;
479
+ if (!((_currentSession_value = currentSession.value) === null || _currentSession_value === void 0 ? void 0 : _currentSession_value.sessionCode) || !(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.url) || currentSessionLoading.value) {
480
+ return;
481
+ }
482
+ const { message, cite, shortcut } = content;
483
+ let input = '';
484
+ if (shortcut) {
485
+ input = processPromptTemplate(shortcut.prompt, cite);
486
+ } else {
487
+ input = cite ? `${message}: "${cite}"` : message;
488
+ }
489
+ sessionContents.value.push({
490
+ sessionCode: (_currentSession_value1 = currentSession.value) === null || _currentSession_value1 === void 0 ? void 0 : _currentSession_value1.sessionCode,
491
+ content: message,
492
+ role: SessionContentRole.User,
493
+ status: SessionContentStatus.Success,
494
+ cite
495
+ });
496
+ // 发送请求
497
+ chatHelper.stream({
498
+ sessionCode: (_currentSession_value2 = currentSession.value) === null || _currentSession_value2 === void 0 ? void 0 : _currentSession_value2.sessionCode,
499
+ url: requestOptions.url,
500
+ headers: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers,
501
+ data: {
502
+ inputs: {
503
+ chat_history: prompts.value.slice(0, prompts.value.length - 1),
504
+ input
505
+ }
506
+ }
507
+ });
508
+ callback === null || callback === void 0 ? void 0 : callback();
509
+ }
510
+ /**
511
+ * 删除聊天内容
512
+ * @param index 要删除的聊天内容索引
513
+ * @description
514
+ * - 如果删除的是用户消息,则同时删除该消息及其对应的AI回复(共2条)
515
+ * - 如果删除的是其他类型消息(如AI回复),则只删除该条消息
516
+ */ function deleteChat(index) {
517
+ const chat = sessionContents.value[index];
518
+ if (chat.role === SessionContentRole.User) {
519
+ sessionContents.value.splice(index, 2);
520
+ return;
521
+ }
522
+ sessionContents.value.splice(index - 1, 2);
523
+ }
524
+ // 停止聊天
525
+ function stopChat(sessionCode) {
526
+ chatHelper.stop(sessionCode);
527
+ }
528
+ return {
529
+ currentSession,
530
+ sessionContents,
531
+ sessionContentsMap,
532
+ sessionLoadingMap,
533
+ prompts,
534
+ currentSessionLoading,
535
+ chat,
536
+ sendChat,
537
+ stopChat,
538
+ plusSessionContent,
539
+ updateSessionContent,
540
+ getSessionContentById,
541
+ getLastSessionContentBySessionCode,
542
+ getSessionContentsBySessionCode,
543
+ setCurrentSession,
544
+ setSessionContents,
545
+ deleteSessionContent,
546
+ deleteSessionContents,
547
+ handleStartChat,
548
+ handleErrorChat,
549
+ reGenerateChat,
550
+ reSendChat,
551
+ deleteChat,
552
+ clearSessionApi,
553
+ getSessionsApi,
554
+ plusSessionApi,
555
+ modifySessionApi,
556
+ deleteSessionApi,
557
+ batchDeleteSessionsApi,
558
+ getSessionApi,
559
+ getSessionContentsApi,
560
+ plusSessionContentApi,
561
+ modifySessionContentApi,
562
+ deleteSessionContentApi,
563
+ batchDeleteSessionContentsApi
564
+ };
565
+ };
@@ -0,0 +1,77 @@
1
+ import { onBeforeMount, onBeforeUnmount } from 'vue';
2
+ import { handleCopy, handleDownLoad, getFullScreenWrap } from '../common/util.js';
3
+ // 全局点击代理事件
4
+ export const useClickProxy = ()=>{
5
+ const clickProxy = (e)=>{
6
+ const target = e.target;
7
+ // 聊天窗里面的引用资料和思考内容
8
+ if (target === null || target === void 0 ? void 0 : target.classList.contains('bkaidev-angle-up')) {
9
+ const parent = target === null || target === void 0 ? void 0 : target.parentElement;
10
+ if (parent === null || parent === void 0 ? void 0 : parent.classList.contains('closed')) {
11
+ parent === null || parent === void 0 ? void 0 : parent.classList.remove('closed');
12
+ } else {
13
+ parent === null || parent === void 0 ? void 0 : parent.classList.add('closed');
14
+ }
15
+ }
16
+ if (target === null || target === void 0 ? void 0 : target.classList.contains('click-close')) {
17
+ if (target === null || target === void 0 ? void 0 : target.classList.contains('closed')) {
18
+ target === null || target === void 0 ? void 0 : target.classList.remove('closed');
19
+ } else {
20
+ target === null || target === void 0 ? void 0 : target.classList.add('closed');
21
+ }
22
+ }
23
+ // 会话里面代码块的全屏
24
+ if (target === null || target === void 0 ? void 0 : target.classList.contains('click-full-screen')) {
25
+ // 获取全屏的父元素
26
+ const fullScreenWrap = getFullScreenWrap(target);
27
+ // 添加 class
28
+ fullScreenWrap === null || fullScreenWrap === void 0 ? void 0 : fullScreenWrap.classList.add('full-screen');
29
+ // 元素移动到body
30
+ if (!fullScreenWrap._originalParent) {
31
+ fullScreenWrap._originalParent = fullScreenWrap.parentNode;
32
+ fullScreenWrap._originalNextSibling = fullScreenWrap.nextSibling;
33
+ }
34
+ document.body.appendChild(fullScreenWrap);
35
+ }
36
+ // 会话里面代码块的取消全屏
37
+ if (target === null || target === void 0 ? void 0 : target.classList.contains('click-un-full-screen')) {
38
+ // 获取全屏的父元素
39
+ const fullScreenWrap = getFullScreenWrap(target);
40
+ // 移除 class
41
+ fullScreenWrap === null || fullScreenWrap === void 0 ? void 0 : fullScreenWrap.classList.remove('full-screen');
42
+ // 移回原位
43
+ if (fullScreenWrap._originalNextSibling) {
44
+ fullScreenWrap._originalParent.insertBefore(fullScreenWrap, fullScreenWrap._originalNextSibling);
45
+ } else {
46
+ fullScreenWrap._originalParent.appendChild(fullScreenWrap);
47
+ }
48
+ }
49
+ // 复制
50
+ if (target === null || target === void 0 ? void 0 : target.classList.contains('click-copy')) {
51
+ const text = target === null || target === void 0 ? void 0 : target.getAttribute('data-clipboard-text');
52
+ if (text) {
53
+ handleCopy(decodeURIComponent(text));
54
+ }
55
+ }
56
+ // 下载
57
+ if (target === null || target === void 0 ? void 0 : target.classList.contains('click-download')) {
58
+ const text = target === null || target === void 0 ? void 0 : target.getAttribute('data-clipboard-text');
59
+ const fileName = target === null || target === void 0 ? void 0 : target.getAttribute('data-file-name');
60
+ if (text && fileName) {
61
+ handleDownLoad(decodeURIComponent(text), fileName);
62
+ }
63
+ }
64
+ };
65
+ const addClickProxy = ()=>{
66
+ window.addEventListener('click', clickProxy);
67
+ };
68
+ const removeClickProxy = ()=>{
69
+ window.removeEventListener('click', clickProxy);
70
+ };
71
+ onBeforeMount(()=>{
72
+ addClickProxy();
73
+ });
74
+ onBeforeUnmount(()=>{
75
+ removeClickProxy();
76
+ });
77
+ };
@@ -0,0 +1,15 @@
1
+ import type { ISession, ISessionContent } from '@/types/session';
2
+ export declare const useHttp: (apiPrefix: string) => {
3
+ clearSession: (sessionCode: string) => Promise<unknown>;
4
+ getSessions: () => Promise<ISession[]>;
5
+ plusSession: (data: ISession) => Promise<ISession>;
6
+ modifySession: (data: ISession) => Promise<ISession>;
7
+ deleteSession: (sessionCode: string) => Promise<unknown>;
8
+ batchDeleteSessions: (sessionCodes: string[]) => Promise<number>;
9
+ getSession: (sessionCode: string) => Promise<ISession>;
10
+ getSessionContents: (sessionCode: string) => Promise<ISessionContent[]>;
11
+ plusSessionContent: (data: ISessionContent) => Promise<ISessionContent>;
12
+ modifySessionContent: (data: ISessionContent) => Promise<ISessionContent>;
13
+ deleteSessionContent: (id: number) => Promise<ISessionContent>;
14
+ batchDeleteSessionContents: (ids: number[]) => Promise<number>;
15
+ };