@ynhcj/xiaoyi-channel 0.0.181-next → 0.0.182-next
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/src/reply-dispatcher.js +20 -12
- package/package.json +1 -1
|
@@ -418,21 +418,29 @@ export function createXYReplyDispatcher(params) {
|
|
|
418
418
|
}
|
|
419
419
|
},
|
|
420
420
|
onPartialReply: async (payload) => {
|
|
421
|
-
|
|
421
|
+
let text = payload.text ?? "";
|
|
422
422
|
try {
|
|
423
423
|
if (text.length > 0) {
|
|
424
|
-
|
|
424
|
+
// 模型可能返回完整文本(非纯增量),如果新文本以已累积内容开头,
|
|
425
|
+
// 则只取新增的后缀部分,避免 append 模式下重复拼接。
|
|
426
|
+
let sendText = text;
|
|
427
|
+
if (accumulatedText.length > 0 && text.startsWith(accumulatedText)) {
|
|
428
|
+
sendText = text.slice(accumulatedText.length);
|
|
429
|
+
}
|
|
430
|
+
accumulatedText += sendText;
|
|
425
431
|
hasSentResponse = true;
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
432
|
+
if (sendText.length > 0) {
|
|
433
|
+
await sendA2AResponse({
|
|
434
|
+
config,
|
|
435
|
+
sessionId,
|
|
436
|
+
taskId: getActiveTaskId(),
|
|
437
|
+
messageId: getActiveMessageId(),
|
|
438
|
+
text: sendText,
|
|
439
|
+
append: true,
|
|
440
|
+
final: false,
|
|
441
|
+
log: false,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
436
444
|
}
|
|
437
445
|
}
|
|
438
446
|
catch (err) {
|