@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.
- package/dist/assets/images/ai.png +0 -0
- package/dist/assets/images/user.png +0 -0
- package/dist/assets/svg/picture-fail.svg +1 -0
- package/dist/common/chart-helper.d.ts +1 -1
- package/dist/common/chart-helper.js +173 -0
- package/dist/common/util.d.ts +31 -0
- package/dist/common/util.js +177 -0
- package/dist/component/render-image/index.script.vue.js +37 -0
- package/dist/component/render-image/index.vue.d.ts +6 -0
- package/dist/component/render-image/index.vue.js +3 -0
- package/dist/component/render-input/index.script.vue.js +205 -0
- package/dist/component/render-input/index.vue.css +134 -0
- package/dist/component/render-input/index.vue.d.ts +18 -0
- package/dist/component/render-input/index.vue.js +5 -0
- package/dist/component/render-input/render-drag.script.vue.js +61 -0
- package/dist/component/render-input/render-drag.vue.css +32 -0
- package/dist/component/render-input/render-drag.vue.d.ts +13 -0
- package/dist/component/render-input/render-drag.vue.js +5 -0
- package/dist/component/render-input/render-quill.script.vue.js +197 -0
- package/dist/component/render-input/render-quill.vue.css +27 -0
- package/dist/component/render-input/render-quill.vue.d.ts +24 -0
- package/dist/component/render-input/render-quill.vue.js +4 -0
- package/dist/component/render-knowledge-icon/index.script.vue.js +40 -0
- package/dist/component/render-knowledge-icon/index.vue.css +4 -0
- package/dist/component/render-knowledge-icon/index.vue.d.ts +14 -0
- package/dist/component/render-knowledge-icon/index.vue.js +5 -0
- package/dist/component/render-markdown/mark-down-code.d.ts +2 -0
- package/dist/component/render-markdown/mark-down-code.js +171 -0
- package/dist/component/render-markdown/mark-down-emoji.d.ts +2 -0
- package/dist/component/render-markdown/mark-down-emoji.js +4 -0
- package/dist/component/render-markdown/mark-down.d.ts +74 -0
- package/dist/component/render-markdown/mark-down.js +147 -0
- package/dist/component/render-markdown/mark-down.postcss.css +131 -0
- package/dist/component/render-message/image-not-supported-message.script.vue.js +99 -0
- package/dist/component/render-message/image-not-supported-message.vue.css +66 -0
- package/dist/component/render-message/image-not-supported-message.vue.d.ts +21 -0
- package/dist/component/render-message/image-not-supported-message.vue.js +5 -0
- package/dist/component/render-message/index.script.vue.js +104 -0
- package/dist/component/render-message/index.vue.d.ts +13 -0
- package/dist/component/render-message/index.vue.js +3 -0
- package/dist/component/render-message/openai-message.script.vue.js +215 -0
- package/dist/component/render-message/openai-message.vue.css +98 -0
- package/dist/component/render-message/openai-message.vue.d.ts +15 -0
- package/dist/component/render-message/openai-message.vue.js +5 -0
- package/dist/component/render-message/skeleton-message.script.vue.js +7 -0
- package/dist/component/render-message/skeleton-message.vue.css +7 -0
- package/dist/component/render-message/skeleton-message.vue.d.ts +2 -0
- package/dist/component/render-message/skeleton-message.vue.js +6 -0
- package/dist/component/render-message/system-message.script.vue.js +17 -0
- package/dist/component/render-message/system-message.vue.css +20 -0
- package/dist/component/render-message/system-message.vue.d.ts +6 -0
- package/dist/component/render-message/system-message.vue.js +5 -0
- package/dist/component/render-message/time-message.script.vue.js +41 -0
- package/dist/component/render-message/time-message.vue.css +14 -0
- package/dist/component/render-message/time-message.vue.d.ts +6 -0
- package/dist/component/render-message/time-message.vue.js +5 -0
- package/dist/component/render-message/token-expired-message.script.vue.js +78 -0
- package/dist/component/render-message/token-expired-message.vue.css +60 -0
- package/dist/component/render-message/token-expired-message.vue.d.ts +15 -0
- package/dist/component/render-message/token-expired-message.vue.js +5 -0
- package/dist/component/render-message/user-message.script.vue.js +241 -0
- package/dist/component/render-message/user-message.vue.css +100 -0
- package/dist/component/render-message/user-message.vue.d.ts +21 -0
- package/dist/component/render-message/user-message.vue.js +5 -0
- package/dist/css/fonts/iconcool.eot +0 -0
- package/dist/css/fonts/iconcool.svg +53 -0
- package/dist/css/fonts/iconcool.ttf +0 -0
- package/dist/css/fonts/iconcool.woff +0 -0
- package/dist/css/iconcool.js +10 -0
- package/dist/css/style.css +43 -0
- package/dist/event/index.d.ts +4 -0
- package/dist/event/index.js +18 -0
- package/dist/hooks/use-chat.d.ts +844 -20
- package/dist/hooks/use-chat.js +565 -0
- package/dist/hooks/use-click-proxy.js +77 -0
- package/dist/hooks/use-http.d.ts +15 -0
- package/dist/hooks/use-http.js +48 -0
- package/dist/hooks/use-mouse-drag.d.ts +13 -0
- package/dist/hooks/use-mouse-drag.js +59 -0
- package/dist/hooks/use-reference-doc.d.ts +1 -1
- package/dist/hooks/use-reference-doc.js +185 -0
- package/dist/hooks/use-style.js +11 -0
- package/dist/hooks/use-summary.d.ts +1 -1
- package/dist/hooks/use-summary.js +55 -0
- package/dist/hooks/use-think.js +135 -0
- package/dist/http/fetch/error-interceptor.d.ts +3 -0
- package/dist/http/fetch/error-interceptor.js +28 -0
- package/dist/http/fetch/index.d.ts +25 -0
- package/dist/http/fetch/index.js +182 -0
- package/dist/http/fetch/request-error.d.ts +6 -0
- package/dist/http/fetch/request-error.js +25 -0
- package/dist/http/fetch/success-interceptor.d.ts +3 -0
- package/dist/http/fetch/success-interceptor.js +92 -0
- package/dist/http/helper/knowledge.d.ts +43 -0
- package/dist/http/helper/knowledge.js +227 -0
- package/dist/http/helper/permission.d.ts +7 -0
- package/dist/http/helper/permission.js +28 -0
- package/dist/http/helper/session.d.ts +31 -0
- package/dist/http/helper/session.js +147 -0
- package/dist/http/helper/tool.d.ts +13 -0
- package/dist/http/helper/tool.js +49 -0
- package/dist/main.d.ts +17 -2
- package/dist/main.js +29 -239
- package/dist/node_modules/bkui-vue/lib/icon/angle-double-down-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-double-left-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-double-left.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-double-right-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-double-right.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-double-up-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-down-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-down-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-down.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-left.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-right.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-up-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-up.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/archive-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/arrows-left.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/arrows-right.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/assistant.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/audio-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/bk.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/circle.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/close-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/close.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/code.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/cog-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/collapse-left.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/copy-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/copy.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/data-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/del.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/doc-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/done.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/down-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/down-small.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/edit-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/ellipsis.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/enlarge-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/error.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/excel-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/exclamation-circle-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/eye.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/filliscreen-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/fix-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/fix-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/folder-open.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/folder-shape-open.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/folder-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/folder.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/funnel.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/grag-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/help-document-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/help-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/help.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/image-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/img-error.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/img-placehoulder.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/index.js +113 -0
- package/dist/node_modules/bkui-vue/lib/icon/info-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/info.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/left-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/left-turn-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/loading.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/narrow-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/original.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/pdf-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/play-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/plus.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/ppt-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/qq.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/right-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/right-turn-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/search.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/share.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/spinner.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/success.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/switcher-loading.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/text-all.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/text-file.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/text-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/transfer.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/tree-application-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/unfull-screen.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/unvisible.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/up-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/upload.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/video-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/warn.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/weixin-pro.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/weixin.js +191 -0
- package/dist/node_modules/bkui-vue/lib/styles/reset.css +439 -0
- package/dist/node_modules/call-bind/index.js +24 -0
- package/dist/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
- package/dist/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
- package/dist/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
- package/dist/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
- package/dist/node_modules/call-bind-apply-helpers/index.js +15 -0
- package/dist/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
- package/dist/node_modules/call-bound/index.js +19 -0
- package/dist/node_modules/deep-equal/index.js +112 -0
- package/dist/node_modules/define-data-property/index.js +56 -0
- package/dist/node_modules/define-properties/index.js +47 -0
- package/dist/node_modules/dunder-proto/get.js +30 -0
- package/dist/node_modules/es-define-property/index.js +14 -0
- package/dist/node_modules/es-errors/eval.js +4 -0
- package/dist/node_modules/es-errors/index.js +4 -0
- package/dist/node_modules/es-errors/range.js +4 -0
- package/dist/node_modules/es-errors/ref.js +4 -0
- package/dist/node_modules/es-errors/syntax.js +4 -0
- package/dist/node_modules/es-errors/type.js +4 -0
- package/dist/node_modules/es-errors/uri.js +4 -0
- package/dist/node_modules/es-object-atoms/index.js +4 -0
- package/dist/node_modules/extend/index.js +117 -0
- package/dist/node_modules/fast-diff/diff.js +738 -0
- package/dist/node_modules/function-bind/implementation.js +84 -0
- package/dist/node_modules/function-bind/index.js +5 -0
- package/dist/node_modules/functions-have-names/index.js +31 -0
- package/dist/node_modules/get-intrinsic/index.js +378 -0
- package/dist/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
- package/dist/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
- package/dist/node_modules/get-proto/index.js +27 -0
- package/dist/node_modules/gopd/gOPD.js +4 -0
- package/dist/node_modules/gopd/index.js +15 -0
- package/dist/node_modules/has-property-descriptors/index.js +22 -0
- package/dist/node_modules/has-symbols/index.js +14 -0
- package/dist/node_modules/has-symbols/shams.js +45 -0
- package/dist/node_modules/has-tostringtag/shams.js +8 -0
- package/dist/node_modules/hasown/index.js +8 -0
- package/dist/node_modules/is-arguments/index.js +44 -0
- package/dist/node_modules/is-date-object/index.js +27 -0
- package/dist/node_modules/is-regex/index.js +69 -0
- package/dist/node_modules/math-intrinsics/abs.js +4 -0
- package/dist/node_modules/math-intrinsics/floor.js +4 -0
- package/dist/node_modules/math-intrinsics/isNaN.js +6 -0
- package/dist/node_modules/math-intrinsics/max.js +4 -0
- package/dist/node_modules/math-intrinsics/min.js +4 -0
- package/dist/node_modules/math-intrinsics/pow.js +4 -0
- package/dist/node_modules/math-intrinsics/round.js +4 -0
- package/dist/node_modules/math-intrinsics/sign.js +11 -0
- package/dist/node_modules/object-is/implementation.js +19 -0
- package/dist/node_modules/object-is/index.js +18 -0
- package/dist/node_modules/object-is/polyfill.js +7 -0
- package/dist/node_modules/object-is/shim.js +14 -0
- package/dist/node_modules/object-keys/implementation.js +122 -0
- package/dist/node_modules/object-keys/index.js +32 -0
- package/dist/node_modules/object-keys/isArguments.js +17 -0
- package/dist/node_modules/quill/dist/quill.js +11562 -0
- package/dist/node_modules/quill/dist/quill.snow.css +945 -0
- package/dist/node_modules/quill-delta/lib/delta.js +344 -0
- package/dist/node_modules/quill-delta/lib/op.js +155 -0
- package/dist/node_modules/regexp.prototype.flags/implementation.js +39 -0
- package/dist/node_modules/regexp.prototype.flags/index.js +18 -0
- package/dist/node_modules/regexp.prototype.flags/polyfill.js +39 -0
- package/dist/node_modules/regexp.prototype.flags/shim.js +26 -0
- package/dist/node_modules/set-function-length/index.js +42 -0
- package/dist/node_modules/set-function-name/index.js +23 -0
- package/dist/node_modules/x-mavon-editor/dist/css/index.css +1 -0
- package/dist/node_modules/x-mavon-editor/dist/font/fontello.eot +0 -0
- package/dist/node_modules/x-mavon-editor/dist/font/fontello.svg +72 -0
- package/dist/node_modules/x-mavon-editor/dist/font/fontello.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/font/fontello.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/font/fontello.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/highlight.min.js +1150 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/bash.min.js +20 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/css.min.js +31 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/go.min.js +14 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/java.min.js +37 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/javascript.min.js +76 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/json.min.js +7 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/markdown.min.js +31 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/perl.min.js +36 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/php.min.js +37 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/python.min.js +42 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/ruby.min.js +48 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/sql.min.js +17 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/swift.min.js +60 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/typescript.min.js +92 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/xml.min.js +28 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/styles/atom-one-dark.min.css +1 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Italic.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-Italic.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Script-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/katex.min.css +1 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/katex.min.js +1 -0
- package/dist/node_modules/x-mavon-editor/dist/markdown/github-markdown.min.css +2 -0
- package/dist/node_modules/x-mavon-editor/dist/mavon-editor.js +31 -0
- package/dist/types/enum.d.ts +44 -0
- package/dist/types/enum.js +111 -0
- package/dist/types/file.d.ts +13 -0
- package/dist/types/file.js +1 -0
- package/dist/types/knowledge.d.ts +133 -0
- package/dist/types/knowledge.js +1 -0
- package/dist/types/model.d.ts +14 -0
- package/dist/types/permission.d.ts +48 -0
- package/dist/types/permission.js +1 -0
- package/dist/types/{type.d.ts → session.d.ts} +84 -23
- package/dist/types/session.js +1 -0
- package/dist/types/tool.d.ts +60 -0
- package/dist/types/tool.js +1 -0
- package/package.json +10 -4
- package/dist/common/type-transform.d.ts +0 -7
@@ -0,0 +1,48 @@
|
|
1
|
+
import fetch from '../http/fetch/index.js';
|
2
|
+
import { transferSession2SessionApi, transferSessionApi2Session, transferSessionContent2SessionContentApi, transferSessionContentApi2SessionContent } from '../http/helper/session.js';
|
3
|
+
export const useHttp = (apiPrefix)=>{
|
4
|
+
// 清除聊天上下文
|
5
|
+
const clearSession = (sessionCode)=>fetch.post(`${apiPrefix}/chat_completion/${sessionCode}/clear/`);
|
6
|
+
// 获取会话列表
|
7
|
+
const getSessions = ()=>fetch.get(`${apiPrefix}/session/`).then((res)=>res.map(transferSessionApi2Session));
|
8
|
+
// 新增会话
|
9
|
+
const plusSession = (data)=>fetch.post(`${apiPrefix}/session/`, transferSession2SessionApi(data)).then((res)=>transferSessionApi2Session(res));
|
10
|
+
// 修改会话
|
11
|
+
const modifySession = (data)=>fetch.put(`${apiPrefix}/session/${data.sessionCode}/`, transferSession2SessionApi(data)).then((res)=>transferSessionApi2Session(res));
|
12
|
+
// 删除会话
|
13
|
+
const deleteSession = (sessionCode)=>fetch.delete(`${apiPrefix}/session/${sessionCode}/`);
|
14
|
+
// 批量删除会话
|
15
|
+
const batchDeleteSessions = (sessionCodes)=>fetch.post(`${apiPrefix}/session/batch_delete/`, {
|
16
|
+
session_codes: sessionCodes
|
17
|
+
});
|
18
|
+
// 获取会话资源
|
19
|
+
const getSession = (sessionCode)=>fetch.get(`${apiPrefix}/session/${sessionCode}/`).then((res)=>transferSessionApi2Session(res));
|
20
|
+
// 获取会话内容列表
|
21
|
+
const getSessionContents = (sessionCode)=>fetch.get(`${apiPrefix}/session_content/content/`, {
|
22
|
+
session_code: sessionCode
|
23
|
+
}).then((res)=>res.map(transferSessionContentApi2SessionContent));
|
24
|
+
// 新增会话内容
|
25
|
+
const plusSessionContent = (data)=>fetch.post(`${apiPrefix}/session_content/`, transferSessionContent2SessionContentApi(data));
|
26
|
+
// 修改会话内容
|
27
|
+
const modifySessionContent = (data)=>fetch.put(`${apiPrefix}/session_content/${data.id}/`, transferSessionContent2SessionContentApi(data));
|
28
|
+
// 删除会话内容
|
29
|
+
const deleteSessionContent = (id)=>fetch.delete(`${apiPrefix}/session_content/${id}/`);
|
30
|
+
// 批量删除聊天内容
|
31
|
+
const batchDeleteSessionContents = (ids)=>fetch.post(`${apiPrefix}/session_content/batch_delete/`, {
|
32
|
+
ids
|
33
|
+
});
|
34
|
+
return {
|
35
|
+
clearSession,
|
36
|
+
getSessions,
|
37
|
+
plusSession,
|
38
|
+
modifySession,
|
39
|
+
deleteSession,
|
40
|
+
batchDeleteSessions,
|
41
|
+
getSession,
|
42
|
+
getSessionContents,
|
43
|
+
plusSessionContent,
|
44
|
+
modifySessionContent,
|
45
|
+
deleteSessionContent,
|
46
|
+
batchDeleteSessionContents
|
47
|
+
};
|
48
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export type PositionInfo = {
|
2
|
+
moveDistance: {
|
3
|
+
x: number;
|
4
|
+
y: number;
|
5
|
+
};
|
6
|
+
singleMoveDistance: {
|
7
|
+
x: number;
|
8
|
+
y: number;
|
9
|
+
};
|
10
|
+
};
|
11
|
+
export declare const useMouseDrag: (targetsClassName: string[], callBack: (positionInfo: PositionInfo) => void) => {
|
12
|
+
isDragging: import("vue").Ref<boolean, boolean>;
|
13
|
+
};
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
2
|
+
export const useMouseDrag = (targetsClassName, callBack)=>{
|
3
|
+
const isDragging = ref(false);
|
4
|
+
const startPosition = {
|
5
|
+
x: 0,
|
6
|
+
y: 0
|
7
|
+
};
|
8
|
+
const lastPosition = {
|
9
|
+
x: 0,
|
10
|
+
y: 0
|
11
|
+
};
|
12
|
+
const handleMouseDown = (event)=>{
|
13
|
+
const ele = event.target;
|
14
|
+
if (targetsClassName.some((name)=>{
|
15
|
+
var _ele_className_includes, _ele_className;
|
16
|
+
return (_ele_className = ele.className) === null || _ele_className === void 0 ? void 0 : (_ele_className_includes = _ele_className.includes) === null || _ele_className_includes === void 0 ? void 0 : _ele_className_includes.call(_ele_className, name);
|
17
|
+
})) {
|
18
|
+
isDragging.value = true;
|
19
|
+
startPosition.x = event.x;
|
20
|
+
startPosition.y = event.y;
|
21
|
+
lastPosition.x = event.x;
|
22
|
+
lastPosition.y = event.y;
|
23
|
+
}
|
24
|
+
};
|
25
|
+
const handleMouseMove = (event)=>{
|
26
|
+
if (!isDragging.value) return;
|
27
|
+
event.preventDefault();
|
28
|
+
const positionInfo = {
|
29
|
+
moveDistance: {
|
30
|
+
x: event.x - startPosition.x,
|
31
|
+
y: event.y - startPosition.y
|
32
|
+
},
|
33
|
+
singleMoveDistance: {
|
34
|
+
x: event.x - lastPosition.x,
|
35
|
+
y: event.y - lastPosition.y
|
36
|
+
}
|
37
|
+
};
|
38
|
+
// record lastPosition
|
39
|
+
lastPosition.x = event.x;
|
40
|
+
lastPosition.y = event.y;
|
41
|
+
callBack(positionInfo);
|
42
|
+
};
|
43
|
+
const handleMouseUp = ()=>{
|
44
|
+
isDragging.value = false;
|
45
|
+
};
|
46
|
+
onMounted(()=>{
|
47
|
+
document.addEventListener('mousedown', handleMouseDown);
|
48
|
+
document.addEventListener('mousemove', handleMouseMove);
|
49
|
+
document.addEventListener('mouseup', handleMouseUp);
|
50
|
+
});
|
51
|
+
onBeforeUnmount(()=>{
|
52
|
+
document.removeEventListener('mousedown', handleMouseDown);
|
53
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
54
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
55
|
+
});
|
56
|
+
return {
|
57
|
+
isDragging
|
58
|
+
};
|
59
|
+
};
|
@@ -0,0 +1,185 @@
|
|
1
|
+
import { onBeforeMount, onBeforeUnmount } from 'vue';
|
2
|
+
/**
|
3
|
+
* 获取引用资料的 HTML 内容
|
4
|
+
* @param documents
|
5
|
+
* @returns
|
6
|
+
*/ export const getHtmlContentFromDocuments = (documents)=>{
|
7
|
+
let htmlContent = `<section class="knowledge-head click-close"><svg class="ai-ui-sdk-wenzhang"><use href="#ai-ui-sdk-wenzhang"></use></svg>找到 ${documents.length} 篇资料参考<i class="ai-ui-sdk-icon ai-ui-sdk-angle-up"></i></section><ul class="knowledge-body">`;
|
8
|
+
documents.forEach((document1)=>{
|
9
|
+
const { path, file_path: filePath, display_name: displayName, preview_path: previewPath } = document1.metadata;
|
10
|
+
const title = displayName || filePath.split('/').pop();
|
11
|
+
htmlContent += `<li
|
12
|
+
class="knowledge-item"
|
13
|
+
>
|
14
|
+
<i class="ai-ui-sdk-icon ai-ui-sdk-zhishiku"></i>
|
15
|
+
<a href="${previewPath}" title="${title} (${previewPath})" target="_blank" class="knowledge-link g-flex-truncate">
|
16
|
+
${title}
|
17
|
+
</a>
|
18
|
+
<a href="${path}" title="预览原文" target="_blank" class="knowledge-link hover-show">
|
19
|
+
<i class="ai-ui-sdk-icon ai-ui-sdk-yanjing-kejian"></i>
|
20
|
+
</a>
|
21
|
+
</li>`;
|
22
|
+
});
|
23
|
+
htmlContent += '</ul>';
|
24
|
+
return htmlContent;
|
25
|
+
};
|
26
|
+
/**
|
27
|
+
* 移除引用资料的 HTML 内容
|
28
|
+
* @param content
|
29
|
+
* @returns
|
30
|
+
*/ export const removeReferenceDoc = (content)=>{
|
31
|
+
return content.replace(/<section class="knowledge-head click-close">[\s\S]*?<\/section>/, '').replace(/<ul class="knowledge-body">[\s\S]*?<\/ul>/, '').replace(/<section class="knowledge-tips">[\s\S]*?<\/section>/, '');
|
32
|
+
};
|
33
|
+
export const useReferenceDoc = ()=>{
|
34
|
+
let styleEle = null;
|
35
|
+
const addReferenceDocStyle = ()=>{
|
36
|
+
// 旧版知识样式
|
37
|
+
const oldStyle = `.knowledge-tips {
|
38
|
+
position: relative;
|
39
|
+
padding: 6px 8px;
|
40
|
+
margin-bottom: 14px;
|
41
|
+
line-height: 22px;
|
42
|
+
background: #f5f7fa;
|
43
|
+
border-radius: 4px;
|
44
|
+
|
45
|
+
&.closed {
|
46
|
+
.bkaidev-angle-up {
|
47
|
+
transform: rotate(180deg);
|
48
|
+
}
|
49
|
+
|
50
|
+
.knowledge-summary {
|
51
|
+
margin-bottom: 0;
|
52
|
+
}
|
53
|
+
|
54
|
+
.knowledge-link {
|
55
|
+
display: none;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
.bkaidev-angle-up {
|
60
|
+
position: absolute;
|
61
|
+
top: 4px;
|
62
|
+
right: 0px;
|
63
|
+
font-size: 22px;
|
64
|
+
color: #979ba5;
|
65
|
+
cursor: pointer;
|
66
|
+
}
|
67
|
+
|
68
|
+
.bkaidev-help-document {
|
69
|
+
margin-right: 4px;
|
70
|
+
font-size: 19px;
|
71
|
+
color: #3a84ff;
|
72
|
+
}
|
73
|
+
|
74
|
+
.knowledge-summary {
|
75
|
+
display: block;
|
76
|
+
margin-bottom: 4px;
|
77
|
+
color: #313238;
|
78
|
+
}
|
79
|
+
|
80
|
+
.knowledge-link {
|
81
|
+
display: block;
|
82
|
+
color: #3a84ff;
|
83
|
+
text-decoration: none;
|
84
|
+
cursor: pointer;
|
85
|
+
|
86
|
+
.bkaidev-cc-jump-link {
|
87
|
+
font-size: 14px;
|
88
|
+
}
|
89
|
+
|
90
|
+
&:last-child {
|
91
|
+
margin-bottom: 2px;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}`;
|
95
|
+
// 新版知识样式
|
96
|
+
const newStyle = `.knowledge-head {
|
97
|
+
display: flex;
|
98
|
+
align-items: center;
|
99
|
+
padding: 0 8px 0 6px;
|
100
|
+
margin-bottom: 8px;
|
101
|
+
line-height: 28px;
|
102
|
+
background: #F0F1F5;
|
103
|
+
border-radius: 4px;
|
104
|
+
font-size: 12px;
|
105
|
+
color: #313238;
|
106
|
+
cursor: pointer;
|
107
|
+
width: fit-content;
|
108
|
+
|
109
|
+
.ai-ui-sdk-wenzhang {
|
110
|
+
width: 14px;
|
111
|
+
height: 14px;
|
112
|
+
margin-right: 6px;
|
113
|
+
}
|
114
|
+
|
115
|
+
.ai-ui-sdk-angle-up {
|
116
|
+
font-size: 22px;
|
117
|
+
color: #4D4F56;
|
118
|
+
margin-left: 4px;
|
119
|
+
}
|
120
|
+
|
121
|
+
&.closed {
|
122
|
+
margin-bottom: 16px;
|
123
|
+
|
124
|
+
.ai-ui-sdk-angle-up {
|
125
|
+
transform: rotate(180deg);
|
126
|
+
}
|
127
|
+
|
128
|
+
&~ .knowledge-body {
|
129
|
+
display: none;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
&:hover {
|
134
|
+
background: #EAEBF0;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
.knowledge-body {
|
138
|
+
background: #F5F7FA;
|
139
|
+
padding: 16px 0 !important;
|
140
|
+
.knowledge-item {
|
141
|
+
padding-left: 10px;
|
142
|
+
display: flex;
|
143
|
+
align-items: center;
|
144
|
+
line-height: 28px;
|
145
|
+
.hover-show {
|
146
|
+
display: none;
|
147
|
+
}
|
148
|
+
a {
|
149
|
+
margin-right: 10px;
|
150
|
+
&:has(i) {
|
151
|
+
padding: 0 10px;
|
152
|
+
margin-right: 0;
|
153
|
+
text-decoration: none !important;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
.ai-ui-sdk-zhishiku {
|
157
|
+
color: #D66F6B;
|
158
|
+
font-size: 14px;
|
159
|
+
margin-right: 6px;
|
160
|
+
}
|
161
|
+
&:hover {
|
162
|
+
background: #EAEBF0;
|
163
|
+
.hover-show {
|
164
|
+
display: inline;
|
165
|
+
}
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}`;
|
169
|
+
styleEle = document.createElement('style');
|
170
|
+
styleEle.textContent = oldStyle + newStyle;
|
171
|
+
document.head.appendChild(styleEle);
|
172
|
+
};
|
173
|
+
const removeReferenceDocStyle = ()=>{
|
174
|
+
if (styleEle) {
|
175
|
+
styleEle.remove();
|
176
|
+
styleEle = null;
|
177
|
+
}
|
178
|
+
};
|
179
|
+
onBeforeMount(()=>{
|
180
|
+
addReferenceDocStyle();
|
181
|
+
});
|
182
|
+
onBeforeUnmount(()=>{
|
183
|
+
removeReferenceDocStyle();
|
184
|
+
});
|
185
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { useReferenceDoc } from './use-reference-doc.js';
|
2
|
+
import { useThink } from './use-think.js';
|
3
|
+
import '../css/style.css';
|
4
|
+
import '../css/iconcool.js';
|
5
|
+
// ai 样式。注意:全局引入一次即可
|
6
|
+
export const useStyle = ()=>{
|
7
|
+
// 引用资料
|
8
|
+
useReferenceDoc();
|
9
|
+
// 思考
|
10
|
+
useThink();
|
11
|
+
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { SummaryCallbacks } from '../types/
|
1
|
+
import type { SummaryCallbacks } from '../types/session';
|
2
2
|
export declare const useSummary: ({ handleStart, handleEnd, handleError, }?: SummaryCallbacks) => {
|
3
3
|
summary: ({ content, url, headers, model, }: {
|
4
4
|
content: string;
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { SessionPromptRole } from '../types/enum.js';
|
2
|
+
import { removeReferenceDoc } from './use-reference-doc.js';
|
3
|
+
import { removeThink } from './use-think.js';
|
4
|
+
import { ChatHelper } from '../common/chart-helper.js';
|
5
|
+
// ai 总结
|
6
|
+
export const useSummary = ({ handleStart, handleEnd, handleError } = {})=>{
|
7
|
+
let summaryText = '';
|
8
|
+
const handleStartChat = ()=>{
|
9
|
+
summaryText = '';
|
10
|
+
return handleStart === null || handleStart === void 0 ? void 0 : handleStart();
|
11
|
+
};
|
12
|
+
const handleTextChat = (sessionCode, message, cover)=>{
|
13
|
+
if (cover || summaryText === '正在思考...') {
|
14
|
+
summaryText = message;
|
15
|
+
} else {
|
16
|
+
summaryText += message;
|
17
|
+
}
|
18
|
+
};
|
19
|
+
const handleEndChat = ()=>{
|
20
|
+
if (summaryText === '无话可说') {
|
21
|
+
summaryText = '';
|
22
|
+
}
|
23
|
+
return handleEnd === null || handleEnd === void 0 ? void 0 : handleEnd(summaryText);
|
24
|
+
};
|
25
|
+
const handleErrorChat = (sessionCode, message, code)=>{
|
26
|
+
return handleError === null || handleError === void 0 ? void 0 : handleError(message, code);
|
27
|
+
};
|
28
|
+
const chatHelper = new ChatHelper({
|
29
|
+
handleStart: handleStartChat,
|
30
|
+
handleText: handleTextChat,
|
31
|
+
handleEnd: handleEndChat,
|
32
|
+
handleError: handleErrorChat
|
33
|
+
});
|
34
|
+
const summary = ({ content, url, headers, model })=>{
|
35
|
+
const filterContent = removeThink(removeReferenceDoc(content));
|
36
|
+
const prompts = [
|
37
|
+
{
|
38
|
+
role: SessionPromptRole.User,
|
39
|
+
content: `你是一个总结大师,请帮助我对下面这段话进行总结。要求总结精炼,不超过 15 个字!且末尾没有标点符号!请注意:如果你无法总结,请回复“无话可说”!\n文字如下:\n${filterContent}`
|
40
|
+
}
|
41
|
+
];
|
42
|
+
chatHelper.stream({
|
43
|
+
sessionCode: 'summary',
|
44
|
+
url,
|
45
|
+
data: {
|
46
|
+
prompts,
|
47
|
+
model
|
48
|
+
},
|
49
|
+
headers
|
50
|
+
});
|
51
|
+
};
|
52
|
+
return {
|
53
|
+
summary
|
54
|
+
};
|
55
|
+
};
|
@@ -0,0 +1,135 @@
|
|
1
|
+
import { onBeforeMount, onBeforeUnmount } from 'vue';
|
2
|
+
import { durationFormatter } from '../common/util.js';
|
3
|
+
/**
|
4
|
+
* 获取思考的 HTML 内容
|
5
|
+
* @param chatContent 聊天内容
|
6
|
+
* @param content 思考内容
|
7
|
+
* @param elapsedTime 思考时间
|
8
|
+
* @returns 完整的 chatContent
|
9
|
+
*/ export const getHtmlContentFromThink = (chatContent, content, cover, elapsedTime)=>{
|
10
|
+
let htmlContent = chatContent === '内容正在生成中...' || cover ? '' : chatContent;
|
11
|
+
// 思考开始
|
12
|
+
if (!htmlContent.includes('<section class="think-head click-close">')) {
|
13
|
+
htmlContent += `<section class="think-head click-close">
|
14
|
+
<i class="ai-ui-sdk-icon ai-ui-sdk-sikao"></i>思考中...<i class="ai-ui-sdk-icon ai-ui-sdk-angle-up"></i>
|
15
|
+
</section>
|
16
|
+
<section class="think-body">
|
17
|
+
${content}
|
18
|
+
</section>`;
|
19
|
+
} else {
|
20
|
+
// 补充思考内容
|
21
|
+
const thinkBodyMatch = htmlContent.match(/<section class="think-body">([\s\S]*?)<\/section>/);
|
22
|
+
if (thinkBodyMatch) {
|
23
|
+
// 原有思考内容
|
24
|
+
const thinkContent = thinkBodyMatch[1];
|
25
|
+
// 在最后的换行符前面添加新的思考内容
|
26
|
+
const newThinkContent = thinkContent.replace(/\n$/g, `${content}\n`);
|
27
|
+
htmlContent = htmlContent.replace(thinkContent, newThinkContent);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
// 思考结束
|
31
|
+
if (elapsedTime) {
|
32
|
+
htmlContent = htmlContent.replace('思考中...', `已完成思考 (耗时:${durationFormatter(elapsedTime)})`);
|
33
|
+
}
|
34
|
+
return htmlContent;
|
35
|
+
};
|
36
|
+
/**
|
37
|
+
* 移除思考的 HTML 内容
|
38
|
+
* @param content
|
39
|
+
* @returns
|
40
|
+
*/ export const removeThink = (content)=>{
|
41
|
+
// 移除思考头部
|
42
|
+
const afterRemoveThinkHead = content.replace(/<section class="think-head click-close">[\s\S]*<\/section>/, '');
|
43
|
+
// 移除思考内容
|
44
|
+
let afterRemoveThinkBody = afterRemoveThinkHead.replace(/<section class="think-body">[\s\S]*<\/section>/, '');
|
45
|
+
// 如果内容只有思考,那就给ai传递思考内容
|
46
|
+
if (afterRemoveThinkBody.trim() === '') {
|
47
|
+
const thinkBodyMatch = content.match(/<section class="think-body">([\s\S]*?)<\/section>/);
|
48
|
+
if (thinkBodyMatch) {
|
49
|
+
[, afterRemoveThinkBody] = thinkBodyMatch;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
return afterRemoveThinkBody;
|
53
|
+
};
|
54
|
+
/**
|
55
|
+
* 判断是否是思考中
|
56
|
+
* @param content
|
57
|
+
* @returns
|
58
|
+
*/ export const isThinking = (content)=>{
|
59
|
+
// 是否开始思考
|
60
|
+
const isStartThinking = content === '正在思考...';
|
61
|
+
// 判断是否空思考
|
62
|
+
const thinkBodyMatch = content.match(/<section class="think-body">([\s\S]*?)<\/section>$/);
|
63
|
+
const isEmptyThinking = thinkBodyMatch && thinkBodyMatch[1].trim() === '';
|
64
|
+
return isStartThinking || isEmptyThinking;
|
65
|
+
};
|
66
|
+
// 思考
|
67
|
+
export const useThink = ()=>{
|
68
|
+
let styleEle = null;
|
69
|
+
const addThinkStyle = ()=>{
|
70
|
+
const style = `.think-head {
|
71
|
+
display: flex;
|
72
|
+
align-items: center;
|
73
|
+
padding: 0 8px 0 6px;
|
74
|
+
margin-bottom: 8px;
|
75
|
+
line-height: 28px;
|
76
|
+
background: #F0F1F5;
|
77
|
+
border-radius: 4px;
|
78
|
+
font-size: 12px;
|
79
|
+
color: #313238;
|
80
|
+
cursor: pointer;
|
81
|
+
width: fit-content;
|
82
|
+
.ai-ui-sdk-sikao {
|
83
|
+
font-size: 14px;
|
84
|
+
color: #979ba5;
|
85
|
+
margin-right: 4px;
|
86
|
+
}
|
87
|
+
|
88
|
+
.ai-ui-sdk-angle-up {
|
89
|
+
font-size: 22px;
|
90
|
+
color: #4D4F56;
|
91
|
+
margin-left: 4px;
|
92
|
+
}
|
93
|
+
|
94
|
+
&.closed {
|
95
|
+
margin-bottom: 16px;
|
96
|
+
|
97
|
+
.ai-ui-sdk-angle-up {
|
98
|
+
transform: rotate(180deg);
|
99
|
+
}
|
100
|
+
|
101
|
+
&~ .think-body {
|
102
|
+
display: none;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
&:hover {
|
107
|
+
background: #EAEBF0;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
.think-body {
|
111
|
+
background: #F5F7FA;
|
112
|
+
color: #979BA5;
|
113
|
+
padding: 16px;
|
114
|
+
margin-bottom: 16px;
|
115
|
+
&~ .knowledge-head {
|
116
|
+
margin-bottom: 8px;
|
117
|
+
}
|
118
|
+
}`;
|
119
|
+
styleEle = document.createElement('style');
|
120
|
+
styleEle.textContent = style;
|
121
|
+
document.head.appendChild(styleEle);
|
122
|
+
};
|
123
|
+
const removeThinkStyle = ()=>{
|
124
|
+
if (styleEle) {
|
125
|
+
styleEle.remove();
|
126
|
+
styleEle = null;
|
127
|
+
}
|
128
|
+
};
|
129
|
+
onBeforeMount(()=>{
|
130
|
+
addThinkStyle();
|
131
|
+
});
|
132
|
+
onBeforeUnmount(()=>{
|
133
|
+
removeThinkStyle();
|
134
|
+
});
|
135
|
+
};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { emitEvent } from '../../event/index.js';
|
2
|
+
import { EventType, HttpErrorCode } from '../../types/enum.js';
|
3
|
+
import { Message } from 'bkui-vue';
|
4
|
+
// 请求执行失败拦截器
|
5
|
+
export default ((error, config)=>{
|
6
|
+
const { code, message, response } = error;
|
7
|
+
// 用户登录状态失效
|
8
|
+
if ([
|
9
|
+
'ret: 1002',
|
10
|
+
'ret: 1001',
|
11
|
+
'user authentication failed'
|
12
|
+
].some((item)=>{
|
13
|
+
var _response_message;
|
14
|
+
return response === null || response === void 0 ? void 0 : (_response_message = response.message) === null || _response_message === void 0 ? void 0 : _response_message.includes(item);
|
15
|
+
}) || code === HttpErrorCode.UnLogin) {
|
16
|
+
emitEvent(EventType.Unlogin);
|
17
|
+
} else if (code === HttpErrorCode.IamNoPermission && !config.noCheckPermission) {
|
18
|
+
emitEvent(EventType.Unauthorized);
|
19
|
+
} else if (config.globalError && code !== HttpErrorCode.Aborted) {
|
20
|
+
// 全局捕获错误给出提示
|
21
|
+
Message({
|
22
|
+
theme: 'error',
|
23
|
+
message,
|
24
|
+
width: 'auto'
|
25
|
+
});
|
26
|
+
}
|
27
|
+
return Promise.reject(error);
|
28
|
+
});
|
@@ -0,0 +1,25 @@
|
|
1
|
+
export interface IFetchConfig extends RequestInit {
|
2
|
+
requestType?: 'json' | 'formData';
|
3
|
+
responseType?: 'json' | 'text' | 'formData' | 'file' | 'blob';
|
4
|
+
globalError?: Boolean;
|
5
|
+
signal?: AbortSignal;
|
6
|
+
withoutSpace?: boolean;
|
7
|
+
noCheckPermission?: boolean;
|
8
|
+
}
|
9
|
+
type HttpMethod = <T>(url: string, payload?: any, config?: IFetchConfig) => Promise<T>;
|
10
|
+
interface IHttp {
|
11
|
+
get: HttpMethod;
|
12
|
+
post: HttpMethod;
|
13
|
+
put: HttpMethod;
|
14
|
+
delete: HttpMethod;
|
15
|
+
head: HttpMethod;
|
16
|
+
options: HttpMethod;
|
17
|
+
patch: HttpMethod;
|
18
|
+
}
|
19
|
+
declare const http: IHttp;
|
20
|
+
declare const withAbort: <R, T extends any[]>(fn: (signal: AbortSignal, ...args: T) => Promise<R>) => {
|
21
|
+
(...args: T): Promise<R>;
|
22
|
+
abort(): void | undefined;
|
23
|
+
};
|
24
|
+
export default http;
|
25
|
+
export { withAbort };
|