@equationalapplications/core-llm-wiki 9.16.1 → 9.16.2
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/{chunk-7DBDJBN3.mjs → chunk-64ZKSSY6.mjs} +72 -29
- package/dist/{chunk-7DBDJBN3.mjs.map → chunk-64ZKSSY6.mjs.map} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +70 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{testing-C8sYdo2S.d.mts → testing-DNSqIkkv.d.mts} +32 -2
- package/dist/{testing-C8sYdo2S.d.ts → testing-DNSqIkkv.d.ts} +32 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +70 -27
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, W as WikiConfig, R as ReadOptions, c as OntologyConfig, S as SQLiteAdapter, d as WikiOptions, e as WikiMemory } from './testing-
|
|
2
|
-
export { C as CLASSIFIER_MAX_CHOICES, f as CheckpointIncompleteError, g as ChunkFailure, h as ClassifierAnswer, i as ClassifierQuestion, j as ClassifyRequest, k as ClassifyResponse, D as DegradedRecord, l as DraftPage, E as EmbedFactResult, m as EmbedFailureKind, n as EmbeddingMarkerKind, o as EntityMaintenanceReport, p as EntityStatus, q as EraseReport, r as EraseStepError, s as ExtractedFact, t as ExtractedFactEdge, u as ExtractedFactWithOntology, v as ExtractedTask, w as ForgetParams, x as ForgetResult, y as GraphTraversalOptions, z as GroundingConfig, H as HEAL_BATCH_SIZE, A as HEAL_RECHECK_MS, B as HOOK_TIMEOUT_MARKER, I as HealResult, J as ImportDumpResult, K as IngestDocumentResult, L as LLMProvider, N as LibrarianConfig, P as LibrarianGateConfig, Q as LockedMaintenanceJob, T as MaintenanceJob, U as MaintenanceStopReason, V as MemoryDumpEntity, X as MigrationPolicy, Y as ONTOLOGY_ABSTAIN_SENTINEL, Z as ONTOLOGY_BACKFILL_BATCH_SIZE, _ as ONTOLOGY_BACKFILL_RECHECK_MS, $ as OntologyBackfillResult, a0 as OntologyEdgeType, a1 as OntologyManifest, a2 as OntologyNodeType, a3 as OntologyPromptContext, a4 as OntologyUpdates, a5 as PendingMaintenance, a6 as PendingMigrationWork, a7 as PendingSourceStatus, a8 as PromptOverrides, a9 as PromptService, aa as PrunePartialFailureError, ab as ReembedResult, ac as RememberInput, ad as RunPendingMaintenanceOptions, ae as RunPendingMaintenanceResult, af as SourcePassage, ag as StoreSourceResult, ah as StoredSource, ai as StoredSourceDump, aj as StoredSourceSummary, ak as SupersedeReplacement, al as SystemOneConfig, am as SystemOneThresholdSite, an as VectorRanker, ao as VectorRankerFallback, ap as VectorRankerRankArgs, aq as VectorRankerSemanticResult, ar as WikiBusyError, as as WikiBusyOperation, at as WikiCheckpoint, au as WikiDiagnostic, av as WikiDiagnosticCode, aw as WikiDiagnosticDetail, ax as WikiDiagnosticOperation, ay as WikiDiagnosticSeverity, az as WikiDiagnosticTrigger, aA as WikiDraftNotFound, aB as WikiDuplicateHashError, aC as WikiEdge, aD as WikiEvent, aE as WikiExternalDeletionError, aF as WikiFact, aG as WikiGraphNodeOwnershipConflict, aH as WikiIngestEmptyError, aI as WikiInstructions, aJ as WikiInvalidReadOptions, aK as WikiLintReport, aL as WikiMemoryTestAccess, aM as WikiMigrationRequiredError, aN as WikiOutboxEvent, aO as WikiParseError, aP as WikiSearchUnavailableError, aQ as WikiSourcePointer, aR as WikiSourceRefHashCollision, aS as WikiStrictOntologyViolation, aT as WikiSupersedeError, aU as WikiSupersedeReason, aV as WikiTask, aW as WikiTransactionError, aX as WriteOntologyPromptContext, aY as isReservedAbstainSlug, aZ as isWikiSearchUnavailableError, a_ as validateManifest } from './testing-
|
|
1
|
+
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, W as WikiConfig, R as ReadOptions, c as OntologyConfig, S as SQLiteAdapter, d as WikiOptions, e as WikiMemory } from './testing-DNSqIkkv.mjs';
|
|
2
|
+
export { C as CLASSIFIER_MAX_CHOICES, f as CheckpointIncompleteError, g as ChunkFailure, h as ClassifierAnswer, i as ClassifierQuestion, j as ClassifyRequest, k as ClassifyResponse, D as DegradedRecord, l as DraftPage, E as EmbedFactResult, m as EmbedFailureKind, n as EmbeddingMarkerKind, o as EntityMaintenanceReport, p as EntityStatus, q as EraseReport, r as EraseStepError, s as ExtractedFact, t as ExtractedFactEdge, u as ExtractedFactWithOntology, v as ExtractedTask, w as ForgetParams, x as ForgetResult, y as GraphTraversalOptions, z as GroundingConfig, H as HEAL_BATCH_SIZE, A as HEAL_RECHECK_MS, B as HOOK_TIMEOUT_MARKER, I as HealResult, J as ImportDumpResult, K as IngestDocumentResult, L as LLMProvider, N as LibrarianConfig, P as LibrarianGateConfig, Q as LockedMaintenanceJob, T as MaintenanceJob, U as MaintenanceStopReason, V as MemoryDumpEntity, X as MigrationPolicy, Y as ONTOLOGY_ABSTAIN_SENTINEL, Z as ONTOLOGY_BACKFILL_BATCH_SIZE, _ as ONTOLOGY_BACKFILL_RECHECK_MS, $ as OntologyBackfillResult, a0 as OntologyEdgeType, a1 as OntologyManifest, a2 as OntologyNodeType, a3 as OntologyPromptContext, a4 as OntologyUpdates, a5 as PendingMaintenance, a6 as PendingMigrationWork, a7 as PendingSourceStatus, a8 as PromptOverrides, a9 as PromptService, aa as PrunePartialFailureError, ab as ReembedResult, ac as RememberInput, ad as RunPendingMaintenanceOptions, ae as RunPendingMaintenanceResult, af as SourcePassage, ag as StoreSourceResult, ah as StoredSource, ai as StoredSourceDump, aj as StoredSourceSummary, ak as SupersedeReplacement, al as SystemOneConfig, am as SystemOneThresholdSite, an as VectorRanker, ao as VectorRankerFallback, ap as VectorRankerRankArgs, aq as VectorRankerSemanticResult, ar as WikiBusyError, as as WikiBusyOperation, at as WikiCheckpoint, au as WikiDiagnostic, av as WikiDiagnosticCode, aw as WikiDiagnosticDetail, ax as WikiDiagnosticOperation, ay as WikiDiagnosticSeverity, az as WikiDiagnosticTrigger, aA as WikiDraftNotFound, aB as WikiDuplicateHashError, aC as WikiEdge, aD as WikiEvent, aE as WikiExternalDeletionError, aF as WikiFact, aG as WikiGraphNodeOwnershipConflict, aH as WikiIngestEmptyError, aI as WikiInstructions, aJ as WikiInvalidReadOptions, aK as WikiLintReport, aL as WikiMemoryTestAccess, aM as WikiMigrationRequiredError, aN as WikiOutboxEvent, aO as WikiParseError, aP as WikiSearchUnavailableError, aQ as WikiSourcePointer, aR as WikiSourceRefHashCollision, aS as WikiStrictOntologyViolation, aT as WikiSupersedeError, aU as WikiSupersedeReason, aV as WikiTask, aW as WikiTransactionError, aX as WriteOntologyPromptContext, aY as isReservedAbstainSlug, aZ as isWikiSearchUnavailableError, a_ as validateManifest } from './testing-DNSqIkkv.mjs';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, W as WikiConfig, R as ReadOptions, c as OntologyConfig, S as SQLiteAdapter, d as WikiOptions, e as WikiMemory } from './testing-
|
|
2
|
-
export { C as CLASSIFIER_MAX_CHOICES, f as CheckpointIncompleteError, g as ChunkFailure, h as ClassifierAnswer, i as ClassifierQuestion, j as ClassifyRequest, k as ClassifyResponse, D as DegradedRecord, l as DraftPage, E as EmbedFactResult, m as EmbedFailureKind, n as EmbeddingMarkerKind, o as EntityMaintenanceReport, p as EntityStatus, q as EraseReport, r as EraseStepError, s as ExtractedFact, t as ExtractedFactEdge, u as ExtractedFactWithOntology, v as ExtractedTask, w as ForgetParams, x as ForgetResult, y as GraphTraversalOptions, z as GroundingConfig, H as HEAL_BATCH_SIZE, A as HEAL_RECHECK_MS, B as HOOK_TIMEOUT_MARKER, I as HealResult, J as ImportDumpResult, K as IngestDocumentResult, L as LLMProvider, N as LibrarianConfig, P as LibrarianGateConfig, Q as LockedMaintenanceJob, T as MaintenanceJob, U as MaintenanceStopReason, V as MemoryDumpEntity, X as MigrationPolicy, Y as ONTOLOGY_ABSTAIN_SENTINEL, Z as ONTOLOGY_BACKFILL_BATCH_SIZE, _ as ONTOLOGY_BACKFILL_RECHECK_MS, $ as OntologyBackfillResult, a0 as OntologyEdgeType, a1 as OntologyManifest, a2 as OntologyNodeType, a3 as OntologyPromptContext, a4 as OntologyUpdates, a5 as PendingMaintenance, a6 as PendingMigrationWork, a7 as PendingSourceStatus, a8 as PromptOverrides, a9 as PromptService, aa as PrunePartialFailureError, ab as ReembedResult, ac as RememberInput, ad as RunPendingMaintenanceOptions, ae as RunPendingMaintenanceResult, af as SourcePassage, ag as StoreSourceResult, ah as StoredSource, ai as StoredSourceDump, aj as StoredSourceSummary, ak as SupersedeReplacement, al as SystemOneConfig, am as SystemOneThresholdSite, an as VectorRanker, ao as VectorRankerFallback, ap as VectorRankerRankArgs, aq as VectorRankerSemanticResult, ar as WikiBusyError, as as WikiBusyOperation, at as WikiCheckpoint, au as WikiDiagnostic, av as WikiDiagnosticCode, aw as WikiDiagnosticDetail, ax as WikiDiagnosticOperation, ay as WikiDiagnosticSeverity, az as WikiDiagnosticTrigger, aA as WikiDraftNotFound, aB as WikiDuplicateHashError, aC as WikiEdge, aD as WikiEvent, aE as WikiExternalDeletionError, aF as WikiFact, aG as WikiGraphNodeOwnershipConflict, aH as WikiIngestEmptyError, aI as WikiInstructions, aJ as WikiInvalidReadOptions, aK as WikiLintReport, aL as WikiMemoryTestAccess, aM as WikiMigrationRequiredError, aN as WikiOutboxEvent, aO as WikiParseError, aP as WikiSearchUnavailableError, aQ as WikiSourcePointer, aR as WikiSourceRefHashCollision, aS as WikiStrictOntologyViolation, aT as WikiSupersedeError, aU as WikiSupersedeReason, aV as WikiTask, aW as WikiTransactionError, aX as WriteOntologyPromptContext, aY as isReservedAbstainSlug, aZ as isWikiSearchUnavailableError, a_ as validateManifest } from './testing-
|
|
1
|
+
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, W as WikiConfig, R as ReadOptions, c as OntologyConfig, S as SQLiteAdapter, d as WikiOptions, e as WikiMemory } from './testing-DNSqIkkv.js';
|
|
2
|
+
export { C as CLASSIFIER_MAX_CHOICES, f as CheckpointIncompleteError, g as ChunkFailure, h as ClassifierAnswer, i as ClassifierQuestion, j as ClassifyRequest, k as ClassifyResponse, D as DegradedRecord, l as DraftPage, E as EmbedFactResult, m as EmbedFailureKind, n as EmbeddingMarkerKind, o as EntityMaintenanceReport, p as EntityStatus, q as EraseReport, r as EraseStepError, s as ExtractedFact, t as ExtractedFactEdge, u as ExtractedFactWithOntology, v as ExtractedTask, w as ForgetParams, x as ForgetResult, y as GraphTraversalOptions, z as GroundingConfig, H as HEAL_BATCH_SIZE, A as HEAL_RECHECK_MS, B as HOOK_TIMEOUT_MARKER, I as HealResult, J as ImportDumpResult, K as IngestDocumentResult, L as LLMProvider, N as LibrarianConfig, P as LibrarianGateConfig, Q as LockedMaintenanceJob, T as MaintenanceJob, U as MaintenanceStopReason, V as MemoryDumpEntity, X as MigrationPolicy, Y as ONTOLOGY_ABSTAIN_SENTINEL, Z as ONTOLOGY_BACKFILL_BATCH_SIZE, _ as ONTOLOGY_BACKFILL_RECHECK_MS, $ as OntologyBackfillResult, a0 as OntologyEdgeType, a1 as OntologyManifest, a2 as OntologyNodeType, a3 as OntologyPromptContext, a4 as OntologyUpdates, a5 as PendingMaintenance, a6 as PendingMigrationWork, a7 as PendingSourceStatus, a8 as PromptOverrides, a9 as PromptService, aa as PrunePartialFailureError, ab as ReembedResult, ac as RememberInput, ad as RunPendingMaintenanceOptions, ae as RunPendingMaintenanceResult, af as SourcePassage, ag as StoreSourceResult, ah as StoredSource, ai as StoredSourceDump, aj as StoredSourceSummary, ak as SupersedeReplacement, al as SystemOneConfig, am as SystemOneThresholdSite, an as VectorRanker, ao as VectorRankerFallback, ap as VectorRankerRankArgs, aq as VectorRankerSemanticResult, ar as WikiBusyError, as as WikiBusyOperation, at as WikiCheckpoint, au as WikiDiagnostic, av as WikiDiagnosticCode, aw as WikiDiagnosticDetail, ax as WikiDiagnosticOperation, ay as WikiDiagnosticSeverity, az as WikiDiagnosticTrigger, aA as WikiDraftNotFound, aB as WikiDuplicateHashError, aC as WikiEdge, aD as WikiEvent, aE as WikiExternalDeletionError, aF as WikiFact, aG as WikiGraphNodeOwnershipConflict, aH as WikiIngestEmptyError, aI as WikiInstructions, aJ as WikiInvalidReadOptions, aK as WikiLintReport, aL as WikiMemoryTestAccess, aM as WikiMigrationRequiredError, aN as WikiOutboxEvent, aO as WikiParseError, aP as WikiSearchUnavailableError, aQ as WikiSourcePointer, aR as WikiSourceRefHashCollision, aS as WikiStrictOntologyViolation, aT as WikiSupersedeError, aU as WikiSupersedeReason, aV as WikiTask, aW as WikiTransactionError, aX as WriteOntologyPromptContext, aY as isReservedAbstainSlug, aZ as isWikiSearchUnavailableError, a_ as validateManifest } from './testing-DNSqIkkv.js';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -557,13 +557,19 @@ var UsageMeter = class {
|
|
|
557
557
|
constructor(budget) {
|
|
558
558
|
this.used = 0;
|
|
559
559
|
this.estimated = false;
|
|
560
|
+
this.heldTokens = 0;
|
|
560
561
|
if (budget !== void 0 && (typeof budget !== "number" || !Number.isFinite(budget) || budget < 0)) {
|
|
561
562
|
throw new TypeError("tokenBudget must be a finite number >= 0");
|
|
562
563
|
}
|
|
563
564
|
this.budget = budget;
|
|
564
565
|
}
|
|
566
|
+
/** Tokens held by in-flight reservations. */
|
|
567
|
+
get reserved() {
|
|
568
|
+
return this.heldTokens;
|
|
569
|
+
}
|
|
570
|
+
/** budget - used - reserved, clamped at 0; Infinity when unbounded. */
|
|
565
571
|
get remaining() {
|
|
566
|
-
return this.budget === void 0 ? Infinity : Math.max(0, this.budget - this.used);
|
|
572
|
+
return this.budget === void 0 ? Infinity : Math.max(0, this.budget - this.used - this.heldTokens);
|
|
567
573
|
}
|
|
568
574
|
fits(estimate) {
|
|
569
575
|
return estimate <= this.remaining;
|
|
@@ -572,6 +578,33 @@ var UsageMeter = class {
|
|
|
572
578
|
this.used += r.inputTokens + r.outputTokens;
|
|
573
579
|
if (r.estimated) this.estimated = true;
|
|
574
580
|
}
|
|
581
|
+
/**
|
|
582
|
+
* Admit a call on `estimate` (throws WikiBudgetExhausted when it does not
|
|
583
|
+
* fit the unreserved remainder) and hold `max(estimate, hold)` tokens until
|
|
584
|
+
* settle/release.
|
|
585
|
+
*/
|
|
586
|
+
reserve(estimate, hold) {
|
|
587
|
+
if (!this.fits(estimate)) throw new WikiBudgetExhausted(estimate, this.remaining);
|
|
588
|
+
const handle = { _brand: "UsageReservation", hold: Math.max(estimate, hold ?? estimate), open: true };
|
|
589
|
+
this.heldTokens += handle.hold;
|
|
590
|
+
return handle;
|
|
591
|
+
}
|
|
592
|
+
/** Free the hold, then charge the real usage. A closed handle is a no-op. */
|
|
593
|
+
settle(handle, actual) {
|
|
594
|
+
if (!this.close(handle)) return;
|
|
595
|
+
this.record(actual);
|
|
596
|
+
}
|
|
597
|
+
/** Free the hold and charge nothing. A closed handle is a no-op. */
|
|
598
|
+
release(handle) {
|
|
599
|
+
this.close(handle);
|
|
600
|
+
}
|
|
601
|
+
close(handle) {
|
|
602
|
+
const h = handle;
|
|
603
|
+
if (!h.open) return false;
|
|
604
|
+
h.open = false;
|
|
605
|
+
this.heldTokens -= h.hold;
|
|
606
|
+
return true;
|
|
607
|
+
}
|
|
575
608
|
};
|
|
576
609
|
var WikiBudgetExhausted = class _WikiBudgetExhausted extends Error {
|
|
577
610
|
constructor(requiredEstimate, remaining) {
|
|
@@ -584,6 +617,7 @@ var WikiBudgetExhausted = class _WikiBudgetExhausted extends Error {
|
|
|
584
617
|
};
|
|
585
618
|
|
|
586
619
|
// src/utils/llmCall.ts
|
|
620
|
+
var CLASSIFY_HOLD_FACTOR = 2;
|
|
587
621
|
function validUsage(u) {
|
|
588
622
|
if (!u || typeof u !== "object") return false;
|
|
589
623
|
const { inputTokens, outputTokens } = u;
|
|
@@ -591,25 +625,29 @@ function validUsage(u) {
|
|
|
591
625
|
}
|
|
592
626
|
async function callLlm(options, ctx, prompts) {
|
|
593
627
|
const promptEstimate = estimateTokens(prompts.systemPrompt) + estimateTokens(prompts.userPrompt);
|
|
594
|
-
if (ctx.meter && !ctx.meter.fits(promptEstimate)) {
|
|
595
|
-
throw new WikiBudgetExhausted(promptEstimate, ctx.meter.remaining);
|
|
596
|
-
}
|
|
597
628
|
const provider = options.llmProvider;
|
|
598
629
|
const params = { systemPrompt: prompts.systemPrompt, userPrompt: prompts.userPrompt };
|
|
599
630
|
let text;
|
|
600
|
-
let
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
631
|
+
let record;
|
|
632
|
+
const reservation = ctx.meter?.reserve(promptEstimate);
|
|
633
|
+
try {
|
|
634
|
+
let reported;
|
|
635
|
+
if (typeof provider.generateTextWithUsage === "function") {
|
|
636
|
+
const result = await provider.generateTextWithUsage(params);
|
|
637
|
+
if (!result || typeof result.text !== "string") {
|
|
638
|
+
throw new TypeError("generateTextWithUsage() must resolve to { text: string, usage? }");
|
|
639
|
+
}
|
|
640
|
+
text = result.text;
|
|
641
|
+
reported = validUsage(result.usage) ? result.usage : void 0;
|
|
642
|
+
} else {
|
|
643
|
+
text = await provider.generateText(params);
|
|
644
|
+
}
|
|
645
|
+
record = reported ? { inputTokens: reported.inputTokens, outputTokens: reported.outputTokens, estimated: false } : { inputTokens: promptEstimate, outputTokens: estimateTokens(text), estimated: true };
|
|
646
|
+
} catch (err) {
|
|
647
|
+
if (ctx.meter && reservation) ctx.meter.release(reservation);
|
|
648
|
+
throw err;
|
|
610
649
|
}
|
|
611
|
-
|
|
612
|
-
ctx.meter?.record(record);
|
|
650
|
+
if (ctx.meter && reservation) ctx.meter.settle(reservation, record);
|
|
613
651
|
if (options.config?.reportLlmUsage === true) {
|
|
614
652
|
emitDiagnostic(options, {
|
|
615
653
|
code: "llm_usage",
|
|
@@ -623,18 +661,23 @@ async function callLlm(options, ctx, prompts) {
|
|
|
623
661
|
}
|
|
624
662
|
async function callClassify(options, ctx, request) {
|
|
625
663
|
const inputEstimate = estimateTokens(request.state) + estimateTokens(JSON.stringify(request.questions));
|
|
626
|
-
if (ctx.meter && !ctx.meter.fits(inputEstimate)) {
|
|
627
|
-
throw new WikiBudgetExhausted(inputEstimate, ctx.meter.remaining);
|
|
628
|
-
}
|
|
629
664
|
const provider = options.llmProvider;
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
665
|
+
let response;
|
|
666
|
+
let record;
|
|
667
|
+
const reservation = ctx.meter?.reserve(inputEstimate, inputEstimate * CLASSIFY_HOLD_FACTOR);
|
|
668
|
+
try {
|
|
669
|
+
if (typeof provider.classify !== "function") {
|
|
670
|
+
throw new TypeError("callClassify requires a provider with classify()");
|
|
671
|
+
}
|
|
672
|
+
response = await provider.classify(request);
|
|
673
|
+
const reported = validUsage(response?.usage) ? response.usage : void 0;
|
|
674
|
+
const outputEstimate = estimateTokens(JSON.stringify(response?.answers ?? {}));
|
|
675
|
+
record = reported ? { inputTokens: reported.inputTokens, outputTokens: reported.outputTokens, estimated: false } : { inputTokens: inputEstimate, outputTokens: outputEstimate, estimated: true };
|
|
676
|
+
} catch (err) {
|
|
677
|
+
if (ctx.meter && reservation) ctx.meter.release(reservation);
|
|
678
|
+
throw err;
|
|
679
|
+
}
|
|
680
|
+
if (ctx.meter && reservation) ctx.meter.settle(reservation, record);
|
|
638
681
|
if (options.config?.reportLlmUsage === true) {
|
|
639
682
|
emitDiagnostic(options, {
|
|
640
683
|
code: "llm_usage",
|