billion-context 0.1.71 → 0.1.72-pr.471.286

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
@@ -50241,6 +50241,9 @@ var RENDER_TAG_DETECT = /\x3c\/?acp(?=[\s>])|\\u003c\/?acp(?=[\s>\\])/;
50241
50241
  function containsRenderTagText(s3) {
50242
50242
  return RENDER_TAG_DETECT.test(s3);
50243
50243
  }
50244
+ function mayStartRenderTag(s3) {
50245
+ return RENDER_TAG_DETECT.test(s3) || PARTIAL_TAIL.test(s3);
50246
+ }
50244
50247
  var TOOL_CALL_XML = /\x3c\/?(?:antml:)?(invoke|tool_calls|tool_call|parameter|parameters)\b[^<>]*\x3e|\\u003c\/?(?:antml:)?(invoke|tool_calls|tool_call|parameter|parameters)\b|\x3c\/?antml:[a-z_]+/i;
50245
50248
  function containsToolCallXmlFragment(s3) {
50246
50249
  return TOOL_CALL_XML.test(s3);
@@ -54282,6 +54285,7 @@ data: ${JSON.stringify({ type: "content_block_delta", index, delta: { type: delt
54282
54285
  }
54283
54286
  let rebuilt = null;
54284
54287
  let droppedText = false;
54288
+ let keptText = false;
54285
54289
  let hadText = false;
54286
54290
  for (let ci2 = 0; ci2 < choices.length; ci2++) {
54287
54291
  const ch = choices[ci2];
@@ -54292,10 +54296,14 @@ data: ${JSON.stringify({ type: "content_block_delta", index, delta: { type: delt
54292
54296
  const v2 = dd[field];
54293
54297
  if (typeof v2 !== "string") continue;
54294
54298
  hadText = true;
54295
- if (!containsRenderTagText(v2) && !anyPending()) continue;
54299
+ if (!mayStartRenderTag(v2) && !anyPending()) {
54300
+ if (v2.length > 0) keptText = true;
54301
+ continue;
54302
+ }
54296
54303
  const index = typeof ch?.["index"] === "number" ? ch["index"] : ci2;
54297
54304
  const [clean, changed] = pushField(field, index, v2);
54298
54305
  if (clean.length === 0) droppedText = true;
54306
+ else keptText = true;
54299
54307
  if (changed) {
54300
54308
  if (!rebuilt) {
54301
54309
  rebuilt = { ...ev, choices: choices.map((c) => ({ ...c, delta: { ...c["delta"] } })) };
@@ -54305,7 +54313,7 @@ data: ${JSON.stringify({ type: "content_block_delta", index, delta: { type: delt
54305
54313
  }
54306
54314
  }
54307
54315
  if (rebuilt) {
54308
- if (droppedText && !hadTextOtherThanTextFields(rebuilt["choices"])) {
54316
+ if (droppedText && !keptText && !hadTextOtherThanTextFields(rebuilt["choices"])) {
54309
54317
  return "";
54310
54318
  }
54311
54319
  return rebuildEvent(rawEvent, rebuilt);
@@ -54324,7 +54332,7 @@ data: ${JSON.stringify({ type: "content_block_delta", index, delta: { type: delt
54324
54332
  return rawEvent + "\n\n";
54325
54333
  }
54326
54334
  const raw = d[field];
54327
- if (!containsRenderTagText(raw) && !anyPending()) {
54335
+ if (!mayStartRenderTag(raw) && !anyPending()) {
54328
54336
  return rawEvent + "\n\n";
54329
54337
  }
54330
54338
  const [clean, changed] = pushField(field, index, raw);
@@ -54453,7 +54461,7 @@ async function pipePluginResponsesWithStrip(stream2, res, session, log2) {
54453
54461
  await write(rawEvent + "\n\n");
54454
54462
  continue;
54455
54463
  }
54456
- if (!containsRenderTagText(delta) && !tagFilter.pending()) {
54464
+ if (!mayStartRenderTag(delta) && !tagFilter.pending()) {
54457
54465
  await write(rawEvent + "\n\n");
54458
54466
  continue;
54459
54467
  }