dsh-folia 4.26.0-pre.21 → 4.26.0-pre.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/lib/client.js +23 -1
- package/lib/routes/pet-chat.js +1207 -1207
- package/lib/voice/record.js +15 -2
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -20793,6 +20793,9 @@ window.__ModuleLoader__.load({
|
|
|
20793
20793
|
if (typeof onState === 'function') onState({ state: 'idle' });
|
|
20794
20794
|
return;
|
|
20795
20795
|
}
|
|
20796
|
+
let rawReply = '';
|
|
20797
|
+
let replyStarted = false;
|
|
20798
|
+
let replyDone = false;
|
|
20796
20799
|
const reader = stream.body.getReader();
|
|
20797
20800
|
const decoder = new TextDecoder();
|
|
20798
20801
|
let buffer = '';
|
|
@@ -20809,7 +20812,26 @@ window.__ModuleLoader__.load({
|
|
|
20809
20812
|
if (!line) continue;
|
|
20810
20813
|
let payload = null;
|
|
20811
20814
|
try { payload = JSON.parse(line.slice(5).trim()); } catch { payload = null; }
|
|
20812
|
-
|
|
20815
|
+
// 防兜底:模型偶尔仍会输出 {"reply":"…","emotion":"…"} 信封,
|
|
20816
|
+
// 这里只把 reply 的正文喂给气泡(不显示大括号/字段名/emotion)。
|
|
20817
|
+
if (payload && typeof payload.t === 'string') {
|
|
20818
|
+
rawReply += payload.t;
|
|
20819
|
+
let piece = payload.t;
|
|
20820
|
+
if (!replyStarted) {
|
|
20821
|
+
const at = rawReply.indexOf('"reply":"');
|
|
20822
|
+
if (at >= 0) {
|
|
20823
|
+
replyStarted = true;
|
|
20824
|
+
piece = rawReply.slice(at + 9);
|
|
20825
|
+
} else if (rawReply.trimStart().startsWith('{')) {
|
|
20826
|
+
piece = '';
|
|
20827
|
+
}
|
|
20828
|
+
}
|
|
20829
|
+
if (piece && !replyDone) {
|
|
20830
|
+
const cut = piece.indexOf('","emotion"');
|
|
20831
|
+
if (cut >= 0) { piece = piece.slice(0, cut); replyDone = true; }
|
|
20832
|
+
if (piece) petBubble.append(piece);
|
|
20833
|
+
}
|
|
20834
|
+
}
|
|
20813
20835
|
}
|
|
20814
20836
|
}
|
|
20815
20837
|
if (typeof onState === 'function') onState({ state: 'idle' });
|