Graphorin API reference v0.15.1
Graphorin API reference / @graphorin/provider-llamacpp-node / / LlamaCppNativeCounter
Class: LlamaCppNativeCounter
Defined in: src/counter.ts:34
Stable
Counter that delegates to model.tokenize(text) from the loaded GGUF instance. Cache invalidation is keyed on the model file path (when supplied) so swapping models invalidates per-message caches upstream.
Implements
Constructors
Constructor
ts
new LlamaCppNativeCounter(options): LlamaCppNativeCounter;Defined in: src/counter.ts:39
Parameters
| Parameter | Type |
|---|---|
options | LlamaCppNativeCounterOptions |
Returns
LlamaCppNativeCounter
Properties
Methods
count()
ts
count(messages): Promise<number>;Defined in: src/counter.ts:46
Count tokens in a list of Messages (system/user/assistant/tool).
Parameters
| Parameter | Type |
|---|---|
messages | readonly Message[] |
Returns
Promise<number>
Implementation of
countText()
ts
countText(text): Promise<number>;Defined in: src/counter.ts:55
Count tokens in a raw text string.
Parameters
| Parameter | Type |
|---|---|
text | string |
Returns
Promise<number>