Skip to content

Graphorin API reference v0.1.0


Graphorin API reference / @graphorin/memory / / allocateTokenBudget

Function: allocateTokenBudget()

ts
function allocateTokenBudget(
   layers, 
   budgetTokens, 
   counter, 
options?): Promise<AllocationResult>;

Defined in: packages/memory/src/context-engine/token-budget.ts:153

Run the allocator. Layers are sorted by priority ascending (the first layer is the highest priority); when the running total exceeds the budget, lower-priority layers are first capped at their per-layer cap (when set) and finally truncated to whatever fits.

Parameters

ParameterType
layersreadonly LayerCandidate[]
budgetTokensnumber
counterContextTokenCounter
options{ overflowMode?: OverflowMode; priority?: readonly LayerId[]; }
options.overflowMode?OverflowMode
options.priority?readonly LayerId[]

Returns

Promise&lt;AllocationResult&gt;

Stable