byt-lingxiao-ai 0.2.4 → 0.2.5

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/index.css CHANGED
@@ -1 +1 @@
1
- .hidden-audio[data-v-43521054]{position:absolute;left:-9999px;opacity:0;pointer-events:none}.chat-overlay[data-v-43521054]{position:fixed;top:0;left:0;width:100%;height:100%;background:transparent;z-index:10000}[data-v-43521054] .el-textarea__inner{border:none!important;padding:0 5px;font-family:PingFang SC!important}[data-v-43521054] .el-textarea__inner::-webkit-scrollbar{width:6px;height:6px}[data-v-43521054] .el-textarea__inner::-webkit-scrollbar-thumb{background:rgba(0,0,0,.1);border-radius:3px}[data-v-43521054] .el-textarea__inner::-webkit-scrollbar-track{background:transparent}.scrollbar-hide[data-v-43521054]::-webkit-scrollbar{display:none}.scrollbar-hide[data-v-43521054]{-ms-overflow-style:none;scrollbar-width:none}.chat[data-v-43521054]{position:fixed;bottom:20px;right:10px;z-index:10001}.chat-ai[data-v-43521054]{display:flex;width:38px;padding:2px 2px 9px 2px;flex-direction:column;align-items:center;gap:6px;border-radius:40px;background:linear-gradient(180deg,#3e5beb,#5ca5f9);box-shadow:0 2px 11.6px 0 rgba(0,0,0,.1);cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.chat-robot[data-v-43521054]{width:150px;height:200px}.chat-robot.entering[data-v-43521054]{background-image:url(img/entering.42f05909.png);background-size:cover}.chat-robot.waiting[data-v-43521054]{background-image:url(img/waiting.ac21d76e.png);background-size:cover}.chat-robot.speaking[data-v-43521054]{background-image:url(img/speaking.3ce8b666.png);background-size:cover}.chat-ai-avater[data-v-43521054]{border-radius:67px;border:1px solid #0f66e4;background:#124087;display:flex;width:34px;height:33px;padding:2px 2px 1px 2px;justify-content:center;align-items:center;background-size:cover;background-position:50%;background-image:url(img/normal.13f08ecb.png)}.chat-ai-text[data-v-43521054]{color:#fff;font-family:PingFang SC;font-size:16px;font-style:normal;font-weight:500;line-height:20px;align-self:stretch;display:flex;align-items:center;width:20px;margin:0 auto;text-align:center}.chat-window-message-user[data-v-43521054]{display:flex;justify-content:flex-end}.user-message[data-v-43521054]{max-width:80%;display:flex;padding:8px 12px;justify-content:center;align-items:center;gap:10px;border-radius:12px;background:#e3ecff}.chat-window-bar[data-v-43521054]{display:flex;justify-content:flex-end;padding:8px}.chat-window-message-ai[data-v-43521054]{display:flex;gap:12px;align-items:flex-start}.ai-message[data-v-43521054]{max-width:80%;border-radius:12px;background:#f6f8fc;padding:8px 12px}.chat-window[data-v-43521054]{width:480px;height:740px;border-radius:14px;background:#fff;box-shadow:0 2px 20px 0 rgba(0,0,0,.16);position:absolute;bottom:20px;right:60px;overflow:hidden;display:flex;flex-direction:column}.chat-window-header[data-v-43521054]{display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid #eaeaea;background:#fff;padding:16px;flex-shrink:0}.chat-window-content[data-v-43521054]{flex:1;padding:16px;overflow-y:auto;display:flex;flex-direction:column;gap:8px}.chat-window-header-title[data-v-43521054]{color:#29414e;font-size:18px;font-weight:900}.chat-window-header-close[data-v-43521054]{width:24px;height:24px;overflow:hidden;cursor:pointer}.chat-window-footer[data-v-43521054]{padding:16px}.chat-window-textarea[data-v-43521054]{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-43521054]{padding:10px 12px;font-size:16px;font-family:PingFang SC}.chat-window-send[data-v-43521054]{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}
1
+ .hidden-audio[data-v-62955cf4]{position:absolute;left:-9999px;opacity:0;pointer-events:none}.chat-overlay[data-v-62955cf4]{position:fixed;top:0;left:0;width:100%;height:100%;background:transparent;z-index:10000}[data-v-62955cf4] .el-textarea__inner{border:none!important;padding:0 5px;font-family:PingFang SC!important}[data-v-62955cf4] .el-textarea__inner::-webkit-scrollbar{width:6px;height:6px}[data-v-62955cf4] .el-textarea__inner::-webkit-scrollbar-thumb{background:rgba(0,0,0,.1);border-radius:3px}[data-v-62955cf4] .el-textarea__inner::-webkit-scrollbar-track{background:transparent}.scrollbar-hide[data-v-62955cf4]::-webkit-scrollbar{display:none}.scrollbar-hide[data-v-62955cf4]{-ms-overflow-style:none;scrollbar-width:none}.chat[data-v-62955cf4]{position:fixed;bottom:20px;right:10px;z-index:10001}.chat-ai[data-v-62955cf4]{display:flex;width:38px;padding:2px 2px 9px 2px;flex-direction:column;align-items:center;gap:6px;border-radius:40px;background:linear-gradient(180deg,#3e5beb,#5ca5f9);box-shadow:0 2px 11.6px 0 rgba(0,0,0,.1);cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.chat-robot[data-v-62955cf4]{width:150px;height:200px}.chat-robot.entering[data-v-62955cf4]{background-image:url(img/entering.42f05909.png);background-size:cover}.chat-robot.waiting[data-v-62955cf4]{background-image:url(img/waiting.ac21d76e.png);background-size:cover}.chat-robot.speaking[data-v-62955cf4]{background-image:url(img/speaking.3ce8b666.png);background-size:cover}.chat-ai-avater[data-v-62955cf4]{border-radius:67px;border:1px solid #0f66e4;background:#124087;display:flex;width:34px;height:33px;padding:2px 2px 1px 2px;justify-content:center;align-items:center;background-size:cover;background-position:50%}.chat-ai-avater.normal[data-v-62955cf4]{background-image:url(img/normal.13f08ecb.png)}.chat-ai-avater.thinking[data-v-62955cf4]{background-image:url(img/thinking.05f29a84.png)}.chat-ai-avater.output[data-v-62955cf4]{background-image:url(img/output.85c6bd8b.png)}.chat-ai-text[data-v-62955cf4]{color:#fff;font-family:PingFang SC;font-size:16px;font-style:normal;font-weight:500;line-height:20px;align-self:stretch;display:flex;align-items:center;width:20px;margin:0 auto;text-align:center}.chat-window-message-user[data-v-62955cf4]{display:flex;justify-content:flex-end}.user-message[data-v-62955cf4]{max-width:80%;display:flex;padding:8px 12px;justify-content:center;align-items:center;gap:10px;border-radius:12px;background:#e3ecff}.chat-window-bar[data-v-62955cf4]{display:flex;justify-content:flex-end;padding:8px}.chat-window-message-ai[data-v-62955cf4]{display:flex;gap:12px;align-items:flex-start;max-width:100%;border-radius:12px;background:#f6f8fc;padding:8px 12px}.chat-window[data-v-62955cf4]{width:480px;height:740px;border-radius:14px;background:#fff;box-shadow:0 2px 20px 0 rgba(0,0,0,.16);position:absolute;bottom:20px;right:60px;overflow:hidden;display:flex;flex-direction:column}.chat-window-header[data-v-62955cf4]{display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid #eaeaea;background:#fff;padding:16px;flex-shrink:0}.chat-window-content[data-v-62955cf4]{flex:1;padding:16px;overflow-y:auto;display:flex;flex-direction:column;gap:8px}.chat-window-header-title[data-v-62955cf4]{color:#29414e;font-size:18px;font-weight:900;position:relative;padding-left:36px}.chat-window-header-title[data-v-62955cf4]:before{content:"";position:absolute;left:0;top:50%;transform:translateY(-50%);width:32px;height:32px;background-image:url(data:image/png;base64,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);background-size:cover}.chat-window-header-close[data-v-62955cf4]{width:24px;height:24px;overflow:hidden;cursor:pointer}.chat-window-footer[data-v-62955cf4]{padding:16px}.chat-window-textarea[data-v-62955cf4]{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-62955cf4]{padding:10px 12px;font-size:16px;font-family:PingFang SC}.chat-window-send[data-v-62955cf4]{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}.ai-thinking-time[data-v-62955cf4]{border-radius:9px;background:#ecedf4;color:#86909c;font-family:"Alibaba PuHuiTi 2.0";font-size:16px;font-style:normal;font-weight:500;padding:0 26px 0 26px;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-62955cf4]:before{left:6px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJ2SURBVHgBhVS/axRBFP7eGuEiJO7mDCYQ4dIIKTQnaBErjZ0EvIgWVndaWZ7WQs7C1uA/oJ6tYiIEBcFTLLxOz0rQwhMPo+Dm1iab6sb3dnazO7uby4NlZ97M++Z7Pwk50u8rGxaqA4VzBJRZVQqPOgroWhbWnXFq5tlSWvG3ryoW4REvbQyXLllopIEtg9k/tcpga2mw7Z1cwJIa4DHbrOQCyoFSqMvaZ4D2p/jS5y/mvvUhfoRtGi4Tic4odLMWummw2uoDM9MGK7isGx0FDhVMPcd7+YhD6wFDBlsBsoYbLb1+w4yePNfrjbfAt+/IiBCSZB4QdkSoRa6+fg8cnwUOjwGnT2qmO/wdHAGOTgJnTgBTk7Hroh8fC7YFroA/5Hpqjf2upF1tcmqqy8DqQ+120dZxvHWDgdrA4oLWG64rvBihuMYCkQs+x2hmikEcjldBrydsfSbAsi7a2ThyRuYlhlK46G2GMWppkIVTwO17zOQscPUicIH/V/h/5z5wbFo/9vSl9uhrHNOSlXR1P9n2zb08nGZJW54S/FJS6Xo64PNzwLNXOkmFgq7Hm9eYGeuWzmdLiqVjcWY6BouQ6c/N+C8u9X7psMhjvq/vZbxS+EFuX9W5bIJKl7KRmltaNNkKqHRAlKhI5G55LtZxb9dIilERxG2jf4WVlEn1sjbs/dZrKXAJhXwp6U7YNBu1XiUcCrsibN281vP2SAazk8kTZFl6kJv8QfJC+2MMlhwOUn+yT8aPbe9GY8yYhxzPBuX09TARIkWH6rtM0xfCySOgpeFQ8HjCXBfvkkra63Y4NC6FrVkO1V0pM37wHQZoOg55abv/kUb4+qgKrBoAAAAASUVORK5CYII=) no-repeat;background-size:cover}.ai-thinking-time[data-v-62955cf4]:after,.ai-thinking-time[data-v-62955cf4]:before{content:"";position:absolute;top:50%;transform:translateY(-50%);width:16px;height:16px}.ai-thinking-time[data-v-62955cf4]:after{right:6px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAB/SURBVHgB7ZAxDkBAEEVnBLUjuIm4gSNoFEqtaivKLRUKbiJO4ArOQWQsIiHsbiG6feX8/34xAIZ/YbzxGK98VceSBaUQXVwGF51ONYIymYQIRP3RwmCiOWRZOmoHrnKeJfF2K3jdykZQJ5/IRm4/ILCjN3ljv4nMAfuRGT6yAqDAQFdhjRBxAAAAAElFTkSuQmCC) no-repeat;background-size:cover}.ai-thinking-content[data-v-62955cf4]{color:#86909c;font-family:"Alibaba PuHuiTi 2.0";font-size:14px;font-style:normal;font-weight:400;line-height:24px;padding:8px 0 8px 12px}
package/dist/index.umd.js CHANGED
@@ -3756,7 +3756,7 @@ if (typeof window !== 'undefined') {
3756
3756
  var es_iterator_constructor = __webpack_require__(8111);
3757
3757
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.for-each.js
3758
3758
  var es_iterator_for_each = __webpack_require__(7588);
3759
- ;// ./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/ChatWindow.vue?vue&type=template&id=43521054&scoped=true
3759
+ ;// ./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/ChatWindow.vue?vue&type=template&id=62955cf4&scoped=true
3760
3760
  var render = function render() {
3761
3761
  var _vm = this,
3762
3762
  _c = _vm._self._c;
@@ -3782,10 +3782,10 @@ var render = function render() {
3782
3782
  "click": _vm.toggleWindow
3783
3783
  }
3784
3784
  }, [_c('div', {
3785
- staticClass: "chat-ai-avater"
3785
+ class: ['chat-ai-avater', _vm.avaterStatus]
3786
3786
  }), _c('div', {
3787
3787
  staticClass: "chat-ai-text"
3788
- }, [_vm._v("凌霄AI")])]), _c('div', {
3788
+ }, [_vm._v(_vm._s(_vm.avaterText))])]), _c('div', {
3789
3789
  directives: [{
3790
3790
  name: "show",
3791
3791
  rawName: "v-show",
@@ -3852,8 +3852,16 @@ var render = function render() {
3852
3852
  }, [_vm._v(_vm._s(message.content))])]) : _c('div', {
3853
3853
  staticClass: "chat-window-message-ai"
3854
3854
  }, [_c('div', {
3855
- staticClass: "ai-message"
3856
- }, [_vm._v(_vm._s(message.content))])])]);
3855
+ staticClass: "ai-render"
3856
+ }, [_c('div', {
3857
+ staticClass: "ai-thinking"
3858
+ }, [_c('div', {
3859
+ staticClass: "ai-thinking-time"
3860
+ }, [_vm._v("思考用时" + _vm._s(message.time) + "秒")]), _c('div', {
3861
+ staticClass: "ai-thinking-content"
3862
+ }, [_vm._v(_vm._s(message.thinking))])]), _c('div', {
3863
+ staticClass: "ai-content"
3864
+ }, [_vm._v(_vm._s(message.content))])])])]);
3857
3865
  }), 0), _c('div', {
3858
3866
  staticClass: "chat-window-footer"
3859
3867
  }, [_c('div', {
@@ -3961,6 +3969,8 @@ var es_typed_array_with = __webpack_require__(9577);
3961
3969
 
3962
3970
 
3963
3971
 
3972
+
3973
+
3964
3974
  const SAMPLE_RATE = 16000;
3965
3975
  const FRAME_SIZE = 512;
3966
3976
  /* harmony default export */ var ChatWindowvue_type_script_lang_js = ({
@@ -3990,19 +4000,12 @@ const FRAME_SIZE = 512;
3990
4000
  type: 'ai',
3991
4001
  sender: 'AI',
3992
4002
  time: '',
3993
- content: '欢迎来到凌霄大模型AI对话。'
3994
- }, {
3995
- id: 3,
3996
- type: 'ai',
3997
- sender: 'AI',
3998
- time: '',
3999
- content: '请输入您的问题。'
4000
- }, {
4001
- id: 4,
4002
- type: 'user',
4003
- sender: '用户',
4004
- time: '',
4005
- content: '你好,欢迎来到凌霄大模型AI对话。'
4003
+ thinking: '嗯,用户问的是回转窑的工业应用。首先,我需要回忆一下之前对话的内容。用户之前让我解释了水泥的制作流程,特别是提到了回转窑在高温煅烧熟料中的作用。',
4004
+ charts: [{
4005
+ title: '',
4006
+ options: {}
4007
+ }],
4008
+ content: '回转窑(Rotary Kiln)是一种长筒形旋转煅烧设备(类似倾斜安装的大管子),因其独特的旋转运动和高温耐火衬里设计,在多个工业领域都有广泛应用'
4006
4009
  }],
4007
4010
  // 消息列表
4008
4011
  isRecording: false,
@@ -4026,9 +4029,29 @@ const FRAME_SIZE = 512;
4026
4029
  // 音频处理节点
4027
4030
  robotStatus: 'leaving',
4028
4031
  // 机器人状态 waiting, speaking, leaving, entering
4032
+ avaterStatus: 'normal',
4033
+ // 头像状态 normal output thinking
4034
+ buffer: '',
4035
+ // 音频缓冲区
4036
+ currentMessage: null,
4037
+ // 当前消息
4038
+ inTag: false,
4039
+ // 是否在标签页
4040
+ tagBuilder: '',
4041
+ // 标签构建器
4029
4042
  audioBuffer: new Float32Array(0) // 音频缓冲区
4030
4043
  };
4031
4044
  },
4045
+ computed: {
4046
+ avaterText() {
4047
+ const textMap = {
4048
+ 'normal': '凌霄AI',
4049
+ 'thinking': '思考中',
4050
+ 'output': '语音中'
4051
+ };
4052
+ return textMap[this.avaterStatus];
4053
+ }
4054
+ },
4032
4055
  mounted() {
4033
4056
  this.initWebSocket();
4034
4057
 
@@ -4141,8 +4164,10 @@ const FRAME_SIZE = 512;
4141
4164
  } else if (data.code === 0) {
4142
4165
  if (data.data.type === 'detection') {
4143
4166
  console.log('检测到唤醒词...');
4167
+ this.avaterStatus = 'normal';
4144
4168
  } else if (data.data.type === 'Collecting') {
4145
4169
  console.log('状态: 采集中...');
4170
+ this.avaterStatus = 'thinking';
4146
4171
  } else if (data.data.type === 'command') {
4147
4172
  // 根据指令改变机器人的状态
4148
4173
  console.log('状态: 处理中...');
@@ -4180,6 +4205,32 @@ const FRAME_SIZE = 512;
4180
4205
  this.ws.close();
4181
4206
  }
4182
4207
  },
4208
+ createAiMessage() {
4209
+ const message = {
4210
+ id: this.messages.length + 1,
4211
+ type: 'ai',
4212
+ sender: 'AI',
4213
+ time: '',
4214
+ thinking: '',
4215
+ charts: [],
4216
+ content: ''
4217
+ };
4218
+ this.messages.push(message);
4219
+ this.currentMessage = message;
4220
+ return message;
4221
+ },
4222
+ createUserMessage(content) {
4223
+ const message = {
4224
+ id: this.messages.length + 1,
4225
+ type: 'user',
4226
+ sender: '用户',
4227
+ time: '',
4228
+ content
4229
+ };
4230
+ this.messages.push(message);
4231
+ this.inputMessage = '';
4232
+ return message;
4233
+ },
4183
4234
  async initAudio() {
4184
4235
  if (this.isRecording) return;
4185
4236
  try {
@@ -4222,20 +4273,19 @@ const FRAME_SIZE = 512;
4222
4273
  return;
4223
4274
  }
4224
4275
  const message = this.inputMessage.trim();
4276
+ // 初始化信息
4277
+ this.initState();
4225
4278
  // 发送消息
4226
- this.messages.push({
4227
- id: this.messages.length + 1,
4228
- type: 'user',
4229
- sender: '用户',
4230
- time: new Date().toLocaleTimeString(),
4231
- content: this.inputMessage
4232
- });
4233
- this.inputMessage = '';
4279
+ this.createUserMessage(message);
4280
+ // 创建AI消息
4281
+ this.createAiMessage();
4234
4282
  try {
4235
- const token = `Bearer 24ab99b4-4b59-42a0-84df-1d73a96e70cd`;
4283
+ const controller = new AbortController();
4284
+ const token = `Bearer e298f087-85bc-48c2-afb9-7c69ffc911aa`;
4236
4285
  const response = await fetch('/bytserver/api-model/chat/stream', {
4237
4286
  timeout: 30000,
4238
4287
  method: 'POST',
4288
+ signal: controller.signal,
4239
4289
  headers: {
4240
4290
  'Content-Type': 'application/json',
4241
4291
  'Authorization': token
@@ -4247,13 +4297,26 @@ const FRAME_SIZE = 512;
4247
4297
  if (!response.ok) {
4248
4298
  throw new Error(`${response.status}`);
4249
4299
  }
4250
- console.log('响应状态:', response.status);
4251
- // 解析响应流
4252
- this.parseResponseStream(response.body);
4300
+ const render = response.body.getReader();
4301
+ const decoder = new TextDecoder();
4302
+
4303
+ // eslint-disable-next-line no-constant-condition
4304
+ while (true) {
4305
+ const {
4306
+ done,
4307
+ value
4308
+ } = await render.read();
4309
+ if (done) break;
4310
+ const chunk = decoder.decode(value, {
4311
+ stream: true
4312
+ });
4313
+ this.processStreamChunk(chunk);
4314
+ }
4253
4315
  } catch (error) {
4254
4316
  console.error('发送消息失败:', error);
4255
4317
  }
4256
4318
  },
4319
+ initState() {},
4257
4320
  // 分析音频命令
4258
4321
  analyzeAudioCommand(command) {
4259
4322
  console.log('分析音频命令:', command);
@@ -4281,9 +4344,90 @@ const FRAME_SIZE = 512;
4281
4344
  this.stop();
4282
4345
  }
4283
4346
  },
4284
- // 解析响应流
4285
- parseResponseStream(body) {
4286
- console.log(body);
4347
+ processStreamChunk(chunk) {
4348
+ console.log('原始数据:', chunk);
4349
+ try {
4350
+ this.buffer += chunk;
4351
+
4352
+ // eslint-disable-next-line no-constant-condition
4353
+ while (true) {
4354
+ const eventEnd = this.buffer.indexOf('\n\n');
4355
+ if (eventEnd === -1) break;
4356
+ const eventData = this.buffer.slice(0, eventEnd);
4357
+ this.buffer = this.buffer.slice(eventEnd + 2);
4358
+ console.log('解析数据:', eventData);
4359
+ this.processEventData(eventData);
4360
+ }
4361
+ } catch (error) {
4362
+ console.error('流数据处理异常:', error);
4363
+ this.streaming = false;
4364
+ this.response = this.$t('3d.chat.dataFormatError');
4365
+ this.$forceUpdate();
4366
+ }
4367
+ },
4368
+ processEventData(data) {
4369
+ data.split('\n').forEach(line => {
4370
+ console.log('原始数据:', line);
4371
+ if (!line.startsWith('data:')) return;
4372
+ const jsonStr = line.replace(/^data:\s*/, '').trim();
4373
+ if (jsonStr === '[DONE]') return;
4374
+ try {
4375
+ const data = this.safeJsonParse(jsonStr);
4376
+ this.processContentDelta(data.choices[0].delta);
4377
+ } catch (e) {
4378
+ console.warn('JSON解析跳过:', e.message);
4379
+ }
4380
+ });
4381
+ },
4382
+ safeJsonParse(jsonStr) {
4383
+ try {
4384
+ return JSON.parse(jsonStr);
4385
+ } catch (error) {
4386
+ console.warn('JSON parse failed:', jsonStr);
4387
+ return null;
4388
+ }
4389
+ },
4390
+ processContentDelta(delta) {
4391
+ const content = delta.content || '';
4392
+ if (!content || !this.currentMessage) return;
4393
+ for (let i = 0; i < content.length; i++) {
4394
+ const char = content[i];
4395
+
4396
+ // 处理正在拼接的标签
4397
+ if (this.inTag) {
4398
+ this.tagBuilder += char;
4399
+ if (char === '>') {
4400
+ const tag = this.tagBuilder;
4401
+ if (tag === '<think>') {
4402
+ this.avaterStatus = 'thinking';
4403
+ } else if (tag === '</think>') {
4404
+ this.avaterStatus = 'output';
4405
+ } else {
4406
+ console.log('无效标签:', tag);
4407
+ }
4408
+
4409
+ // 重置
4410
+ this.inTag = false;
4411
+ this.tagBuilder = '';
4412
+ }
4413
+ continue;
4414
+ }
4415
+
4416
+ // 检测是否是标签开始
4417
+ if (char === '<') {
4418
+ this.inTag = true;
4419
+ this.tagBuilder = '<';
4420
+ continue;
4421
+ }
4422
+
4423
+ // 正常字符处理
4424
+ if (this.avaterStatus === 'thinking') {
4425
+ this.currentMessage.thinking += char;
4426
+ } else {
4427
+ this.currentMessage.content += char;
4428
+ }
4429
+ }
4430
+ this.$forceUpdate();
4287
4431
  },
4288
4432
  processAudio(event) {
4289
4433
  if (!this.isRecording) return;
@@ -4380,10 +4524,10 @@ const FRAME_SIZE = 512;
4380
4524
  });
4381
4525
  ;// ./components/ChatWindow.vue?vue&type=script&lang=js
4382
4526
  /* harmony default export */ var components_ChatWindowvue_type_script_lang_js = (ChatWindowvue_type_script_lang_js);
4383
- ;// ./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/ChatWindow.vue?vue&type=style&index=0&id=43521054&prod&scoped=true&lang=css
4527
+ ;// ./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/ChatWindow.vue?vue&type=style&index=0&id=62955cf4&prod&scoped=true&lang=css
4384
4528
  // extracted by mini-css-extract-plugin
4385
4529
 
4386
- ;// ./components/ChatWindow.vue?vue&type=style&index=0&id=43521054&prod&scoped=true&lang=css
4530
+ ;// ./components/ChatWindow.vue?vue&type=style&index=0&id=62955cf4&prod&scoped=true&lang=css
4387
4531
 
4388
4532
  ;// ./node_modules/@vue/vue-loader-v15/lib/runtime/componentNormalizer.js
4389
4533
  /* globals __VUE_SSR_CONTEXT__ */
@@ -4498,7 +4642,7 @@ var component = normalizeComponent(
4498
4642
  staticRenderFns,
4499
4643
  false,
4500
4644
  null,
4501
- "43521054",
4645
+ "62955cf4",
4502
4646
  null
4503
4647
 
4504
4648
  )