byt-lingxiao-ai 0.3.21 → 0.3.22
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 +129 -37
- package/components/mixins/messageMixin.js +28 -19
- package/components/utils/StreamParser.js +165 -87
- package/dist/index.common.js +445 -170
- package/dist/index.common.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.umd.js +402 -127
- 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
|
@@ -771,50 +771,19 @@ module.exports = shell;
|
|
|
771
771
|
/***/ }),
|
|
772
772
|
|
|
773
773
|
/***/ 655:
|
|
774
|
-
/***/ (function(module) {
|
|
774
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
775
775
|
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
776
|
+
"use strict";
|
|
777
|
+
|
|
778
|
+
var classof = __webpack_require__(6955);
|
|
779
|
+
|
|
780
|
+
var $String = String;
|
|
781
|
+
|
|
782
|
+
module.exports = function (argument) {
|
|
783
|
+
if (classof(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string');
|
|
784
|
+
return $String(argument);
|
|
785
|
+
};
|
|
782
786
|
|
|
783
|
-
/** @type LanguageFn */
|
|
784
|
-
function flix(hljs) {
|
|
785
|
-
const CHAR = {
|
|
786
|
-
className: 'string',
|
|
787
|
-
begin: /'(.|\\[xXuU][a-zA-Z0-9]+)'/
|
|
788
|
-
};
|
|
789
|
-
const STRING = {
|
|
790
|
-
className: 'string',
|
|
791
|
-
variants: [{
|
|
792
|
-
begin: '"',
|
|
793
|
-
end: '"'
|
|
794
|
-
}]
|
|
795
|
-
};
|
|
796
|
-
const NAME = {
|
|
797
|
-
className: 'title',
|
|
798
|
-
relevance: 0,
|
|
799
|
-
begin: /[^0-9\n\t "'(),.`{}\[\]:;][^\n\t "'(),.`{}\[\]:;]+|[^0-9\n\t "'(),.`{}\[\]:;=]/
|
|
800
|
-
};
|
|
801
|
-
const METHOD = {
|
|
802
|
-
className: 'function',
|
|
803
|
-
beginKeywords: 'def',
|
|
804
|
-
end: /[:={\[(\n;]/,
|
|
805
|
-
excludeEnd: true,
|
|
806
|
-
contains: [NAME]
|
|
807
|
-
};
|
|
808
|
-
return {
|
|
809
|
-
name: 'Flix',
|
|
810
|
-
keywords: {
|
|
811
|
-
keyword: ["case", "class", "def", "else", "enum", "if", "impl", "import", "in", "lat", "rel", "index", "let", "match", "namespace", "switch", "type", "yield", "with"],
|
|
812
|
-
literal: ["true", "false"]
|
|
813
|
-
},
|
|
814
|
-
contains: [hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, CHAR, STRING, METHOD, hljs.C_NUMBER_MODE]
|
|
815
|
-
};
|
|
816
|
-
}
|
|
817
|
-
module.exports = flix;
|
|
818
787
|
|
|
819
788
|
/***/ }),
|
|
820
789
|
|
|
@@ -6397,7 +6366,7 @@ hljs.registerLanguage('erlang-repl', __webpack_require__(5233));
|
|
|
6397
6366
|
hljs.registerLanguage('erlang', __webpack_require__(7755));
|
|
6398
6367
|
hljs.registerLanguage('excel', __webpack_require__(5905));
|
|
6399
6368
|
hljs.registerLanguage('fix', __webpack_require__(3041));
|
|
6400
|
-
hljs.registerLanguage('flix', __webpack_require__(
|
|
6369
|
+
hljs.registerLanguage('flix', __webpack_require__(3036));
|
|
6401
6370
|
hljs.registerLanguage('fortran', __webpack_require__(3792));
|
|
6402
6371
|
hljs.registerLanguage('fsharp', __webpack_require__(7846));
|
|
6403
6372
|
hljs.registerLanguage('gams', __webpack_require__(8092));
|
|
@@ -6627,6 +6596,21 @@ var POLYFILL = isForced.POLYFILL = 'P';
|
|
|
6627
6596
|
module.exports = isForced;
|
|
6628
6597
|
|
|
6629
6598
|
|
|
6599
|
+
/***/ }),
|
|
6600
|
+
|
|
6601
|
+
/***/ 2812:
|
|
6602
|
+
/***/ (function(module) {
|
|
6603
|
+
|
|
6604
|
+
"use strict";
|
|
6605
|
+
|
|
6606
|
+
var $TypeError = TypeError;
|
|
6607
|
+
|
|
6608
|
+
module.exports = function (passed, required) {
|
|
6609
|
+
if (passed < required) throw new $TypeError('Not enough arguments');
|
|
6610
|
+
return passed;
|
|
6611
|
+
};
|
|
6612
|
+
|
|
6613
|
+
|
|
6630
6614
|
/***/ }),
|
|
6631
6615
|
|
|
6632
6616
|
/***/ 2839:
|
|
@@ -7255,6 +7239,54 @@ module.exports = phpTemplate;
|
|
|
7255
7239
|
|
|
7256
7240
|
/***/ }),
|
|
7257
7241
|
|
|
7242
|
+
/***/ 3036:
|
|
7243
|
+
/***/ (function(module) {
|
|
7244
|
+
|
|
7245
|
+
/*
|
|
7246
|
+
Language: Flix
|
|
7247
|
+
Category: functional
|
|
7248
|
+
Author: Magnus Madsen <mmadsen@uwaterloo.ca>
|
|
7249
|
+
Website: https://flix.dev/
|
|
7250
|
+
*/
|
|
7251
|
+
|
|
7252
|
+
/** @type LanguageFn */
|
|
7253
|
+
function flix(hljs) {
|
|
7254
|
+
const CHAR = {
|
|
7255
|
+
className: 'string',
|
|
7256
|
+
begin: /'(.|\\[xXuU][a-zA-Z0-9]+)'/
|
|
7257
|
+
};
|
|
7258
|
+
const STRING = {
|
|
7259
|
+
className: 'string',
|
|
7260
|
+
variants: [{
|
|
7261
|
+
begin: '"',
|
|
7262
|
+
end: '"'
|
|
7263
|
+
}]
|
|
7264
|
+
};
|
|
7265
|
+
const NAME = {
|
|
7266
|
+
className: 'title',
|
|
7267
|
+
relevance: 0,
|
|
7268
|
+
begin: /[^0-9\n\t "'(),.`{}\[\]:;][^\n\t "'(),.`{}\[\]:;]+|[^0-9\n\t "'(),.`{}\[\]:;=]/
|
|
7269
|
+
};
|
|
7270
|
+
const METHOD = {
|
|
7271
|
+
className: 'function',
|
|
7272
|
+
beginKeywords: 'def',
|
|
7273
|
+
end: /[:={\[(\n;]/,
|
|
7274
|
+
excludeEnd: true,
|
|
7275
|
+
contains: [NAME]
|
|
7276
|
+
};
|
|
7277
|
+
return {
|
|
7278
|
+
name: 'Flix',
|
|
7279
|
+
keywords: {
|
|
7280
|
+
keyword: ["case", "class", "def", "else", "enum", "if", "impl", "import", "in", "lat", "rel", "index", "let", "match", "namespace", "switch", "type", "yield", "with"],
|
|
7281
|
+
literal: ["true", "false"]
|
|
7282
|
+
},
|
|
7283
|
+
contains: [hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, CHAR, STRING, METHOD, hljs.C_NUMBER_MODE]
|
|
7284
|
+
};
|
|
7285
|
+
}
|
|
7286
|
+
module.exports = flix;
|
|
7287
|
+
|
|
7288
|
+
/***/ }),
|
|
7289
|
+
|
|
7258
7290
|
/***/ 3041:
|
|
7259
7291
|
/***/ (function(module) {
|
|
7260
7292
|
|
|
@@ -13016,6 +13048,63 @@ module.exports =
|
|
|
13016
13048
|
(function () { return this; })() || Function('return this')();
|
|
13017
13049
|
|
|
13018
13050
|
|
|
13051
|
+
/***/ }),
|
|
13052
|
+
|
|
13053
|
+
/***/ 4603:
|
|
13054
|
+
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
|
|
13055
|
+
|
|
13056
|
+
"use strict";
|
|
13057
|
+
|
|
13058
|
+
var defineBuiltIn = __webpack_require__(6840);
|
|
13059
|
+
var uncurryThis = __webpack_require__(9504);
|
|
13060
|
+
var toString = __webpack_require__(655);
|
|
13061
|
+
var validateArgumentsLength = __webpack_require__(2812);
|
|
13062
|
+
|
|
13063
|
+
var $URLSearchParams = URLSearchParams;
|
|
13064
|
+
var URLSearchParamsPrototype = $URLSearchParams.prototype;
|
|
13065
|
+
var append = uncurryThis(URLSearchParamsPrototype.append);
|
|
13066
|
+
var $delete = uncurryThis(URLSearchParamsPrototype['delete']);
|
|
13067
|
+
var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
|
|
13068
|
+
var push = uncurryThis([].push);
|
|
13069
|
+
var params = new $URLSearchParams('a=1&a=2&b=3');
|
|
13070
|
+
|
|
13071
|
+
params['delete']('a', 1);
|
|
13072
|
+
// `undefined` case is a Chromium 117 bug
|
|
13073
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=14222
|
|
13074
|
+
params['delete']('b', undefined);
|
|
13075
|
+
|
|
13076
|
+
if (params + '' !== 'a=2') {
|
|
13077
|
+
defineBuiltIn(URLSearchParamsPrototype, 'delete', function (name /* , value */) {
|
|
13078
|
+
var length = arguments.length;
|
|
13079
|
+
var $value = length < 2 ? undefined : arguments[1];
|
|
13080
|
+
if (length && $value === undefined) return $delete(this, name);
|
|
13081
|
+
var entries = [];
|
|
13082
|
+
forEach(this, function (v, k) { // also validates `this`
|
|
13083
|
+
push(entries, { key: k, value: v });
|
|
13084
|
+
});
|
|
13085
|
+
validateArgumentsLength(length, 1);
|
|
13086
|
+
var key = toString(name);
|
|
13087
|
+
var value = toString($value);
|
|
13088
|
+
var index = 0;
|
|
13089
|
+
var dindex = 0;
|
|
13090
|
+
var found = false;
|
|
13091
|
+
var entriesLength = entries.length;
|
|
13092
|
+
var entry;
|
|
13093
|
+
while (index < entriesLength) {
|
|
13094
|
+
entry = entries[index++];
|
|
13095
|
+
if (found || entry.key === key) {
|
|
13096
|
+
found = true;
|
|
13097
|
+
$delete(this, entry.key);
|
|
13098
|
+
} else dindex++;
|
|
13099
|
+
}
|
|
13100
|
+
while (dindex < entriesLength) {
|
|
13101
|
+
entry = entries[dindex++];
|
|
13102
|
+
if (!(entry.key === key && entry.value === value)) append(this, entry.key, entry.value);
|
|
13103
|
+
}
|
|
13104
|
+
}, { enumerable: true, unsafe: true });
|
|
13105
|
+
}
|
|
13106
|
+
|
|
13107
|
+
|
|
13019
13108
|
/***/ }),
|
|
13020
13109
|
|
|
13021
13110
|
/***/ 4644:
|
|
@@ -19397,6 +19486,42 @@ function brainfuck(hljs) {
|
|
|
19397
19486
|
}
|
|
19398
19487
|
module.exports = brainfuck;
|
|
19399
19488
|
|
|
19489
|
+
/***/ }),
|
|
19490
|
+
|
|
19491
|
+
/***/ 7566:
|
|
19492
|
+
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
|
|
19493
|
+
|
|
19494
|
+
"use strict";
|
|
19495
|
+
|
|
19496
|
+
var defineBuiltIn = __webpack_require__(6840);
|
|
19497
|
+
var uncurryThis = __webpack_require__(9504);
|
|
19498
|
+
var toString = __webpack_require__(655);
|
|
19499
|
+
var validateArgumentsLength = __webpack_require__(2812);
|
|
19500
|
+
|
|
19501
|
+
var $URLSearchParams = URLSearchParams;
|
|
19502
|
+
var URLSearchParamsPrototype = $URLSearchParams.prototype;
|
|
19503
|
+
var getAll = uncurryThis(URLSearchParamsPrototype.getAll);
|
|
19504
|
+
var $has = uncurryThis(URLSearchParamsPrototype.has);
|
|
19505
|
+
var params = new $URLSearchParams('a=1');
|
|
19506
|
+
|
|
19507
|
+
// `undefined` case is a Chromium 117 bug
|
|
19508
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=14222
|
|
19509
|
+
if (params.has('a', 2) || !params.has('a', undefined)) {
|
|
19510
|
+
defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name /* , value */) {
|
|
19511
|
+
var length = arguments.length;
|
|
19512
|
+
var $value = length < 2 ? undefined : arguments[1];
|
|
19513
|
+
if (length && $value === undefined) return $has(this, name);
|
|
19514
|
+
var values = getAll(this, name); // also validates `this`
|
|
19515
|
+
validateArgumentsLength(length, 1);
|
|
19516
|
+
var value = toString($value);
|
|
19517
|
+
var index = 0;
|
|
19518
|
+
while (index < values.length) {
|
|
19519
|
+
if (values[index++] === value) return true;
|
|
19520
|
+
} return false;
|
|
19521
|
+
}, { enumerable: true, unsafe: true });
|
|
19522
|
+
}
|
|
19523
|
+
|
|
19524
|
+
|
|
19400
19525
|
/***/ }),
|
|
19401
19526
|
|
|
19402
19527
|
/***/ 7580:
|
|
@@ -23215,6 +23340,35 @@ module.exports = DESCRIPTORS && fails(function () {
|
|
|
23215
23340
|
});
|
|
23216
23341
|
|
|
23217
23342
|
|
|
23343
|
+
/***/ }),
|
|
23344
|
+
|
|
23345
|
+
/***/ 8721:
|
|
23346
|
+
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
|
|
23347
|
+
|
|
23348
|
+
"use strict";
|
|
23349
|
+
|
|
23350
|
+
var DESCRIPTORS = __webpack_require__(3724);
|
|
23351
|
+
var uncurryThis = __webpack_require__(9504);
|
|
23352
|
+
var defineBuiltInAccessor = __webpack_require__(2106);
|
|
23353
|
+
|
|
23354
|
+
var URLSearchParamsPrototype = URLSearchParams.prototype;
|
|
23355
|
+
var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
|
|
23356
|
+
|
|
23357
|
+
// `URLSearchParams.prototype.size` getter
|
|
23358
|
+
// https://github.com/whatwg/url/pull/734
|
|
23359
|
+
if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
|
|
23360
|
+
defineBuiltInAccessor(URLSearchParamsPrototype, 'size', {
|
|
23361
|
+
get: function size() {
|
|
23362
|
+
var count = 0;
|
|
23363
|
+
forEach(this, function () { count++; });
|
|
23364
|
+
return count;
|
|
23365
|
+
},
|
|
23366
|
+
configurable: true,
|
|
23367
|
+
enumerable: true
|
|
23368
|
+
});
|
|
23369
|
+
}
|
|
23370
|
+
|
|
23371
|
+
|
|
23218
23372
|
/***/ }),
|
|
23219
23373
|
|
|
23220
23374
|
/***/ 8727:
|
|
@@ -29013,8 +29167,8 @@ var UserMessage_component = normalizeComponent(
|
|
|
29013
29167
|
)
|
|
29014
29168
|
|
|
29015
29169
|
/* harmony default export */ var UserMessage = (UserMessage_component.exports);
|
|
29016
|
-
;// ./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=
|
|
29017
|
-
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=0d2964f2&scoped=true
|
|
29171
|
+
var AiMessagevue_type_template_id_0d2964f2_scoped_true_render = function render() {
|
|
29018
29172
|
var _vm = this,
|
|
29019
29173
|
_c = _vm._self._c;
|
|
29020
29174
|
return _c('div', {
|
|
@@ -29029,26 +29183,46 @@ var AiMessagevue_type_template_id_c82646d8_scoped_true_render = function render(
|
|
|
29029
29183
|
staticClass: "dot"
|
|
29030
29184
|
}), _c('div', {
|
|
29031
29185
|
staticClass: "dot"
|
|
29032
|
-
})]) : _vm._e(), _vm.
|
|
29033
|
-
|
|
29034
|
-
|
|
29035
|
-
"
|
|
29036
|
-
|
|
29186
|
+
})]) : _vm._e(), _vm._l(_vm.mergedTimeline, function (item) {
|
|
29187
|
+
return _c('div', {
|
|
29188
|
+
key: item.id,
|
|
29189
|
+
staticClass: "ai-timeline-item"
|
|
29190
|
+
}, [item.type === 'thinking' ? _c('div', {
|
|
29191
|
+
staticClass: "ai-thinking",
|
|
29192
|
+
on: {
|
|
29193
|
+
"click": function ($event) {
|
|
29194
|
+
return _vm.$emit('thinking-toggle');
|
|
29195
|
+
}
|
|
29037
29196
|
}
|
|
29038
|
-
}
|
|
29039
|
-
|
|
29040
|
-
|
|
29041
|
-
|
|
29042
|
-
|
|
29043
|
-
|
|
29044
|
-
|
|
29045
|
-
|
|
29046
|
-
|
|
29047
|
-
|
|
29048
|
-
|
|
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
|
|
29212
|
+
}
|
|
29213
|
+
}) : _vm._e(), item.type === 'protocol_error' ? _c('div', {
|
|
29214
|
+
staticClass: "ai-protocol-error"
|
|
29215
|
+
}, [_vm._v(" " + _vm._s(item.raw) + " ")]) : _vm._e()]);
|
|
29216
|
+
})], 2)]);
|
|
29049
29217
|
};
|
|
29050
|
-
var
|
|
29051
|
-
|
|
29218
|
+
var AiMessagevue_type_template_id_0d2964f2_scoped_true_staticRenderFns = [];
|
|
29219
|
+
|
|
29220
|
+
// EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.delete.js
|
|
29221
|
+
var web_url_search_params_delete = __webpack_require__(4603);
|
|
29222
|
+
// EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.has.js
|
|
29223
|
+
var web_url_search_params_has = __webpack_require__(7566);
|
|
29224
|
+
// EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.size.js
|
|
29225
|
+
var web_url_search_params_size = __webpack_require__(8721);
|
|
29052
29226
|
;// ./node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
29053
29227
|
function _typeof(o) {
|
|
29054
29228
|
"@babel/helpers - typeof";
|
|
@@ -30824,26 +30998,30 @@ var lib = __webpack_require__(2750);
|
|
|
30824
30998
|
|
|
30825
30999
|
|
|
30826
31000
|
|
|
30827
|
-
|
|
31001
|
+
|
|
31002
|
+
|
|
31003
|
+
|
|
30828
31004
|
const renderer = new d.Renderer();
|
|
30829
31005
|
|
|
30830
|
-
//
|
|
30831
|
-
// renderer.link = function(content) {
|
|
30832
|
-
// console.log(content)
|
|
30833
|
-
// return `<router-link to="http://192.168.2.24:9529/portal/permission/user">点击跳转</router-link>`
|
|
30834
|
-
// };
|
|
31006
|
+
// 自定义链接渲染
|
|
30835
31007
|
renderer.link = function ({
|
|
30836
31008
|
href,
|
|
30837
|
-
|
|
31009
|
+
text
|
|
30838
31010
|
}) {
|
|
30839
|
-
|
|
30840
|
-
|
|
30841
|
-
const
|
|
30842
|
-
|
|
31011
|
+
let dataPath = '';
|
|
31012
|
+
const url = new URL(href, window.location.origin);
|
|
31013
|
+
const pathname = url.pathname;
|
|
31014
|
+
if (pathname.startsWith('/portal/')) {
|
|
31015
|
+
dataPath = pathname.substring('/portal'.length);
|
|
31016
|
+
return `<a href="javascript:void(0)" data-path="${dataPath}" data-text="${text}">${text}</a>`;
|
|
31017
|
+
} else {
|
|
31018
|
+
dataPath = href;
|
|
31019
|
+
return `<a href="${dataPath}" target="_blank">${text}</a>`;
|
|
31020
|
+
}
|
|
30843
31021
|
};
|
|
30844
31022
|
d.setOptions({
|
|
30845
|
-
renderer
|
|
30846
|
-
highlight
|
|
31023
|
+
renderer,
|
|
31024
|
+
highlight(code, lang) {
|
|
30847
31025
|
if (lang && es.getLanguage(lang)) {
|
|
30848
31026
|
return es.highlight(code, {
|
|
30849
31027
|
language: lang
|
|
@@ -30866,25 +31044,67 @@ d.setOptions({
|
|
|
30866
31044
|
thinkingExpanded() {
|
|
30867
31045
|
return this.message.thinkingExpanded !== false;
|
|
30868
31046
|
},
|
|
30869
|
-
renderedContent() {
|
|
30870
|
-
return d.parse(this.message.content || '');
|
|
30871
|
-
},
|
|
30872
31047
|
isLoading() {
|
|
30873
31048
|
return this.message.loading === true;
|
|
31049
|
+
},
|
|
31050
|
+
mergedTimeline() {
|
|
31051
|
+
const result = [];
|
|
31052
|
+
let last = null;
|
|
31053
|
+
for (const item of this.message.timeline || []) {
|
|
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;
|
|
30874
31069
|
}
|
|
30875
31070
|
},
|
|
30876
|
-
|
|
30877
|
-
|
|
30878
|
-
|
|
31071
|
+
methods: {
|
|
31072
|
+
renderMarkdown(text) {
|
|
31073
|
+
return d.parse(text || '');
|
|
31074
|
+
},
|
|
31075
|
+
handleLinkClick(event) {
|
|
31076
|
+
const link = event.target.closest('a');
|
|
31077
|
+
if (!link) return;
|
|
31078
|
+
const routePath = link.getAttribute('data-path');
|
|
31079
|
+
const linkText = link.getAttribute('data-text');
|
|
31080
|
+
if (routePath && linkText) {
|
|
31081
|
+
event.preventDefault();
|
|
31082
|
+
if (this.$appOptions?.store?.dispatch) {
|
|
31083
|
+
this.$appOptions.store.dispatch('tags/addTagview', {
|
|
31084
|
+
path: routePath,
|
|
31085
|
+
fullPath: routePath,
|
|
31086
|
+
label: linkText,
|
|
31087
|
+
name: linkText,
|
|
31088
|
+
meta: {
|
|
31089
|
+
title: linkText
|
|
31090
|
+
}
|
|
31091
|
+
});
|
|
31092
|
+
this.$appOptions.router.push({
|
|
31093
|
+
path: routePath
|
|
31094
|
+
});
|
|
31095
|
+
} else {
|
|
31096
|
+
this.$router.push(routePath).catch(() => {});
|
|
31097
|
+
}
|
|
31098
|
+
}
|
|
30879
31099
|
}
|
|
30880
31100
|
}
|
|
30881
31101
|
});
|
|
30882
31102
|
;// ./components/AiMessage.vue?vue&type=script&lang=js
|
|
30883
31103
|
/* harmony default export */ var components_AiMessagevue_type_script_lang_js = (AiMessagevue_type_script_lang_js);
|
|
30884
|
-
;// ./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=
|
|
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=0d2964f2&prod&scoped=true&lang=css
|
|
30885
31105
|
// extracted by mini-css-extract-plugin
|
|
30886
31106
|
|
|
30887
|
-
;// ./components/AiMessage.vue?vue&type=style&index=0&id=
|
|
31107
|
+
;// ./components/AiMessage.vue?vue&type=style&index=0&id=0d2964f2&prod&scoped=true&lang=css
|
|
30888
31108
|
|
|
30889
31109
|
;// ./components/AiMessage.vue
|
|
30890
31110
|
|
|
@@ -30897,11 +31117,11 @@ d.setOptions({
|
|
|
30897
31117
|
|
|
30898
31118
|
var AiMessage_component = normalizeComponent(
|
|
30899
31119
|
components_AiMessagevue_type_script_lang_js,
|
|
30900
|
-
|
|
30901
|
-
|
|
31120
|
+
AiMessagevue_type_template_id_0d2964f2_scoped_true_render,
|
|
31121
|
+
AiMessagevue_type_template_id_0d2964f2_scoped_true_staticRenderFns,
|
|
30902
31122
|
false,
|
|
30903
31123
|
null,
|
|
30904
|
-
"
|
|
31124
|
+
"0d2964f2",
|
|
30905
31125
|
null
|
|
30906
31126
|
|
|
30907
31127
|
)
|
|
@@ -31422,99 +31642,138 @@ const TIME_JUMP_POINTS_URL = '/minio/lingxiaoai/timeJumpPoints.json'; // 语音u
|
|
|
31422
31642
|
});
|
|
31423
31643
|
;// ./components/utils/StreamParser.js
|
|
31424
31644
|
|
|
31645
|
+
// utils/StreamParser.js
|
|
31425
31646
|
class StreamParser {
|
|
31426
31647
|
constructor(options = {}) {
|
|
31427
31648
|
this.options = {
|
|
31428
31649
|
updateInterval: 16,
|
|
31429
|
-
// 每16ms刷新一次(约60fps)
|
|
31430
31650
|
debug: false,
|
|
31431
31651
|
...options
|
|
31432
31652
|
};
|
|
31433
31653
|
this.reset();
|
|
31434
31654
|
}
|
|
31435
|
-
|
|
31436
|
-
// 重置解析器状态
|
|
31437
31655
|
reset() {
|
|
31438
|
-
this.buffer = '';
|
|
31439
31656
|
this.contentBuffer = [];
|
|
31440
31657
|
this.thinkingBuffer = [];
|
|
31658
|
+
this.completedThinkingSegments = [];
|
|
31659
|
+
this.completedToolCalls = [];
|
|
31660
|
+
this.currentToolCall = null;
|
|
31661
|
+
this.protocolErrorBuffer = []; // ✅ 新增
|
|
31662
|
+
|
|
31441
31663
|
this.inTag = false;
|
|
31442
31664
|
this.tagBuffer = '';
|
|
31443
31665
|
this.updateTimer = null;
|
|
31444
|
-
this.status = 'output'; // thinking | output
|
|
31666
|
+
this.status = 'output'; // thinking | output | tool_call | tool_result
|
|
31445
31667
|
}
|
|
31446
|
-
|
|
31447
|
-
// 处理接收到的流数据块
|
|
31448
31668
|
processChunk(chunk, callback) {
|
|
31449
31669
|
if (!chunk) return;
|
|
31450
31670
|
this.parseContent(chunk, callback);
|
|
31451
31671
|
}
|
|
31452
|
-
|
|
31453
|
-
// 核心内容解析,支持 <think> 标签
|
|
31454
31672
|
parseContent(content, callback) {
|
|
31455
31673
|
let i = 0;
|
|
31456
31674
|
while (i < content.length) {
|
|
31457
31675
|
if (this.inTag) {
|
|
31458
|
-
const
|
|
31459
|
-
if (
|
|
31460
|
-
this.tagBuffer += content.
|
|
31676
|
+
const end = content.indexOf('>', i);
|
|
31677
|
+
if (end !== -1) {
|
|
31678
|
+
this.tagBuffer += content.slice(i, end + 1);
|
|
31461
31679
|
this.handleTag(this.tagBuffer);
|
|
31462
31680
|
this.tagBuffer = '';
|
|
31463
31681
|
this.inTag = false;
|
|
31464
|
-
i =
|
|
31682
|
+
i = end + 1;
|
|
31465
31683
|
} else {
|
|
31466
|
-
|
|
31467
|
-
this.tagBuffer += content.substring(i);
|
|
31468
|
-
if (this.tagBuffer.length > 50) {
|
|
31469
|
-
this.appendText(this.tagBuffer);
|
|
31470
|
-
this.tagBuffer = '';
|
|
31471
|
-
this.inTag = false;
|
|
31472
|
-
}
|
|
31684
|
+
this.tagBuffer += content.slice(i);
|
|
31473
31685
|
break;
|
|
31474
31686
|
}
|
|
31475
31687
|
} else {
|
|
31476
|
-
const
|
|
31477
|
-
if (
|
|
31478
|
-
|
|
31479
|
-
const endIndex = content.indexOf('>', startIndex);
|
|
31480
|
-
if (endIndex !== -1) {
|
|
31481
|
-
const tag = content.substring(startIndex, endIndex + 1);
|
|
31482
|
-
this.handleTag(tag);
|
|
31483
|
-
i = endIndex + 1;
|
|
31484
|
-
} else {
|
|
31485
|
-
const nextChar = content[startIndex + 1];
|
|
31486
|
-
if (!/[a-zA-Z/]/.test(nextChar)) {
|
|
31487
|
-
// 很可能不是标签,直接当文本输出
|
|
31488
|
-
this.appendText('<');
|
|
31489
|
-
i = startIndex + 1;
|
|
31490
|
-
} else {
|
|
31491
|
-
this.inTag = true;
|
|
31492
|
-
this.tagBuffer = content.substring(startIndex);
|
|
31493
|
-
break;
|
|
31494
|
-
}
|
|
31495
|
-
}
|
|
31496
|
-
} else {
|
|
31497
|
-
this.appendText(content.substring(i));
|
|
31688
|
+
const start = content.indexOf('<', i);
|
|
31689
|
+
if (start === -1) {
|
|
31690
|
+
this.appendText(content.slice(i));
|
|
31498
31691
|
break;
|
|
31499
31692
|
}
|
|
31693
|
+
if (start > i) {
|
|
31694
|
+
this.appendText(content.slice(i, start));
|
|
31695
|
+
}
|
|
31696
|
+
const end = content.indexOf('>', start);
|
|
31697
|
+
if (end === -1) {
|
|
31698
|
+
this.inTag = true;
|
|
31699
|
+
this.tagBuffer = content.slice(start);
|
|
31700
|
+
break;
|
|
31701
|
+
}
|
|
31702
|
+
const tag = content.slice(start, end + 1);
|
|
31703
|
+
this.handleTag(tag);
|
|
31704
|
+
i = end + 1;
|
|
31500
31705
|
}
|
|
31501
31706
|
}
|
|
31502
31707
|
this.scheduleUpdate(callback);
|
|
31503
31708
|
}
|
|
31504
|
-
|
|
31505
|
-
// 处理标签
|
|
31506
31709
|
handleTag(tag) {
|
|
31507
31710
|
const t = tag.toLowerCase();
|
|
31508
|
-
if (t === '<think>') this.status = 'thinking';else if (t === '</think>') this.status = 'output';
|
|
31509
|
-
}
|
|
31510
31711
|
|
|
31511
|
-
|
|
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
|
+
}
|
|
31764
|
+
}
|
|
31512
31765
|
appendText(text) {
|
|
31513
31766
|
if (!text) return;
|
|
31514
|
-
if (this.status === 'thinking')
|
|
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
|
+
}
|
|
31515
31776
|
}
|
|
31516
|
-
|
|
31517
|
-
// 防抖刷新
|
|
31518
31777
|
scheduleUpdate(callback) {
|
|
31519
31778
|
if (this.updateTimer) return;
|
|
31520
31779
|
this.updateTimer = setTimeout(() => {
|
|
@@ -31522,32 +31781,39 @@ class StreamParser {
|
|
|
31522
31781
|
this.updateTimer = null;
|
|
31523
31782
|
}, this.options.updateInterval);
|
|
31524
31783
|
}
|
|
31525
|
-
|
|
31526
|
-
// 刷新缓冲区
|
|
31527
31784
|
flush(callback) {
|
|
31528
31785
|
if (!callback) return;
|
|
31529
31786
|
const result = {
|
|
31530
|
-
|
|
31531
|
-
|
|
31787
|
+
thinkingSegment: null,
|
|
31788
|
+
toolCall: null,
|
|
31789
|
+
content: null,
|
|
31790
|
+
protocolError: null,
|
|
31532
31791
|
status: this.status
|
|
31533
31792
|
};
|
|
31534
|
-
this.
|
|
31535
|
-
|
|
31793
|
+
if (this.protocolErrorBuffer.length) {
|
|
31794
|
+
result.protocolError = this.protocolErrorBuffer.join('\n');
|
|
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
|
+
}
|
|
31536
31807
|
callback(result);
|
|
31537
31808
|
}
|
|
31538
|
-
|
|
31539
|
-
// 完成解析
|
|
31540
31809
|
finish(callback) {
|
|
31541
|
-
if (this.
|
|
31542
|
-
this.
|
|
31543
|
-
this.
|
|
31544
|
-
this.inTag = false;
|
|
31810
|
+
if (this.thinkingBuffer.length) {
|
|
31811
|
+
this.completedThinkingSegments.push(this.thinkingBuffer.join(''));
|
|
31812
|
+
this.thinkingBuffer = [];
|
|
31545
31813
|
}
|
|
31546
31814
|
this.flush(callback);
|
|
31547
31815
|
if (this.updateTimer) clearTimeout(this.updateTimer);
|
|
31548
31816
|
}
|
|
31549
|
-
|
|
31550
|
-
// 销毁解析器
|
|
31551
31817
|
destroy() {
|
|
31552
31818
|
if (this.updateTimer) clearTimeout(this.updateTimer);
|
|
31553
31819
|
this.reset();
|
|
@@ -31597,9 +31863,7 @@ const getCookie = cname => {
|
|
|
31597
31863
|
type: 'ai',
|
|
31598
31864
|
sender: 'AI',
|
|
31599
31865
|
time: '',
|
|
31600
|
-
|
|
31601
|
-
charts: [],
|
|
31602
|
-
content: '',
|
|
31866
|
+
timeline: [],
|
|
31603
31867
|
loading: true,
|
|
31604
31868
|
thinkingExpanded: true
|
|
31605
31869
|
};
|
|
@@ -31632,7 +31896,7 @@ const getCookie = cname => {
|
|
|
31632
31896
|
const controller = new AbortController();
|
|
31633
31897
|
try {
|
|
31634
31898
|
const startTime = Date.now();
|
|
31635
|
-
const token = getCookie('bonyear-access_token') || `
|
|
31899
|
+
const token = getCookie('bonyear-access_token') || `b6dd936e-4b8b-4e10-ba70-573eb35673f1`;
|
|
31636
31900
|
const response = await fetch(API_URL, {
|
|
31637
31901
|
method: 'POST',
|
|
31638
31902
|
signal: controller.signal,
|
|
@@ -31712,27 +31976,38 @@ const getCookie = cname => {
|
|
|
31712
31976
|
*/
|
|
31713
31977
|
handleStreamUpdate(result) {
|
|
31714
31978
|
if (!this.currentMessage) return;
|
|
31715
|
-
|
|
31716
|
-
if (
|
|
31717
|
-
this.currentMessage.
|
|
31979
|
+
this.currentMessage.loading = false;
|
|
31980
|
+
if (result.protocolError) {
|
|
31981
|
+
this.currentMessage.timeline.push({
|
|
31982
|
+
type: 'protocol_error',
|
|
31983
|
+
id: Date.now() + Math.random(),
|
|
31984
|
+
raw: result.protocolError
|
|
31985
|
+
});
|
|
31718
31986
|
}
|
|
31719
|
-
|
|
31720
|
-
|
|
31721
|
-
|
|
31987
|
+
if (result.thinkingSegment) {
|
|
31988
|
+
this.currentMessage.timeline.push({
|
|
31989
|
+
type: 'thinking',
|
|
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
|
+
});
|
|
31722
32000
|
}
|
|
31723
|
-
|
|
31724
|
-
// 更新回复内容
|
|
31725
|
-
console.log('更新回复内容:', result.content);
|
|
31726
32001
|
if (result.content) {
|
|
31727
|
-
this.currentMessage.
|
|
32002
|
+
this.currentMessage.timeline.push({
|
|
32003
|
+
type: 'content',
|
|
32004
|
+
id: Date.now() + Math.random(),
|
|
32005
|
+
text: result.content
|
|
32006
|
+
});
|
|
31728
32007
|
}
|
|
31729
32008
|
|
|
31730
32009
|
// 更新状态
|
|
31731
|
-
|
|
31732
|
-
this.avaterStatus = 'thinking';
|
|
31733
|
-
} else {
|
|
31734
|
-
this.avaterStatus = 'output';
|
|
31735
|
-
}
|
|
32010
|
+
this.avaterStatus = result.status === 'thinking' ? 'thinking' : 'output';
|
|
31736
32011
|
|
|
31737
32012
|
// 触发视图更新
|
|
31738
32013
|
this.$forceUpdate();
|