@xcanwin/manyoyo 7.0.17 → 7.0.20
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/lib/web/frontend/app.js +32 -0
- package/lib/web/frontend/shadcn.html +75 -75
- package/lib/web/server.js +115 -19
- package/package.json +1 -1
package/lib/web/frontend/app.js
CHANGED
|
@@ -4439,6 +4439,21 @@
|
|
|
4439
4439
|
}
|
|
4440
4440
|
}
|
|
4441
4441
|
|
|
4442
|
+
function appendStreamingReplyChunkLocal(sessionName, replyMessageId, chunk, reset) {
|
|
4443
|
+
if (state.active !== sessionName) {
|
|
4444
|
+
return;
|
|
4445
|
+
}
|
|
4446
|
+
for (var i = state.messages.length - 1; i >= 0; i -= 1) {
|
|
4447
|
+
var message = state.messages[i];
|
|
4448
|
+
if (!message || String(message.id || '') !== String(replyMessageId || '')) {
|
|
4449
|
+
continue;
|
|
4450
|
+
}
|
|
4451
|
+
message.content = reset ? '' : String(message.content || '') + String(chunk || '');
|
|
4452
|
+
message.timestamp = new Date().toISOString();
|
|
4453
|
+
return;
|
|
4454
|
+
}
|
|
4455
|
+
}
|
|
4456
|
+
|
|
4442
4457
|
function removeStreamingReplyLocal(sessionName, replyMessageId) {
|
|
4443
4458
|
if (state.active !== sessionName) {
|
|
4444
4459
|
return;
|
|
@@ -4522,6 +4537,23 @@
|
|
|
4522
4537
|
}
|
|
4523
4538
|
return;
|
|
4524
4539
|
}
|
|
4540
|
+
if (event.type === 'content_chunk') {
|
|
4541
|
+
// token 级增量:服务端只发新增片段,这里追加。
|
|
4542
|
+
// reset 表示换了一条 assistant 消息,从空白重新开始
|
|
4543
|
+
if (!streamingReplyId) {
|
|
4544
|
+
streamingReplyId = appendStreamingReplyLocal(sessionName);
|
|
4545
|
+
}
|
|
4546
|
+
appendStreamingReplyChunkLocal(
|
|
4547
|
+
sessionName,
|
|
4548
|
+
streamingReplyId,
|
|
4549
|
+
event.reset === true ? '' : String(event.text || ''),
|
|
4550
|
+
event.reset === true
|
|
4551
|
+
);
|
|
4552
|
+
if (state.active === sessionName) {
|
|
4553
|
+
renderMessages(state.messages);
|
|
4554
|
+
}
|
|
4555
|
+
return;
|
|
4556
|
+
}
|
|
4525
4557
|
if (event.type === 'result') {
|
|
4526
4558
|
finalResult = event;
|
|
4527
4559
|
if (event.interrupted) {
|