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.common.js
CHANGED
|
@@ -29167,8 +29167,8 @@ var UserMessage_component = normalizeComponent(
|
|
|
29167
29167
|
)
|
|
29168
29168
|
|
|
29169
29169
|
/* harmony default export */ var UserMessage = (UserMessage_component.exports);
|
|
29170
|
-
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.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=
|
|
29171
|
-
var
|
|
29170
|
+
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.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
|
|
29171
|
+
var AiMessagevue_type_template_id_7f2cec94_scoped_true_render = function render() {
|
|
29172
29172
|
var _vm = this,
|
|
29173
29173
|
_c = _vm._self._c;
|
|
29174
29174
|
return _c('div', {
|
|
@@ -29183,39 +29183,28 @@ var AiMessagevue_type_template_id_0d2964f2_scoped_true_render = function render(
|
|
|
29183
29183
|
staticClass: "dot"
|
|
29184
29184
|
}), _c('div', {
|
|
29185
29185
|
staticClass: "dot"
|
|
29186
|
-
})]) : _vm._e(), _vm.
|
|
29187
|
-
|
|
29188
|
-
|
|
29189
|
-
|
|
29190
|
-
|
|
29191
|
-
staticClass: "ai-thinking",
|
|
29192
|
-
on: {
|
|
29193
|
-
"click": function ($event) {
|
|
29194
|
-
return _vm.$emit('thinking-toggle');
|
|
29195
|
-
}
|
|
29196
|
-
}
|
|
29197
|
-
}, [_c('div', {
|
|
29198
|
-
staticClass: "ai-thinking-time"
|
|
29199
|
-
}, [_vm._v(" " + _vm._s(_vm.message.time ? `思考用时 ${_vm.message.time} 秒` : '思考中...') + " ")]), _vm.thinkingExpanded ? _c('div', {
|
|
29200
|
-
staticClass: "ai-thinking-content"
|
|
29201
|
-
}, [_vm._v(" " + _vm._s(item.text) + " ")]) : _vm._e()]) : item.type === 'tool' ? _c('div', {
|
|
29202
|
-
staticClass: "ai-tool"
|
|
29203
|
-
}, [_c('div', {
|
|
29204
|
-
staticClass: "ai-tool-header"
|
|
29205
|
-
}, [_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', {
|
|
29206
|
-
staticClass: "ai-content markdown-body",
|
|
29207
|
-
domProps: {
|
|
29208
|
-
"innerHTML": _vm._s(_vm.renderMarkdown(item.text))
|
|
29209
|
-
},
|
|
29210
|
-
on: {
|
|
29211
|
-
"click": _vm.handleLinkClick
|
|
29186
|
+
})]) : _vm._e(), _vm.message.thinking ? _c('div', {
|
|
29187
|
+
staticClass: "ai-thinking",
|
|
29188
|
+
on: {
|
|
29189
|
+
"click": function ($event) {
|
|
29190
|
+
return _vm.$emit('thinking-toggle');
|
|
29212
29191
|
}
|
|
29213
|
-
}
|
|
29214
|
-
|
|
29215
|
-
|
|
29216
|
-
}
|
|
29192
|
+
}
|
|
29193
|
+
}, [_c('div', {
|
|
29194
|
+
staticClass: "ai-thinking-time"
|
|
29195
|
+
}, [_vm._v(_vm._s(_vm.message.time ? `思考用时${_vm.message.time}秒` : '思考中...'))]), _vm.thinkingExpanded ? _c('div', {
|
|
29196
|
+
staticClass: "ai-thinking-content"
|
|
29197
|
+
}, [_vm._v(_vm._s(_vm.message.thinking))]) : _vm._e()]) : _vm._e(), _c('div', {
|
|
29198
|
+
staticClass: "ai-content markdown-body",
|
|
29199
|
+
domProps: {
|
|
29200
|
+
"innerHTML": _vm._s(_vm.renderedContent)
|
|
29201
|
+
},
|
|
29202
|
+
on: {
|
|
29203
|
+
"click": _vm.handleLinkClick
|
|
29204
|
+
}
|
|
29205
|
+
})])]);
|
|
29217
29206
|
};
|
|
29218
|
-
var
|
|
29207
|
+
var AiMessagevue_type_template_id_7f2cec94_scoped_true_staticRenderFns = [];
|
|
29219
29208
|
|
|
29220
29209
|
// EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.delete.js
|
|
29221
29210
|
var web_url_search_params_delete = __webpack_require__(4603);
|
|
@@ -31001,6 +30990,8 @@ var lib = __webpack_require__(2750);
|
|
|
31001
30990
|
|
|
31002
30991
|
|
|
31003
30992
|
|
|
30993
|
+
|
|
30994
|
+
// 创建自定义渲染器
|
|
31004
30995
|
const renderer = new d.Renderer();
|
|
31005
30996
|
|
|
31006
30997
|
// 自定义链接渲染
|
|
@@ -31020,8 +31011,8 @@ renderer.link = function ({
|
|
|
31020
31011
|
}
|
|
31021
31012
|
};
|
|
31022
31013
|
d.setOptions({
|
|
31023
|
-
renderer,
|
|
31024
|
-
highlight(code, lang) {
|
|
31014
|
+
renderer: renderer,
|
|
31015
|
+
highlight: function (code, lang) {
|
|
31025
31016
|
if (lang && es.getLanguage(lang)) {
|
|
31026
31017
|
return es.highlight(code, {
|
|
31027
31018
|
language: lang
|
|
@@ -31044,34 +31035,19 @@ d.setOptions({
|
|
|
31044
31035
|
thinkingExpanded() {
|
|
31045
31036
|
return this.message.thinkingExpanded !== false;
|
|
31046
31037
|
},
|
|
31038
|
+
renderedContent() {
|
|
31039
|
+
return d.parse(this.message.content || '');
|
|
31040
|
+
},
|
|
31047
31041
|
isLoading() {
|
|
31048
31042
|
return this.message.loading === true;
|
|
31049
|
-
}
|
|
31050
|
-
|
|
31051
|
-
|
|
31052
|
-
|
|
31053
|
-
|
|
31054
|
-
if (item.type === 'content') {
|
|
31055
|
-
if (last && last.type === 'content') {
|
|
31056
|
-
last.text += item.text;
|
|
31057
|
-
} else {
|
|
31058
|
-
last = {
|
|
31059
|
-
...item
|
|
31060
|
-
};
|
|
31061
|
-
result.push(last);
|
|
31062
|
-
}
|
|
31063
|
-
} else {
|
|
31064
|
-
last = null;
|
|
31065
|
-
result.push(item);
|
|
31066
|
-
}
|
|
31067
|
-
}
|
|
31068
|
-
return result;
|
|
31043
|
+
}
|
|
31044
|
+
},
|
|
31045
|
+
watch: {
|
|
31046
|
+
thinkStatus(newVal, oldVal) {
|
|
31047
|
+
console.log('thinkStatus 变化:', newVal, oldVal);
|
|
31069
31048
|
}
|
|
31070
31049
|
},
|
|
31071
31050
|
methods: {
|
|
31072
|
-
renderMarkdown(text) {
|
|
31073
|
-
return d.parse(text || '');
|
|
31074
|
-
},
|
|
31075
31051
|
handleLinkClick(event) {
|
|
31076
31052
|
const link = event.target.closest('a');
|
|
31077
31053
|
if (!link) return;
|
|
@@ -31101,10 +31077,10 @@ d.setOptions({
|
|
|
31101
31077
|
});
|
|
31102
31078
|
;// ./components/AiMessage.vue?vue&type=script&lang=js
|
|
31103
31079
|
/* harmony default export */ var components_AiMessagevue_type_script_lang_js = (AiMessagevue_type_script_lang_js);
|
|
31104
|
-
;// ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/AiMessage.vue?vue&type=style&index=0&id=
|
|
31080
|
+
;// ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.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
|
|
31105
31081
|
// extracted by mini-css-extract-plugin
|
|
31106
31082
|
|
|
31107
|
-
;// ./components/AiMessage.vue?vue&type=style&index=0&id=
|
|
31083
|
+
;// ./components/AiMessage.vue?vue&type=style&index=0&id=7f2cec94&prod&scoped=true&lang=css
|
|
31108
31084
|
|
|
31109
31085
|
;// ./components/AiMessage.vue
|
|
31110
31086
|
|
|
@@ -31117,11 +31093,11 @@ d.setOptions({
|
|
|
31117
31093
|
|
|
31118
31094
|
var AiMessage_component = normalizeComponent(
|
|
31119
31095
|
components_AiMessagevue_type_script_lang_js,
|
|
31120
|
-
|
|
31121
|
-
|
|
31096
|
+
AiMessagevue_type_template_id_7f2cec94_scoped_true_render,
|
|
31097
|
+
AiMessagevue_type_template_id_7f2cec94_scoped_true_staticRenderFns,
|
|
31122
31098
|
false,
|
|
31123
31099
|
null,
|
|
31124
|
-
"
|
|
31100
|
+
"7f2cec94",
|
|
31125
31101
|
null
|
|
31126
31102
|
|
|
31127
31103
|
)
|
|
@@ -31642,138 +31618,99 @@ const TIME_JUMP_POINTS_URL = '/minio/lingxiaoai/timeJumpPoints.json'; // 语音u
|
|
|
31642
31618
|
});
|
|
31643
31619
|
;// ./components/utils/StreamParser.js
|
|
31644
31620
|
|
|
31645
|
-
// utils/StreamParser.js
|
|
31646
31621
|
class StreamParser {
|
|
31647
31622
|
constructor(options = {}) {
|
|
31648
31623
|
this.options = {
|
|
31649
31624
|
updateInterval: 16,
|
|
31625
|
+
// 每16ms刷新一次(约60fps)
|
|
31650
31626
|
debug: false,
|
|
31651
31627
|
...options
|
|
31652
31628
|
};
|
|
31653
31629
|
this.reset();
|
|
31654
31630
|
}
|
|
31631
|
+
|
|
31632
|
+
// 重置解析器状态
|
|
31655
31633
|
reset() {
|
|
31634
|
+
this.buffer = '';
|
|
31656
31635
|
this.contentBuffer = [];
|
|
31657
31636
|
this.thinkingBuffer = [];
|
|
31658
|
-
this.completedThinkingSegments = [];
|
|
31659
|
-
this.completedToolCalls = [];
|
|
31660
|
-
this.currentToolCall = null;
|
|
31661
|
-
this.protocolErrorBuffer = []; // ✅ 新增
|
|
31662
|
-
|
|
31663
31637
|
this.inTag = false;
|
|
31664
31638
|
this.tagBuffer = '';
|
|
31665
31639
|
this.updateTimer = null;
|
|
31666
|
-
this.status = 'output'; // thinking | output
|
|
31640
|
+
this.status = 'output'; // thinking | output
|
|
31667
31641
|
}
|
|
31642
|
+
|
|
31643
|
+
// 处理接收到的流数据块
|
|
31668
31644
|
processChunk(chunk, callback) {
|
|
31669
31645
|
if (!chunk) return;
|
|
31670
31646
|
this.parseContent(chunk, callback);
|
|
31671
31647
|
}
|
|
31648
|
+
|
|
31649
|
+
// 核心内容解析,支持 <think> 标签
|
|
31672
31650
|
parseContent(content, callback) {
|
|
31673
31651
|
let i = 0;
|
|
31674
31652
|
while (i < content.length) {
|
|
31675
31653
|
if (this.inTag) {
|
|
31676
|
-
const
|
|
31677
|
-
if (
|
|
31678
|
-
this.tagBuffer += content.
|
|
31654
|
+
const endIndex = content.indexOf('>', i);
|
|
31655
|
+
if (endIndex !== -1) {
|
|
31656
|
+
this.tagBuffer += content.substring(i, endIndex + 1);
|
|
31679
31657
|
this.handleTag(this.tagBuffer);
|
|
31680
31658
|
this.tagBuffer = '';
|
|
31681
31659
|
this.inTag = false;
|
|
31682
|
-
i =
|
|
31660
|
+
i = endIndex + 1;
|
|
31683
31661
|
} else {
|
|
31684
|
-
|
|
31662
|
+
// 标签未闭合,超过50字符强制输出,防止阻塞
|
|
31663
|
+
this.tagBuffer += content.substring(i);
|
|
31664
|
+
if (this.tagBuffer.length > 50) {
|
|
31665
|
+
this.appendText(this.tagBuffer);
|
|
31666
|
+
this.tagBuffer = '';
|
|
31667
|
+
this.inTag = false;
|
|
31668
|
+
}
|
|
31685
31669
|
break;
|
|
31686
31670
|
}
|
|
31687
31671
|
} else {
|
|
31688
|
-
const
|
|
31689
|
-
if (
|
|
31690
|
-
this.appendText(content.
|
|
31691
|
-
|
|
31692
|
-
|
|
31693
|
-
|
|
31694
|
-
|
|
31695
|
-
|
|
31696
|
-
|
|
31697
|
-
|
|
31698
|
-
|
|
31699
|
-
|
|
31672
|
+
const startIndex = content.indexOf('<', i);
|
|
31673
|
+
if (startIndex !== -1) {
|
|
31674
|
+
if (startIndex > i) this.appendText(content.substring(i, startIndex));
|
|
31675
|
+
const endIndex = content.indexOf('>', startIndex);
|
|
31676
|
+
if (endIndex !== -1) {
|
|
31677
|
+
const tag = content.substring(startIndex, endIndex + 1);
|
|
31678
|
+
this.handleTag(tag);
|
|
31679
|
+
i = endIndex + 1;
|
|
31680
|
+
} else {
|
|
31681
|
+
const nextChar = content[startIndex + 1];
|
|
31682
|
+
if (!/[a-zA-Z/]/.test(nextChar)) {
|
|
31683
|
+
// 很可能不是标签,直接当文本输出
|
|
31684
|
+
this.appendText('<');
|
|
31685
|
+
i = startIndex + 1;
|
|
31686
|
+
} else {
|
|
31687
|
+
this.inTag = true;
|
|
31688
|
+
this.tagBuffer = content.substring(startIndex);
|
|
31689
|
+
break;
|
|
31690
|
+
}
|
|
31691
|
+
}
|
|
31692
|
+
} else {
|
|
31693
|
+
this.appendText(content.substring(i));
|
|
31700
31694
|
break;
|
|
31701
31695
|
}
|
|
31702
|
-
const tag = content.slice(start, end + 1);
|
|
31703
|
-
this.handleTag(tag);
|
|
31704
|
-
i = end + 1;
|
|
31705
31696
|
}
|
|
31706
31697
|
}
|
|
31707
31698
|
this.scheduleUpdate(callback);
|
|
31708
31699
|
}
|
|
31700
|
+
|
|
31701
|
+
// 处理标签
|
|
31709
31702
|
handleTag(tag) {
|
|
31710
31703
|
const t = tag.toLowerCase();
|
|
31711
|
-
|
|
31712
|
-
// ---------- think ----------
|
|
31713
|
-
if (t === '<think>') {
|
|
31714
|
-
this.status = 'thinking';
|
|
31715
|
-
return;
|
|
31716
|
-
}
|
|
31717
|
-
if (t === '</think>') {
|
|
31718
|
-
if (this.thinkingBuffer.length) {
|
|
31719
|
-
this.completedThinkingSegments.push(this.thinkingBuffer.join(''));
|
|
31720
|
-
this.thinkingBuffer = [];
|
|
31721
|
-
}
|
|
31722
|
-
this.status = 'output';
|
|
31723
|
-
return;
|
|
31724
|
-
}
|
|
31725
|
-
|
|
31726
|
-
// ---------- tool_call ----------
|
|
31727
|
-
if (t.startsWith('<tool_call')) {
|
|
31728
|
-
const nameMatch = tag.match(/name\s*=\s*["'](.+?)["']/);
|
|
31729
|
-
this.currentToolCall = {
|
|
31730
|
-
id: `${Date.now()}-${Math.random()}`,
|
|
31731
|
-
name: nameMatch ? nameMatch[1] : 'unknown',
|
|
31732
|
-
args: '',
|
|
31733
|
-
result: '',
|
|
31734
|
-
status: 'calling'
|
|
31735
|
-
};
|
|
31736
|
-
this.status = 'tool_call';
|
|
31737
|
-
return;
|
|
31738
|
-
}
|
|
31739
|
-
if (t === '</tool_call>') {
|
|
31740
|
-
this.status = 'output';
|
|
31741
|
-
return;
|
|
31742
|
-
}
|
|
31743
|
-
|
|
31744
|
-
// ---------- tool_result ----------
|
|
31745
|
-
if (t === '<tool_result>') {
|
|
31746
|
-
this.status = 'tool_result';
|
|
31747
|
-
return;
|
|
31748
|
-
}
|
|
31749
|
-
if (t === '</tool_result>') {
|
|
31750
|
-
if (this.currentToolCall) {
|
|
31751
|
-
this.currentToolCall.status = 'done';
|
|
31752
|
-
this.completedToolCalls.push(this.currentToolCall);
|
|
31753
|
-
this.currentToolCall = null;
|
|
31754
|
-
}
|
|
31755
|
-
this.status = 'output';
|
|
31756
|
-
return;
|
|
31757
|
-
}
|
|
31758
|
-
|
|
31759
|
-
// ---------- ❌ 协议错误 ----------
|
|
31760
|
-
if (t.startsWith('<') && t.endsWith('>')) {
|
|
31761
|
-
this.protocolErrorBuffer.push(tag);
|
|
31762
|
-
this.status = 'output';
|
|
31763
|
-
}
|
|
31704
|
+
if (t === '<think>') this.status = 'thinking';else if (t === '</think>') this.status = 'output';
|
|
31764
31705
|
}
|
|
31706
|
+
|
|
31707
|
+
// 添加文本到缓冲区
|
|
31765
31708
|
appendText(text) {
|
|
31766
31709
|
if (!text) return;
|
|
31767
|
-
if (this.status === 'thinking')
|
|
31768
|
-
this.thinkingBuffer.push(text);
|
|
31769
|
-
} else if (this.status === 'tool_call') {
|
|
31770
|
-
this.currentToolCall && (this.currentToolCall.args += text);
|
|
31771
|
-
} else if (this.status === 'tool_result') {
|
|
31772
|
-
this.currentToolCall && (this.currentToolCall.result += text);
|
|
31773
|
-
} else {
|
|
31774
|
-
this.contentBuffer.push(text);
|
|
31775
|
-
}
|
|
31710
|
+
if (this.status === 'thinking') this.thinkingBuffer.push(text);else this.contentBuffer.push(text);
|
|
31776
31711
|
}
|
|
31712
|
+
|
|
31713
|
+
// 防抖刷新
|
|
31777
31714
|
scheduleUpdate(callback) {
|
|
31778
31715
|
if (this.updateTimer) return;
|
|
31779
31716
|
this.updateTimer = setTimeout(() => {
|
|
@@ -31781,39 +31718,32 @@ class StreamParser {
|
|
|
31781
31718
|
this.updateTimer = null;
|
|
31782
31719
|
}, this.options.updateInterval);
|
|
31783
31720
|
}
|
|
31721
|
+
|
|
31722
|
+
// 刷新缓冲区
|
|
31784
31723
|
flush(callback) {
|
|
31785
31724
|
if (!callback) return;
|
|
31786
31725
|
const result = {
|
|
31787
|
-
|
|
31788
|
-
|
|
31789
|
-
content: null,
|
|
31790
|
-
protocolError: null,
|
|
31726
|
+
thinking: this.thinkingBuffer.length ? this.thinkingBuffer.join('') : null,
|
|
31727
|
+
content: this.contentBuffer.length ? this.contentBuffer.join('') : null,
|
|
31791
31728
|
status: this.status
|
|
31792
31729
|
};
|
|
31793
|
-
|
|
31794
|
-
|
|
31795
|
-
this.protocolErrorBuffer = [];
|
|
31796
|
-
}
|
|
31797
|
-
if (this.completedThinkingSegments.length) {
|
|
31798
|
-
result.thinkingSegment = this.completedThinkingSegments.shift();
|
|
31799
|
-
}
|
|
31800
|
-
if (this.completedToolCalls.length) {
|
|
31801
|
-
result.toolCall = this.completedToolCalls.shift();
|
|
31802
|
-
}
|
|
31803
|
-
if (this.contentBuffer.length) {
|
|
31804
|
-
result.content = this.contentBuffer.join('');
|
|
31805
|
-
this.contentBuffer = [];
|
|
31806
|
-
}
|
|
31730
|
+
this.thinkingBuffer = [];
|
|
31731
|
+
this.contentBuffer = [];
|
|
31807
31732
|
callback(result);
|
|
31808
31733
|
}
|
|
31734
|
+
|
|
31735
|
+
// 完成解析
|
|
31809
31736
|
finish(callback) {
|
|
31810
|
-
if (this.
|
|
31811
|
-
this.
|
|
31812
|
-
this.
|
|
31737
|
+
if (this.inTag && this.tagBuffer) {
|
|
31738
|
+
this.appendText(this.tagBuffer);
|
|
31739
|
+
this.tagBuffer = '';
|
|
31740
|
+
this.inTag = false;
|
|
31813
31741
|
}
|
|
31814
31742
|
this.flush(callback);
|
|
31815
31743
|
if (this.updateTimer) clearTimeout(this.updateTimer);
|
|
31816
31744
|
}
|
|
31745
|
+
|
|
31746
|
+
// 销毁解析器
|
|
31817
31747
|
destroy() {
|
|
31818
31748
|
if (this.updateTimer) clearTimeout(this.updateTimer);
|
|
31819
31749
|
this.reset();
|
|
@@ -31863,7 +31793,9 @@ const getCookie = cname => {
|
|
|
31863
31793
|
type: 'ai',
|
|
31864
31794
|
sender: 'AI',
|
|
31865
31795
|
time: '',
|
|
31866
|
-
|
|
31796
|
+
thinking: '',
|
|
31797
|
+
charts: [],
|
|
31798
|
+
content: '',
|
|
31867
31799
|
loading: true,
|
|
31868
31800
|
thinkingExpanded: true
|
|
31869
31801
|
};
|
|
@@ -31896,7 +31828,7 @@ const getCookie = cname => {
|
|
|
31896
31828
|
const controller = new AbortController();
|
|
31897
31829
|
try {
|
|
31898
31830
|
const startTime = Date.now();
|
|
31899
|
-
const token = getCookie('bonyear-access_token') || `
|
|
31831
|
+
const token = getCookie('bonyear-access_token') || `44e7f112-63f3-429d-908d-2c97ec380de2`;
|
|
31900
31832
|
const response = await fetch(API_URL, {
|
|
31901
31833
|
method: 'POST',
|
|
31902
31834
|
signal: controller.signal,
|
|
@@ -31976,38 +31908,27 @@ const getCookie = cname => {
|
|
|
31976
31908
|
*/
|
|
31977
31909
|
handleStreamUpdate(result) {
|
|
31978
31910
|
if (!this.currentMessage) return;
|
|
31979
|
-
|
|
31980
|
-
if (
|
|
31981
|
-
this.currentMessage.
|
|
31982
|
-
type: 'protocol_error',
|
|
31983
|
-
id: Date.now() + Math.random(),
|
|
31984
|
-
raw: result.protocolError
|
|
31985
|
-
});
|
|
31911
|
+
console.log('收到更新:', result);
|
|
31912
|
+
if (this.currentMessage.loading) {
|
|
31913
|
+
this.currentMessage.loading = false;
|
|
31986
31914
|
}
|
|
31987
|
-
|
|
31988
|
-
|
|
31989
|
-
|
|
31990
|
-
id: Date.now() + Math.random(),
|
|
31991
|
-
text: result.thinkingSegment
|
|
31992
|
-
});
|
|
31993
|
-
}
|
|
31994
|
-
if (result.toolCall) {
|
|
31995
|
-
this.currentMessage.timeline.push({
|
|
31996
|
-
type: 'tool',
|
|
31997
|
-
id: result.toolCall.id,
|
|
31998
|
-
tool: result.toolCall
|
|
31999
|
-
});
|
|
31915
|
+
// 更新思考内容
|
|
31916
|
+
if (result.thinking) {
|
|
31917
|
+
this.currentMessage.thinking += result.thinking;
|
|
32000
31918
|
}
|
|
31919
|
+
|
|
31920
|
+
// 更新回复内容
|
|
31921
|
+
console.log('更新回复内容:', result.content);
|
|
32001
31922
|
if (result.content) {
|
|
32002
|
-
this.currentMessage.
|
|
32003
|
-
type: 'content',
|
|
32004
|
-
id: Date.now() + Math.random(),
|
|
32005
|
-
text: result.content
|
|
32006
|
-
});
|
|
31923
|
+
this.currentMessage.content += result.content;
|
|
32007
31924
|
}
|
|
32008
31925
|
|
|
32009
31926
|
// 更新状态
|
|
32010
|
-
|
|
31927
|
+
if (result.status === 'thinking') {
|
|
31928
|
+
this.avaterStatus = 'thinking';
|
|
31929
|
+
} else {
|
|
31930
|
+
this.avaterStatus = 'output';
|
|
31931
|
+
}
|
|
32011
31932
|
|
|
32012
31933
|
// 触发视图更新
|
|
32013
31934
|
this.$forceUpdate();
|