billion-context 0.1.88-pr.593.419 → 0.1.88

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 CHANGED
@@ -53417,23 +53417,6 @@ function stripFinishReasonChunk(buf) {
53417
53417
  return buf;
53418
53418
  }
53419
53419
  }
53420
- function patchUsageChunk(eventStr, parsed, u2, hostCredit) {
53421
- const pu = typeof u2.prompt_tokens === "number" ? u2.prompt_tokens : void 0;
53422
- const tu = typeof u2.total_tokens === "number" ? u2.total_tokens : void 0;
53423
- if (hostCredit > 0 && (pu !== void 0 || tu !== void 0)) {
53424
- const patched = {
53425
- ...parsed,
53426
- usage: {
53427
- ...u2,
53428
- ...pu !== void 0 ? { prompt_tokens: pu + hostCredit } : {},
53429
- ...tu !== void 0 ? { total_tokens: tu + hostCredit } : {}
53430
- }
53431
- };
53432
- const out = eventStr.split("\n").map((l) => l.startsWith("data:") ? `data: ${JSON.stringify(patched)}` : l).join("\n");
53433
- return Buffer.from(out + "\n\n", "utf8");
53434
- }
53435
- return Buffer.from(eventStr + "\n\n", "utf8");
53436
- }
53437
53420
  function createOpenaiAdapter(requestBody, clientSystem, hostCredit = 0) {
53438
53421
  const model = requestBody.model ?? "unknown";
53439
53422
  let responseId = `chatcmpl-proxy-${Date.now()}`;
@@ -53610,9 +53593,6 @@ function createOpenaiAdapter(requestBody, clientSystem, hostCredit = 0) {
53610
53593
  outputTokens: typeof u2.completion_tokens === "number" ? u2.completion_tokens : void 0,
53611
53594
  cachedTokens: typeof pd?.cached_tokens === "number" ? pd.cached_tokens : void 0
53612
53595
  };
53613
- if (sawRealToolCall) {
53614
- yield { kind: "meta", chunk: patchUsageChunk(eventStr, parsed, u2, hostCredit) };
53615
- }
53616
53596
  }
53617
53597
  continue;
53618
53598
  }
@@ -53631,7 +53611,23 @@ function createOpenaiAdapter(requestBody, clientSystem, hostCredit = 0) {
53631
53611
  cachedTokens: typeof pd?.cached_tokens === "number" ? pd.cached_tokens : void 0
53632
53612
  };
53633
53613
  if (sawRealToolCall) {
53634
- const chunk = patchUsageChunk(eventStr, parsed, u2 ?? {}, hostCredit);
53614
+ let chunk = rawBuf;
53615
+ if (hostCredit > 0 && u2) {
53616
+ const pu = typeof u2.prompt_tokens === "number" ? u2.prompt_tokens : void 0;
53617
+ const tu = typeof u2.total_tokens === "number" ? u2.total_tokens : void 0;
53618
+ if (pu !== void 0 || tu !== void 0) {
53619
+ const patched = {
53620
+ ...parsed,
53621
+ usage: {
53622
+ ...u2,
53623
+ ...pu !== void 0 ? { prompt_tokens: pu + hostCredit } : {},
53624
+ ...tu !== void 0 ? { total_tokens: tu + hostCredit } : {}
53625
+ }
53626
+ };
53627
+ const out = eventStr.split("\n").map((l) => l.startsWith("data:") ? `data: ${JSON.stringify(patched)}` : l).join("\n");
53628
+ chunk = Buffer.from(out + "\n\n", "utf8");
53629
+ }
53630
+ }
53635
53631
  yield { kind: "meta", chunk };
53636
53632
  yield { kind: "done", finishReason, suppressCompletion: true };
53637
53633
  continue;