@wendongfly/myhi 1.3.39 → 1.3.40
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/chat.html +7 -5
- package/package.json +1 -1
package/dist/chat.html
CHANGED
|
@@ -820,6 +820,7 @@
|
|
|
820
820
|
|
|
821
821
|
let _streamEl = null; // 当前流式输出的 assistant 元素
|
|
822
822
|
let _streamText = ''; // 累积的原始文本
|
|
823
|
+
let _streamedTextThisMessage = false; // 当前 message 是否已通过 content_block_delta 流式渲染过 text;用于在末尾 assistant 事件中跳过重复渲染
|
|
823
824
|
|
|
824
825
|
function addAssistantMessage(raw) {
|
|
825
826
|
removeThinking(); endToolGroup();
|
|
@@ -1318,7 +1319,7 @@
|
|
|
1318
1319
|
if (block.type === 'thinking' && block.thinking) {
|
|
1319
1320
|
showThinking(block.thinking);
|
|
1320
1321
|
} else if (block.type === 'text' && block.text) {
|
|
1321
|
-
addAssistantMessage(block.text);
|
|
1322
|
+
if (!_streamedTextThisMessage) addAssistantMessage(block.text);
|
|
1322
1323
|
} else if (block.type === 'tool_use') {
|
|
1323
1324
|
if (block.name === 'AskUserQuestion' && block.input) {
|
|
1324
1325
|
openAskSheet(block.input);
|
|
@@ -1330,6 +1331,7 @@
|
|
|
1330
1331
|
}
|
|
1331
1332
|
}
|
|
1332
1333
|
}
|
|
1334
|
+
_streamedTextThisMessage = false;
|
|
1333
1335
|
setWorkState('working');
|
|
1334
1336
|
break;
|
|
1335
1337
|
case 'result':
|
|
@@ -1342,10 +1344,9 @@
|
|
|
1342
1344
|
addStatusMessage(`完成${cost}`);
|
|
1343
1345
|
break;
|
|
1344
1346
|
case 'content_block_start':
|
|
1345
|
-
//
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
} else if (msg.content_block?.type === 'thinking') {
|
|
1347
|
+
// 流式内容块开始:thinking 时创建占位,由 thinking_delta 增量填充;
|
|
1348
|
+
// tool_use 不创建占位卡,待末尾 assistant 事件用完整入参渲染,避免重复
|
|
1349
|
+
if (msg.content_block?.type === 'thinking') {
|
|
1349
1350
|
showThinking('');
|
|
1350
1351
|
}
|
|
1351
1352
|
setWorkState('working');
|
|
@@ -1354,6 +1355,7 @@
|
|
|
1354
1355
|
// 流式内容增量
|
|
1355
1356
|
if (msg.delta?.type === 'text_delta' && msg.delta.text) {
|
|
1356
1357
|
appendStream(msg.delta.text);
|
|
1358
|
+
_streamedTextThisMessage = true;
|
|
1357
1359
|
} else if (msg.delta?.type === 'thinking_delta' && msg.delta.thinking) {
|
|
1358
1360
|
appendThinking(msg.delta.thinking);
|
|
1359
1361
|
} else if (msg.delta?.type === 'input_json_delta' && msg.delta.partial_json) {
|