billion-context 0.1.72-pr.472.287 → 0.1.72
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/index.js +4 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -54221,7 +54221,7 @@ function mergeUsageSample(acc, sample) {
|
|
|
54221
54221
|
if (sample.cachedTokens !== void 0) acc.cachedTokens = sample.cachedTokens;
|
|
54222
54222
|
if (sample.outputTokens !== void 0) acc.outputTokens = sample.outputTokens;
|
|
54223
54223
|
}
|
|
54224
|
-
async function pipePluginChatWithStrip(stream2, res,
|
|
54224
|
+
async function pipePluginChatWithStrip(stream2, res, session, protocol, log2) {
|
|
54225
54225
|
const reader = stream2.getReader();
|
|
54226
54226
|
const decoder = new TextDecoder("utf-8");
|
|
54227
54227
|
let buf = "";
|
|
@@ -54375,7 +54375,7 @@ data: ${JSON.stringify({ type: "content_block_delta", index, delta: { type: delt
|
|
|
54375
54375
|
}
|
|
54376
54376
|
const rest = flushTails();
|
|
54377
54377
|
if (rest.length > 0 && !res.destroyed && !res.writableEnded) await write(rest);
|
|
54378
|
-
if (
|
|
54378
|
+
if (acc.inputTokens !== void 0 || acc.outputTokens !== void 0 || acc.cachedTokens !== void 0) {
|
|
54379
54379
|
applyUsageSample(session, acc, protocol);
|
|
54380
54380
|
markDirty(session);
|
|
54381
54381
|
}
|
|
@@ -54484,7 +54484,7 @@ async function pipePluginResponsesWithStrip(stream2, res, session, log2) {
|
|
|
54484
54484
|
const rest = flushTail("");
|
|
54485
54485
|
if (rest.length > 0) await write(rest);
|
|
54486
54486
|
}
|
|
54487
|
-
if (
|
|
54487
|
+
if (acc.inputTokens !== void 0 || acc.outputTokens !== void 0 || acc.cachedTokens !== void 0) {
|
|
54488
54488
|
applyUsageSample(session, acc, "responses");
|
|
54489
54489
|
markDirty(session);
|
|
54490
54490
|
}
|
|
@@ -57511,7 +57511,7 @@ ${hdrText}
|
|
|
57511
57511
|
if (prepared.protocol === "responses") {
|
|
57512
57512
|
await pipePluginResponsesWithStrip(upstream.body, res, prepared.session, (msg) => log2("info", `[${prepared.session.id}] ${msg}`));
|
|
57513
57513
|
} else {
|
|
57514
|
-
await pipePluginChatWithStrip(upstream.body, res, prepared.
|
|
57514
|
+
await pipePluginChatWithStrip(upstream.body, res, prepared.session, prepared.protocol, (msg) => log2("info", `[${prepared.session.id}] ${msg}`));
|
|
57515
57515
|
}
|
|
57516
57516
|
} else {
|
|
57517
57517
|
await pipePluginJson(upstream.body, res, prepared.session, prepared.protocol);
|
|
@@ -57533,15 +57533,6 @@ ${hdrText}
|
|
|
57533
57533
|
} else {
|
|
57534
57534
|
log2("warn", `[${prepared.session.id}] native compact response terminal=${terminal}; rebase NOT scheduled`);
|
|
57535
57535
|
}
|
|
57536
|
-
} else if (prepared && prepared.stream && (upstream.headers.get("content-type") ?? "").includes("text/event-stream")) {
|
|
57537
|
-
const p2 = prepared;
|
|
57538
|
-
const tagLog = (msg) => log2("info", `[${p2.session.id}] ${msg}`);
|
|
57539
|
-
if (p2.protocol === "responses") {
|
|
57540
|
-
await pipePluginResponsesWithStrip(upstream.body, res, void 0, tagLog);
|
|
57541
|
-
} else {
|
|
57542
|
-
await pipePluginChatWithStrip(upstream.body, res, p2.protocol, void 0, tagLog);
|
|
57543
|
-
}
|
|
57544
|
-
clearUpstreamTimer();
|
|
57545
57536
|
} else {
|
|
57546
57537
|
await pipeThrough(upstream.body, res);
|
|
57547
57538
|
clearUpstreamTimer();
|