@equationalapplications/core-llm-wiki 9.5.2 → 9.5.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/dist/index.js CHANGED
@@ -9857,15 +9857,29 @@ function mergeOutcomes(a, b) {
9857
9857
  taskItems: a.taskItems + b.taskItems
9858
9858
  };
9859
9859
  }
9860
- async function extractWithOverflowRetry(deps, ctx, ontologyContext, batch) {
9860
+ async function extractWithOverflowRetry(deps, ctx, ontologyContext, batch, probe) {
9861
9861
  try {
9862
9862
  return await extractOnce(deps, ctx, ontologyContext, batch);
9863
9863
  } catch (err) {
9864
9864
  if (!isContextOverflowError(err)) throw err;
9865
+ if (!probe.checked) {
9866
+ probe.checked = true;
9867
+ const probePrompt = deps.promptService.buildOpsExtractPrompt(
9868
+ [{ ...batch[0], event: { ...batch[0].event, summary: "x" } }],
9869
+ ontologyContext,
9870
+ ctx.guidance
9871
+ );
9872
+ try {
9873
+ await callLlm(deps.options, { operation: "librarian", entityId: ctx.entityId, trigger: ctx.trigger, meter: ctx.meter }, probePrompt);
9874
+ } catch (e) {
9875
+ if (!isContextOverflowError(e)) throw e;
9876
+ throw new Error("ops extract: minimal-prompt probe also overflowed (fixed prompt part exceeds the model window?)");
9877
+ }
9878
+ }
9865
9879
  if (batch.length > 1) {
9866
9880
  const mid = Math.ceil(batch.length / 2);
9867
- const a = await extractWithOverflowRetry(deps, ctx, ontologyContext, batch.slice(0, mid));
9868
- const b = await extractWithOverflowRetry(deps, ctx, ontologyContext, batch.slice(mid));
9881
+ const a = await extractWithOverflowRetry(deps, ctx, ontologyContext, batch.slice(0, mid), probe);
9882
+ const b = await extractWithOverflowRetry(deps, ctx, ontologyContext, batch.slice(mid), probe);
9869
9883
  return mergeOutcomes(a, b);
9870
9884
  }
9871
9885
  const lone = batch[0];
@@ -9917,21 +9931,7 @@ async function extractWithOverflowRetry(deps, ctx, ontologyContext, batch) {
9917
9931
  }
9918
9932
  async function runExtract(deps, ctx, batch) {
9919
9933
  const ontologyContext = await deps.ontologyService?.buildPromptContext(ctx.entityId) ?? null;
9920
- const out = await extractWithOverflowRetry(deps, ctx, ontologyContext, batch);
9921
- if (out.skippedEvents > 0 && out.skippedEvents === out.batch.length) {
9922
- const probe = deps.promptService.buildOpsExtractPrompt(
9923
- [{ ...batch[0], event: { ...batch[0].event, summary: "x" } }],
9924
- ontologyContext,
9925
- ctx.guidance
9926
- );
9927
- try {
9928
- await callLlm(deps.options, { operation: "librarian", entityId: ctx.entityId, trigger: ctx.trigger, meter: void 0 }, probe);
9929
- } catch (e) {
9930
- if (!isContextOverflowError(e)) throw e;
9931
- throw new Error(`ops extract: all ${out.skippedEvents} selected events were skipped for context overflow and a minimal probe also overflowed (fixed prompt part exceeds the model window?)`);
9932
- }
9933
- }
9934
- return out;
9934
+ return extractWithOverflowRetry(deps, ctx, ontologyContext, batch, { checked: false });
9935
9935
  }
9936
9936
  async function extractOnce(deps, ctx, ontologyContext, batch) {
9937
9937
  const { entityId, trigger } = ctx;