@codehz/ai 0.2.2 → 0.2.3
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/README.md +4 -0
- package/dist/index.mjs +11 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/aggregator.ts +15 -2
package/README.md
CHANGED
|
@@ -107,6 +107,10 @@ console.log(response.replay); // 续接材料
|
|
|
107
107
|
| `warnings` | `string[]` | 非致命警告 |
|
|
108
108
|
| `backend` | `BackendTrace` | 调用链路元数据 |
|
|
109
109
|
|
|
110
|
+
流式 `message.delta` / `reasoning.delta` 保持后端分片粒度;完成态 `output` 中的
|
|
111
|
+
`message` / `reasoning` 会合并相邻 `text` content blocks(直接拼接且不添加分隔符),
|
|
112
|
+
非文本 block 仍保留原有边界。
|
|
113
|
+
|
|
110
114
|
## 后端 Adapter
|
|
111
115
|
|
|
112
116
|
| Adapter | 类 | 说明 |
|
package/dist/index.mjs
CHANGED
|
@@ -494,12 +494,21 @@ function getActiveItem(state, itemId, expectedType) {
|
|
|
494
494
|
if (item.type !== expectedType) throw streamProtocolError(`Item ${itemId} started as ${item.type} but received ${expectedType} event`);
|
|
495
495
|
return item;
|
|
496
496
|
}
|
|
497
|
+
function coalesceContentBlocks(blocks) {
|
|
498
|
+
const result = [];
|
|
499
|
+
for (const block of blocks) {
|
|
500
|
+
const previous = result[result.length - 1];
|
|
501
|
+
if (block.type === "text" && previous?.type === "text") previous.text += block.text;
|
|
502
|
+
else result.push({ ...block });
|
|
503
|
+
}
|
|
504
|
+
return result;
|
|
505
|
+
}
|
|
497
506
|
function finalizeMessage(active) {
|
|
498
507
|
return {
|
|
499
508
|
type: "message",
|
|
500
509
|
id: active.id,
|
|
501
510
|
role: active.role,
|
|
502
|
-
content: active.content
|
|
511
|
+
content: coalesceContentBlocks(active.content)
|
|
503
512
|
};
|
|
504
513
|
}
|
|
505
514
|
function finalizeReasoning(active) {
|
|
@@ -507,7 +516,7 @@ function finalizeReasoning(active) {
|
|
|
507
516
|
type: "reasoning",
|
|
508
517
|
id: active.id,
|
|
509
518
|
visibility: active.visibility,
|
|
510
|
-
content: active.content
|
|
519
|
+
content: coalesceContentBlocks(active.content)
|
|
511
520
|
};
|
|
512
521
|
}
|
|
513
522
|
function finalizeToolCall(active) {
|