dsh-folia 4.26.0-pre.22 → 4.26.0-pre.24
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 +26 -2
- package/lib/routes/pet-chat.js +1207 -1207
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -20459,7 +20459,9 @@ window.__ModuleLoader__.load({
|
|
|
20459
20459
|
|
|
20460
20460
|
function stop() { active = false; onState({ state: 'idle' }); }
|
|
20461
20461
|
|
|
20462
|
-
|
|
20462
|
+
// ⚠️ 必须把 postChat 暴露出去:桌宠的「打字说」走 petVoiceIn.postChat(text),
|
|
20463
|
+
// 上一版这里只返回 start/stop ⇒ typing 发送时 TypeError(输入框消失、气泡无反应)。
|
|
20464
|
+
return { start, stop, isActive: () => active, postChat };
|
|
20463
20465
|
}
|
|
20464
20466
|
|
|
20465
20467
|
// ── 内联模块:src/pet-bubble.js —— 头顶气泡:锚定桌宠头顶、跟随位置/缩放、逐字显示、最多 6 行、朗读结束 +3s 淡出(构建期注入;勿手改本段)──
|
|
@@ -20793,6 +20795,9 @@ window.__ModuleLoader__.load({
|
|
|
20793
20795
|
if (typeof onState === 'function') onState({ state: 'idle' });
|
|
20794
20796
|
return;
|
|
20795
20797
|
}
|
|
20798
|
+
let rawReply = '';
|
|
20799
|
+
let replyStarted = false;
|
|
20800
|
+
let replyDone = false;
|
|
20796
20801
|
const reader = stream.body.getReader();
|
|
20797
20802
|
const decoder = new TextDecoder();
|
|
20798
20803
|
let buffer = '';
|
|
@@ -20809,7 +20814,26 @@ window.__ModuleLoader__.load({
|
|
|
20809
20814
|
if (!line) continue;
|
|
20810
20815
|
let payload = null;
|
|
20811
20816
|
try { payload = JSON.parse(line.slice(5).trim()); } catch { payload = null; }
|
|
20812
|
-
|
|
20817
|
+
// 防兜底:模型偶尔仍会输出 {"reply":"…","emotion":"…"} 信封,
|
|
20818
|
+
// 这里只把 reply 的正文喂给气泡(不显示大括号/字段名/emotion)。
|
|
20819
|
+
if (payload && typeof payload.t === 'string') {
|
|
20820
|
+
rawReply += payload.t;
|
|
20821
|
+
let piece = payload.t;
|
|
20822
|
+
if (!replyStarted) {
|
|
20823
|
+
const at = rawReply.indexOf('"reply":"');
|
|
20824
|
+
if (at >= 0) {
|
|
20825
|
+
replyStarted = true;
|
|
20826
|
+
piece = rawReply.slice(at + 9);
|
|
20827
|
+
} else if (rawReply.trimStart().startsWith('{')) {
|
|
20828
|
+
piece = '';
|
|
20829
|
+
}
|
|
20830
|
+
}
|
|
20831
|
+
if (piece && !replyDone) {
|
|
20832
|
+
const cut = piece.indexOf('","emotion"');
|
|
20833
|
+
if (cut >= 0) { piece = piece.slice(0, cut); replyDone = true; }
|
|
20834
|
+
if (piece) petBubble.append(piece);
|
|
20835
|
+
}
|
|
20836
|
+
}
|
|
20813
20837
|
}
|
|
20814
20838
|
}
|
|
20815
20839
|
if (typeof onState === 'function') onState({ state: 'idle' });
|