byt-lingxiao-ai 0.3.22 → 0.3.23
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/components/AiMessage.vue +25 -88
- package/components/mixins/messageMixin.js +19 -28
- package/components/utils/StreamParser.js +88 -166
- package/dist/index.common.js +122 -201
- package/dist/index.common.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.umd.js +122 -201
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
|
|
9
9
|
Outdated base version: https://github.com/primer/github-syntax-light
|
|
10
10
|
Current colors taken from GitHub's CSS
|
|
11
|
-
*/.hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0}.ai-loading[data-v-
|
|
11
|
+
*/.hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0}.ai-loading[data-v-7f2cec94]{display:flex;align-items:center;padding:12px 0;height:24px}.dot[data-v-7f2cec94]{width:8px;height:8px;margin-right:6px;background-color:#86909c;border-radius:50%;animation:dot-bounce-7f2cec94 1.4s ease-in-out infinite both}.dot[data-v-7f2cec94]:first-child{animation-delay:-.32s}.dot[data-v-7f2cec94]:nth-child(2){animation-delay:-.16s}.dot[data-v-7f2cec94]:nth-child(3){animation-delay:0s}@keyframes dot-bounce-7f2cec94{0%,80%,to{transform:scale(0);opacity:.5}40%{transform:scale(1);opacity:1}}.chat-window-message-ai[data-v-7f2cec94]{display:flex;gap:12px;align-items:flex-start;max-width:100%;border-radius:12px;background:#f6f8fc;padding:8px 12px}.ai-render[data-v-7f2cec94]{width:100%}.ai-thinking[data-v-7f2cec94]{margin-bottom:8px}.ai-thinking-time[data-v-7f2cec94]{border-radius:9px;background:#ecedf4;color:#86909c;font-family:"Alibaba PuHuiTi 2.0";font-size:16px;font-style:normal;font-weight:500;padding:0 30px 0 30px;height:28px;box-sizing:border-box;display:inline-flex;align-items:center;position:relative;-webkit-user-select:none;-moz-user-select:none;user-select:none;cursor:pointer}.ai-thinking-time[data-v-7f2cec94]:before{left:6px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAYFBMVEUAAADu8P/u8P/u8P/u8P/u8P/u8P/s7//v8v/s7//v7//t7//v8f/u8P/l6P/Iz/+stv+1v//S1/9Xbf/b3/+/x/+irv/b4P+Zpv9yhP+Pnv+Glv+Qnv99jf9hdf/R1/8RfKwjAAAADXRSTlMA36/vz5CAYF9QEHBvMEqmkAAAAM9JREFUGNNNkIkSgyAMRAG1niEoouDV///LJvFqZmDgkZ0Nq6SazmiA3FTqrTqDq/SDC7nbE39O9iHQA/S0HL0UzEppG3gfpbsmqPnwXcFtsAQ+Zw032ol7A2vBkaRVRsRpOPbN44r8YFTOinmxKbpjjKPMpQAGmCx6R/6+h2gRgCDe0BGcgKEWecQUpzSuMll+Gs07+rR63C+j9hppDoFdHG2VaiQMXMAtsAUx54jeb87yzeoOibwDh2L/Y3qrUFeV+kYZR/Rgk5OD6Rq5/QAhCBJvrLC2lgAAAABJRU5ErkJggg==) no-repeat;background-size:cover}.ai-thinking-time[data-v-7f2cec94]:after,.ai-thinking-time[data-v-7f2cec94]:before{content:"";position:absolute;top:50%;transform:translateY(-50%);width:16px;height:16px}.ai-thinking-time[data-v-7f2cec94]:after{right:6px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAFVBMVEUAAACDj5eGkJyGj5uFj5uGj5uAj5/flAqRAAAAB3RSTlMAIN+ggHAQx7ts8QAAAClJREFUCNdjIBWwCUAZQooQmlHZSAAiYMCsCBFgYAALsRowMDA7kGY8AIDkAfQcVWSDAAAAAElFTkSuQmCC) no-repeat;background-size:cover}.ai-thinking-content[data-v-7f2cec94]{color:#86909c;font-size:14px;padding:8px 0 8px 12px}.ai-content[data-v-7f2cec94],.ai-thinking-content[data-v-7f2cec94]{font-family:"Alibaba PuHuiTi 2.0";font-style:normal;font-weight:400;line-height:24px}.ai-content[data-v-7f2cec94]{color:#4e5969;font-size:16px}.markdown-body[data-v-7f2cec94]{word-wrap:break-word}.markdown-body[data-v-7f2cec94] h1,.markdown-body[data-v-7f2cec94] h2,.markdown-body[data-v-7f2cec94] h3,.markdown-body[data-v-7f2cec94] h4{margin:16px 0 8px 0;font-weight:600;line-height:1.4;color:#1f2937}.markdown-body[data-v-7f2cec94] h1{font-size:24px;border-bottom:2px solid #e5e7eb;padding-bottom:8px}.markdown-body[data-v-7f2cec94] h2{font-size:20px;border-bottom:1px solid #e5e7eb;padding-bottom:6px}.markdown-body[data-v-7f2cec94] h3{font-size:18px}.markdown-body[data-v-7f2cec94] h4{font-size:16px}.markdown-body[data-v-7f2cec94] ol{list-style-type:decimal;padding-left:24px;margin:8px 0}.markdown-body[data-v-7f2cec94] ul{list-style-type:disc;padding-left:24px;margin:8px 0}.markdown-body[data-v-7f2cec94] li{display:list-item}.markdown-body[data-v-7f2cec94] code{background-color:rgba(175,184,193,.2);border-radius:3px;font-size:85%;margin:0;padding:.2em .4em;font-family:Monaco,Menlo,Consolas,Courier New,monospace;color:#e83e8c}.markdown-body[data-v-7f2cec94] pre{background-color:#f6f8fa;border-radius:6px;padding:16px;overflow:auto;margin:12px 0;border:1px solid #e1e4e8}.markdown-body[data-v-7f2cec94] pre code{background-color:transparent;border:0;display:inline;line-height:inherit;margin:0;overflow:visible;padding:0;word-wrap:normal;color:#24292e;font-size:14px}.markdown-body[data-v-7f2cec94] table{border:1px solid #dfe2e5;max-height:500px;margin:12px 0;border-collapse:collapse;width:100%;display:block;overflow:auto}.markdown-body[data-v-7f2cec94] table::-webkit-scrollbar{height:6px}.markdown-body[data-v-7f2cec94] table::-webkit-scrollbar-track{background-color:#f3f4f6}.markdown-body[data-v-7f2cec94] table::-webkit-scrollbar-thumb{background-color:#d1d5db;border-radius:3px}.markdown-body[data-v-7f2cec94] table::-webkit-scrollbar-thumb:hover{background-color:#9ca3af}.markdown-body[data-v-7f2cec94] table td,.markdown-body[data-v-7f2cec94] table th{border:1px solid #dfe2e5;padding:10px 14px;text-align:left}.markdown-body[data-v-7f2cec94] table th{background-color:#f3f4f6;font-weight:600;color:#374151}.markdown-body[data-v-7f2cec94] table tr:nth-child(2n){background-color:#f9fafb}.markdown-body[data-v-7f2cec94] .markdown-table tr:hover{background-color:#f3f4f6;transition:background-color .2s}.markdown-body[data-v-7f2cec94] ol,.markdown-body[data-v-7f2cec94] ul{padding-left:24px;margin:8px 0}.markdown-body[data-v-7f2cec94] li{margin:4px 0;line-height:1.6}.markdown-body[data-v-7f2cec94] strong{font-weight:600;color:#1f2937}.markdown-body[data-v-7f2cec94] em{font-style:italic}.markdown-body[data-v-7f2cec94] del{text-decoration:line-through;opacity:.7}.markdown-body[data-v-7f2cec94] blockquote{border-left:4px solid #dfe2e5;padding-left:16px;margin:12px 0;color:#6b7280;font-style:italic}.markdown-body[data-v-7f2cec94] a{color:#3b82f6;text-decoration:none}.markdown-body[data-v-7f2cec94] a:hover{text-decoration:underline;color:#2563eb}.markdown-body[data-v-7f2cec94] img{max-width:100%;border-radius:6px;margin:12px 0}.markdown-body[data-v-7f2cec94] hr{border:none;border-top:1px solid #e5e7eb;margin:16px 0}.markdown-body[data-v-7f2cec94] br{line-height:.8em}.chat-window-empty[data-v-dfc4454c]{width:300px;height:300px;background:url(img/empty.f36cb82e.png) no-repeat;background-size:cover;margin:auto}.chat-window-content[data-v-dfc4454c]{flex:1;padding:16px;overflow-y:auto;display:flex;flex-direction:column;gap:8px}.scrollbar-hide[data-v-dfc4454c]::-webkit-scrollbar{display:none}.scrollbar-hide[data-v-dfc4454c]{-ms-overflow-style:none;scrollbar-width:none}[data-v-2cd84254] .el-textarea__inner{border:none!important;padding:0 5px;font-family:PingFang SC!important}[data-v-2cd84254] .el-textarea__inner::-webkit-scrollbar{width:6px;height:6px}[data-v-2cd84254] .el-textarea__inner::-webkit-scrollbar-thumb{background:rgba(0,0,0,.1);border-radius:3px}[data-v-2cd84254] .el-textarea__inner::-webkit-scrollbar-track{background:transparent}.chat-window-footer[data-v-2cd84254]{padding:16px}.chat-window-textarea[data-v-2cd84254]{min-height:99px;max-height:180px;border-radius:8px;border:1px solid #f2f2f2;background:#fff;display:flex;flex-direction:column}.chat-window-input[data-v-2cd84254]{padding:10px 12px;font-size:16px;font-family:PingFang SC;box-sizing:border-box}.chat-window-bar[data-v-2cd84254]{display:flex;justify-content:flex-end;padding:8px}.chat-window-send[data-v-2cd84254]{width:70px;height:36px;flex-shrink:0;border-radius:6px;background:rgba(43,128,246,.1);display:flex;align-items:center;justify-content:center;cursor:pointer}.chat-overlay[data-v-bc074e36]{position:fixed;top:0;left:0;width:100%;height:100%;background:transparent;z-index:9999;pointer-events:none}.chat-window[data-v-bc074e36]{width:480px;height:740px;border-radius:14px;background:#fff;box-shadow:0 2px 20px 0 rgba(0,0,0,.16);position:absolute;bottom:0;right:60px;overflow:hidden;display:flex;flex-direction:column;z-index:10000}.hidden-audio[data-v-244aa1c1]{position:absolute;left:-9999px;opacity:0;pointer-events:none}.chat[data-v-244aa1c1]{position:fixed;bottom:20px;right:10px;z-index:10001}
|
package/dist/index.umd.js
CHANGED
|
@@ -29177,8 +29177,8 @@ var UserMessage_component = normalizeComponent(
|
|
|
29177
29177
|
)
|
|
29178
29178
|
|
|
29179
29179
|
/* harmony default export */ var UserMessage = (UserMessage_component.exports);
|
|
29180
|
-
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/AiMessage.vue?vue&type=template&id=
|
|
29181
|
-
var
|
|
29180
|
+
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/AiMessage.vue?vue&type=template&id=7f2cec94&scoped=true
|
|
29181
|
+
var AiMessagevue_type_template_id_7f2cec94_scoped_true_render = function render() {
|
|
29182
29182
|
var _vm = this,
|
|
29183
29183
|
_c = _vm._self._c;
|
|
29184
29184
|
return _c('div', {
|
|
@@ -29193,39 +29193,28 @@ var AiMessagevue_type_template_id_0d2964f2_scoped_true_render = function render(
|
|
|
29193
29193
|
staticClass: "dot"
|
|
29194
29194
|
}), _c('div', {
|
|
29195
29195
|
staticClass: "dot"
|
|
29196
|
-
})]) : _vm._e(), _vm.
|
|
29197
|
-
|
|
29198
|
-
|
|
29199
|
-
|
|
29200
|
-
|
|
29201
|
-
staticClass: "ai-thinking",
|
|
29202
|
-
on: {
|
|
29203
|
-
"click": function ($event) {
|
|
29204
|
-
return _vm.$emit('thinking-toggle');
|
|
29205
|
-
}
|
|
29206
|
-
}
|
|
29207
|
-
}, [_c('div', {
|
|
29208
|
-
staticClass: "ai-thinking-time"
|
|
29209
|
-
}, [_vm._v(" " + _vm._s(_vm.message.time ? `思考用时 ${_vm.message.time} 秒` : '思考中...') + " ")]), _vm.thinkingExpanded ? _c('div', {
|
|
29210
|
-
staticClass: "ai-thinking-content"
|
|
29211
|
-
}, [_vm._v(" " + _vm._s(item.text) + " ")]) : _vm._e()]) : item.type === 'tool' ? _c('div', {
|
|
29212
|
-
staticClass: "ai-tool"
|
|
29213
|
-
}, [_c('div', {
|
|
29214
|
-
staticClass: "ai-tool-header"
|
|
29215
|
-
}, [_vm._v(" 调用工具:" + _vm._s(item.tool.name) + " ")]), _c('details', [_c('summary', [_vm._v("参数")]), _c('pre', [_vm._v(_vm._s(item.tool.args))])]), item.tool.result ? _c('details', [_c('summary', [_vm._v("结果")]), _c('pre', [_vm._v(_vm._s(item.tool.result))])]) : _vm._e()]) : item.type === 'content' ? _c('div', {
|
|
29216
|
-
staticClass: "ai-content markdown-body",
|
|
29217
|
-
domProps: {
|
|
29218
|
-
"innerHTML": _vm._s(_vm.renderMarkdown(item.text))
|
|
29219
|
-
},
|
|
29220
|
-
on: {
|
|
29221
|
-
"click": _vm.handleLinkClick
|
|
29196
|
+
})]) : _vm._e(), _vm.message.thinking ? _c('div', {
|
|
29197
|
+
staticClass: "ai-thinking",
|
|
29198
|
+
on: {
|
|
29199
|
+
"click": function ($event) {
|
|
29200
|
+
return _vm.$emit('thinking-toggle');
|
|
29222
29201
|
}
|
|
29223
|
-
}
|
|
29224
|
-
|
|
29225
|
-
|
|
29226
|
-
}
|
|
29202
|
+
}
|
|
29203
|
+
}, [_c('div', {
|
|
29204
|
+
staticClass: "ai-thinking-time"
|
|
29205
|
+
}, [_vm._v(_vm._s(_vm.message.time ? `思考用时${_vm.message.time}秒` : '思考中...'))]), _vm.thinkingExpanded ? _c('div', {
|
|
29206
|
+
staticClass: "ai-thinking-content"
|
|
29207
|
+
}, [_vm._v(_vm._s(_vm.message.thinking))]) : _vm._e()]) : _vm._e(), _c('div', {
|
|
29208
|
+
staticClass: "ai-content markdown-body",
|
|
29209
|
+
domProps: {
|
|
29210
|
+
"innerHTML": _vm._s(_vm.renderedContent)
|
|
29211
|
+
},
|
|
29212
|
+
on: {
|
|
29213
|
+
"click": _vm.handleLinkClick
|
|
29214
|
+
}
|
|
29215
|
+
})])]);
|
|
29227
29216
|
};
|
|
29228
|
-
var
|
|
29217
|
+
var AiMessagevue_type_template_id_7f2cec94_scoped_true_staticRenderFns = [];
|
|
29229
29218
|
|
|
29230
29219
|
// EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.delete.js
|
|
29231
29220
|
var web_url_search_params_delete = __webpack_require__(4603);
|
|
@@ -31011,6 +31000,8 @@ var lib = __webpack_require__(336);
|
|
|
31011
31000
|
|
|
31012
31001
|
|
|
31013
31002
|
|
|
31003
|
+
|
|
31004
|
+
// 创建自定义渲染器
|
|
31014
31005
|
const renderer = new d.Renderer();
|
|
31015
31006
|
|
|
31016
31007
|
// 自定义链接渲染
|
|
@@ -31030,8 +31021,8 @@ renderer.link = function ({
|
|
|
31030
31021
|
}
|
|
31031
31022
|
};
|
|
31032
31023
|
d.setOptions({
|
|
31033
|
-
renderer,
|
|
31034
|
-
highlight(code, lang) {
|
|
31024
|
+
renderer: renderer,
|
|
31025
|
+
highlight: function (code, lang) {
|
|
31035
31026
|
if (lang && es.getLanguage(lang)) {
|
|
31036
31027
|
return es.highlight(code, {
|
|
31037
31028
|
language: lang
|
|
@@ -31054,34 +31045,19 @@ d.setOptions({
|
|
|
31054
31045
|
thinkingExpanded() {
|
|
31055
31046
|
return this.message.thinkingExpanded !== false;
|
|
31056
31047
|
},
|
|
31048
|
+
renderedContent() {
|
|
31049
|
+
return d.parse(this.message.content || '');
|
|
31050
|
+
},
|
|
31057
31051
|
isLoading() {
|
|
31058
31052
|
return this.message.loading === true;
|
|
31059
|
-
}
|
|
31060
|
-
|
|
31061
|
-
|
|
31062
|
-
|
|
31063
|
-
|
|
31064
|
-
if (item.type === 'content') {
|
|
31065
|
-
if (last && last.type === 'content') {
|
|
31066
|
-
last.text += item.text;
|
|
31067
|
-
} else {
|
|
31068
|
-
last = {
|
|
31069
|
-
...item
|
|
31070
|
-
};
|
|
31071
|
-
result.push(last);
|
|
31072
|
-
}
|
|
31073
|
-
} else {
|
|
31074
|
-
last = null;
|
|
31075
|
-
result.push(item);
|
|
31076
|
-
}
|
|
31077
|
-
}
|
|
31078
|
-
return result;
|
|
31053
|
+
}
|
|
31054
|
+
},
|
|
31055
|
+
watch: {
|
|
31056
|
+
thinkStatus(newVal, oldVal) {
|
|
31057
|
+
console.log('thinkStatus 变化:', newVal, oldVal);
|
|
31079
31058
|
}
|
|
31080
31059
|
},
|
|
31081
31060
|
methods: {
|
|
31082
|
-
renderMarkdown(text) {
|
|
31083
|
-
return d.parse(text || '');
|
|
31084
|
-
},
|
|
31085
31061
|
handleLinkClick(event) {
|
|
31086
31062
|
const link = event.target.closest('a');
|
|
31087
31063
|
if (!link) return;
|
|
@@ -31111,10 +31087,10 @@ d.setOptions({
|
|
|
31111
31087
|
});
|
|
31112
31088
|
;// ./components/AiMessage.vue?vue&type=script&lang=js
|
|
31113
31089
|
/* harmony default export */ var components_AiMessagevue_type_script_lang_js = (AiMessagevue_type_script_lang_js);
|
|
31114
|
-
;// ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-54.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-54.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-54.use[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/AiMessage.vue?vue&type=style&index=0&id=
|
|
31090
|
+
;// ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-54.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-54.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-54.use[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/AiMessage.vue?vue&type=style&index=0&id=7f2cec94&prod&scoped=true&lang=css
|
|
31115
31091
|
// extracted by mini-css-extract-plugin
|
|
31116
31092
|
|
|
31117
|
-
;// ./components/AiMessage.vue?vue&type=style&index=0&id=
|
|
31093
|
+
;// ./components/AiMessage.vue?vue&type=style&index=0&id=7f2cec94&prod&scoped=true&lang=css
|
|
31118
31094
|
|
|
31119
31095
|
;// ./components/AiMessage.vue
|
|
31120
31096
|
|
|
@@ -31127,11 +31103,11 @@ d.setOptions({
|
|
|
31127
31103
|
|
|
31128
31104
|
var AiMessage_component = normalizeComponent(
|
|
31129
31105
|
components_AiMessagevue_type_script_lang_js,
|
|
31130
|
-
|
|
31131
|
-
|
|
31106
|
+
AiMessagevue_type_template_id_7f2cec94_scoped_true_render,
|
|
31107
|
+
AiMessagevue_type_template_id_7f2cec94_scoped_true_staticRenderFns,
|
|
31132
31108
|
false,
|
|
31133
31109
|
null,
|
|
31134
|
-
"
|
|
31110
|
+
"7f2cec94",
|
|
31135
31111
|
null
|
|
31136
31112
|
|
|
31137
31113
|
)
|
|
@@ -31652,138 +31628,99 @@ const TIME_JUMP_POINTS_URL = '/minio/lingxiaoai/timeJumpPoints.json'; // 语音u
|
|
|
31652
31628
|
});
|
|
31653
31629
|
;// ./components/utils/StreamParser.js
|
|
31654
31630
|
|
|
31655
|
-
// utils/StreamParser.js
|
|
31656
31631
|
class StreamParser {
|
|
31657
31632
|
constructor(options = {}) {
|
|
31658
31633
|
this.options = {
|
|
31659
31634
|
updateInterval: 16,
|
|
31635
|
+
// 每16ms刷新一次(约60fps)
|
|
31660
31636
|
debug: false,
|
|
31661
31637
|
...options
|
|
31662
31638
|
};
|
|
31663
31639
|
this.reset();
|
|
31664
31640
|
}
|
|
31641
|
+
|
|
31642
|
+
// 重置解析器状态
|
|
31665
31643
|
reset() {
|
|
31644
|
+
this.buffer = '';
|
|
31666
31645
|
this.contentBuffer = [];
|
|
31667
31646
|
this.thinkingBuffer = [];
|
|
31668
|
-
this.completedThinkingSegments = [];
|
|
31669
|
-
this.completedToolCalls = [];
|
|
31670
|
-
this.currentToolCall = null;
|
|
31671
|
-
this.protocolErrorBuffer = []; // ✅ 新增
|
|
31672
|
-
|
|
31673
31647
|
this.inTag = false;
|
|
31674
31648
|
this.tagBuffer = '';
|
|
31675
31649
|
this.updateTimer = null;
|
|
31676
|
-
this.status = 'output'; // thinking | output
|
|
31650
|
+
this.status = 'output'; // thinking | output
|
|
31677
31651
|
}
|
|
31652
|
+
|
|
31653
|
+
// 处理接收到的流数据块
|
|
31678
31654
|
processChunk(chunk, callback) {
|
|
31679
31655
|
if (!chunk) return;
|
|
31680
31656
|
this.parseContent(chunk, callback);
|
|
31681
31657
|
}
|
|
31658
|
+
|
|
31659
|
+
// 核心内容解析,支持 <think> 标签
|
|
31682
31660
|
parseContent(content, callback) {
|
|
31683
31661
|
let i = 0;
|
|
31684
31662
|
while (i < content.length) {
|
|
31685
31663
|
if (this.inTag) {
|
|
31686
|
-
const
|
|
31687
|
-
if (
|
|
31688
|
-
this.tagBuffer += content.
|
|
31664
|
+
const endIndex = content.indexOf('>', i);
|
|
31665
|
+
if (endIndex !== -1) {
|
|
31666
|
+
this.tagBuffer += content.substring(i, endIndex + 1);
|
|
31689
31667
|
this.handleTag(this.tagBuffer);
|
|
31690
31668
|
this.tagBuffer = '';
|
|
31691
31669
|
this.inTag = false;
|
|
31692
|
-
i =
|
|
31670
|
+
i = endIndex + 1;
|
|
31693
31671
|
} else {
|
|
31694
|
-
|
|
31672
|
+
// 标签未闭合,超过50字符强制输出,防止阻塞
|
|
31673
|
+
this.tagBuffer += content.substring(i);
|
|
31674
|
+
if (this.tagBuffer.length > 50) {
|
|
31675
|
+
this.appendText(this.tagBuffer);
|
|
31676
|
+
this.tagBuffer = '';
|
|
31677
|
+
this.inTag = false;
|
|
31678
|
+
}
|
|
31695
31679
|
break;
|
|
31696
31680
|
}
|
|
31697
31681
|
} else {
|
|
31698
|
-
const
|
|
31699
|
-
if (
|
|
31700
|
-
this.appendText(content.
|
|
31701
|
-
|
|
31702
|
-
|
|
31703
|
-
|
|
31704
|
-
|
|
31705
|
-
|
|
31706
|
-
|
|
31707
|
-
|
|
31708
|
-
|
|
31709
|
-
|
|
31682
|
+
const startIndex = content.indexOf('<', i);
|
|
31683
|
+
if (startIndex !== -1) {
|
|
31684
|
+
if (startIndex > i) this.appendText(content.substring(i, startIndex));
|
|
31685
|
+
const endIndex = content.indexOf('>', startIndex);
|
|
31686
|
+
if (endIndex !== -1) {
|
|
31687
|
+
const tag = content.substring(startIndex, endIndex + 1);
|
|
31688
|
+
this.handleTag(tag);
|
|
31689
|
+
i = endIndex + 1;
|
|
31690
|
+
} else {
|
|
31691
|
+
const nextChar = content[startIndex + 1];
|
|
31692
|
+
if (!/[a-zA-Z/]/.test(nextChar)) {
|
|
31693
|
+
// 很可能不是标签,直接当文本输出
|
|
31694
|
+
this.appendText('<');
|
|
31695
|
+
i = startIndex + 1;
|
|
31696
|
+
} else {
|
|
31697
|
+
this.inTag = true;
|
|
31698
|
+
this.tagBuffer = content.substring(startIndex);
|
|
31699
|
+
break;
|
|
31700
|
+
}
|
|
31701
|
+
}
|
|
31702
|
+
} else {
|
|
31703
|
+
this.appendText(content.substring(i));
|
|
31710
31704
|
break;
|
|
31711
31705
|
}
|
|
31712
|
-
const tag = content.slice(start, end + 1);
|
|
31713
|
-
this.handleTag(tag);
|
|
31714
|
-
i = end + 1;
|
|
31715
31706
|
}
|
|
31716
31707
|
}
|
|
31717
31708
|
this.scheduleUpdate(callback);
|
|
31718
31709
|
}
|
|
31710
|
+
|
|
31711
|
+
// 处理标签
|
|
31719
31712
|
handleTag(tag) {
|
|
31720
31713
|
const t = tag.toLowerCase();
|
|
31721
|
-
|
|
31722
|
-
// ---------- think ----------
|
|
31723
|
-
if (t === '<think>') {
|
|
31724
|
-
this.status = 'thinking';
|
|
31725
|
-
return;
|
|
31726
|
-
}
|
|
31727
|
-
if (t === '</think>') {
|
|
31728
|
-
if (this.thinkingBuffer.length) {
|
|
31729
|
-
this.completedThinkingSegments.push(this.thinkingBuffer.join(''));
|
|
31730
|
-
this.thinkingBuffer = [];
|
|
31731
|
-
}
|
|
31732
|
-
this.status = 'output';
|
|
31733
|
-
return;
|
|
31734
|
-
}
|
|
31735
|
-
|
|
31736
|
-
// ---------- tool_call ----------
|
|
31737
|
-
if (t.startsWith('<tool_call')) {
|
|
31738
|
-
const nameMatch = tag.match(/name\s*=\s*["'](.+?)["']/);
|
|
31739
|
-
this.currentToolCall = {
|
|
31740
|
-
id: `${Date.now()}-${Math.random()}`,
|
|
31741
|
-
name: nameMatch ? nameMatch[1] : 'unknown',
|
|
31742
|
-
args: '',
|
|
31743
|
-
result: '',
|
|
31744
|
-
status: 'calling'
|
|
31745
|
-
};
|
|
31746
|
-
this.status = 'tool_call';
|
|
31747
|
-
return;
|
|
31748
|
-
}
|
|
31749
|
-
if (t === '</tool_call>') {
|
|
31750
|
-
this.status = 'output';
|
|
31751
|
-
return;
|
|
31752
|
-
}
|
|
31753
|
-
|
|
31754
|
-
// ---------- tool_result ----------
|
|
31755
|
-
if (t === '<tool_result>') {
|
|
31756
|
-
this.status = 'tool_result';
|
|
31757
|
-
return;
|
|
31758
|
-
}
|
|
31759
|
-
if (t === '</tool_result>') {
|
|
31760
|
-
if (this.currentToolCall) {
|
|
31761
|
-
this.currentToolCall.status = 'done';
|
|
31762
|
-
this.completedToolCalls.push(this.currentToolCall);
|
|
31763
|
-
this.currentToolCall = null;
|
|
31764
|
-
}
|
|
31765
|
-
this.status = 'output';
|
|
31766
|
-
return;
|
|
31767
|
-
}
|
|
31768
|
-
|
|
31769
|
-
// ---------- ❌ 协议错误 ----------
|
|
31770
|
-
if (t.startsWith('<') && t.endsWith('>')) {
|
|
31771
|
-
this.protocolErrorBuffer.push(tag);
|
|
31772
|
-
this.status = 'output';
|
|
31773
|
-
}
|
|
31714
|
+
if (t === '<think>') this.status = 'thinking';else if (t === '</think>') this.status = 'output';
|
|
31774
31715
|
}
|
|
31716
|
+
|
|
31717
|
+
// 添加文本到缓冲区
|
|
31775
31718
|
appendText(text) {
|
|
31776
31719
|
if (!text) return;
|
|
31777
|
-
if (this.status === 'thinking')
|
|
31778
|
-
this.thinkingBuffer.push(text);
|
|
31779
|
-
} else if (this.status === 'tool_call') {
|
|
31780
|
-
this.currentToolCall && (this.currentToolCall.args += text);
|
|
31781
|
-
} else if (this.status === 'tool_result') {
|
|
31782
|
-
this.currentToolCall && (this.currentToolCall.result += text);
|
|
31783
|
-
} else {
|
|
31784
|
-
this.contentBuffer.push(text);
|
|
31785
|
-
}
|
|
31720
|
+
if (this.status === 'thinking') this.thinkingBuffer.push(text);else this.contentBuffer.push(text);
|
|
31786
31721
|
}
|
|
31722
|
+
|
|
31723
|
+
// 防抖刷新
|
|
31787
31724
|
scheduleUpdate(callback) {
|
|
31788
31725
|
if (this.updateTimer) return;
|
|
31789
31726
|
this.updateTimer = setTimeout(() => {
|
|
@@ -31791,39 +31728,32 @@ class StreamParser {
|
|
|
31791
31728
|
this.updateTimer = null;
|
|
31792
31729
|
}, this.options.updateInterval);
|
|
31793
31730
|
}
|
|
31731
|
+
|
|
31732
|
+
// 刷新缓冲区
|
|
31794
31733
|
flush(callback) {
|
|
31795
31734
|
if (!callback) return;
|
|
31796
31735
|
const result = {
|
|
31797
|
-
|
|
31798
|
-
|
|
31799
|
-
content: null,
|
|
31800
|
-
protocolError: null,
|
|
31736
|
+
thinking: this.thinkingBuffer.length ? this.thinkingBuffer.join('') : null,
|
|
31737
|
+
content: this.contentBuffer.length ? this.contentBuffer.join('') : null,
|
|
31801
31738
|
status: this.status
|
|
31802
31739
|
};
|
|
31803
|
-
|
|
31804
|
-
|
|
31805
|
-
this.protocolErrorBuffer = [];
|
|
31806
|
-
}
|
|
31807
|
-
if (this.completedThinkingSegments.length) {
|
|
31808
|
-
result.thinkingSegment = this.completedThinkingSegments.shift();
|
|
31809
|
-
}
|
|
31810
|
-
if (this.completedToolCalls.length) {
|
|
31811
|
-
result.toolCall = this.completedToolCalls.shift();
|
|
31812
|
-
}
|
|
31813
|
-
if (this.contentBuffer.length) {
|
|
31814
|
-
result.content = this.contentBuffer.join('');
|
|
31815
|
-
this.contentBuffer = [];
|
|
31816
|
-
}
|
|
31740
|
+
this.thinkingBuffer = [];
|
|
31741
|
+
this.contentBuffer = [];
|
|
31817
31742
|
callback(result);
|
|
31818
31743
|
}
|
|
31744
|
+
|
|
31745
|
+
// 完成解析
|
|
31819
31746
|
finish(callback) {
|
|
31820
|
-
if (this.
|
|
31821
|
-
this.
|
|
31822
|
-
this.
|
|
31747
|
+
if (this.inTag && this.tagBuffer) {
|
|
31748
|
+
this.appendText(this.tagBuffer);
|
|
31749
|
+
this.tagBuffer = '';
|
|
31750
|
+
this.inTag = false;
|
|
31823
31751
|
}
|
|
31824
31752
|
this.flush(callback);
|
|
31825
31753
|
if (this.updateTimer) clearTimeout(this.updateTimer);
|
|
31826
31754
|
}
|
|
31755
|
+
|
|
31756
|
+
// 销毁解析器
|
|
31827
31757
|
destroy() {
|
|
31828
31758
|
if (this.updateTimer) clearTimeout(this.updateTimer);
|
|
31829
31759
|
this.reset();
|
|
@@ -31873,7 +31803,9 @@ const getCookie = cname => {
|
|
|
31873
31803
|
type: 'ai',
|
|
31874
31804
|
sender: 'AI',
|
|
31875
31805
|
time: '',
|
|
31876
|
-
|
|
31806
|
+
thinking: '',
|
|
31807
|
+
charts: [],
|
|
31808
|
+
content: '',
|
|
31877
31809
|
loading: true,
|
|
31878
31810
|
thinkingExpanded: true
|
|
31879
31811
|
};
|
|
@@ -31906,7 +31838,7 @@ const getCookie = cname => {
|
|
|
31906
31838
|
const controller = new AbortController();
|
|
31907
31839
|
try {
|
|
31908
31840
|
const startTime = Date.now();
|
|
31909
|
-
const token = getCookie('bonyear-access_token') || `
|
|
31841
|
+
const token = getCookie('bonyear-access_token') || `44e7f112-63f3-429d-908d-2c97ec380de2`;
|
|
31910
31842
|
const response = await fetch(API_URL, {
|
|
31911
31843
|
method: 'POST',
|
|
31912
31844
|
signal: controller.signal,
|
|
@@ -31986,38 +31918,27 @@ const getCookie = cname => {
|
|
|
31986
31918
|
*/
|
|
31987
31919
|
handleStreamUpdate(result) {
|
|
31988
31920
|
if (!this.currentMessage) return;
|
|
31989
|
-
|
|
31990
|
-
if (
|
|
31991
|
-
this.currentMessage.
|
|
31992
|
-
type: 'protocol_error',
|
|
31993
|
-
id: Date.now() + Math.random(),
|
|
31994
|
-
raw: result.protocolError
|
|
31995
|
-
});
|
|
31921
|
+
console.log('收到更新:', result);
|
|
31922
|
+
if (this.currentMessage.loading) {
|
|
31923
|
+
this.currentMessage.loading = false;
|
|
31996
31924
|
}
|
|
31997
|
-
|
|
31998
|
-
|
|
31999
|
-
|
|
32000
|
-
id: Date.now() + Math.random(),
|
|
32001
|
-
text: result.thinkingSegment
|
|
32002
|
-
});
|
|
32003
|
-
}
|
|
32004
|
-
if (result.toolCall) {
|
|
32005
|
-
this.currentMessage.timeline.push({
|
|
32006
|
-
type: 'tool',
|
|
32007
|
-
id: result.toolCall.id,
|
|
32008
|
-
tool: result.toolCall
|
|
32009
|
-
});
|
|
31925
|
+
// 更新思考内容
|
|
31926
|
+
if (result.thinking) {
|
|
31927
|
+
this.currentMessage.thinking += result.thinking;
|
|
32010
31928
|
}
|
|
31929
|
+
|
|
31930
|
+
// 更新回复内容
|
|
31931
|
+
console.log('更新回复内容:', result.content);
|
|
32011
31932
|
if (result.content) {
|
|
32012
|
-
this.currentMessage.
|
|
32013
|
-
type: 'content',
|
|
32014
|
-
id: Date.now() + Math.random(),
|
|
32015
|
-
text: result.content
|
|
32016
|
-
});
|
|
31933
|
+
this.currentMessage.content += result.content;
|
|
32017
31934
|
}
|
|
32018
31935
|
|
|
32019
31936
|
// 更新状态
|
|
32020
|
-
|
|
31937
|
+
if (result.status === 'thinking') {
|
|
31938
|
+
this.avaterStatus = 'thinking';
|
|
31939
|
+
} else {
|
|
31940
|
+
this.avaterStatus = 'output';
|
|
31941
|
+
}
|
|
32021
31942
|
|
|
32022
31943
|
// 触发视图更新
|
|
32023
31944
|
this.$forceUpdate();
|