Graphorin API reference v0.1.0
Graphorin API reference / @graphorin/provider-llamacpp-node / LlamaCppNativeCounter
Class: LlamaCppNativeCounter
Defined in: counter.ts:34
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.
Stable
Implements
Constructors
Constructor
ts
new LlamaCppNativeCounter(options): LlamaCppNativeCounter;Defined in: counter.ts:39
Parameters
| Parameter | Type |
|---|---|
options | LlamaCppNativeCounterOptions |
Returns
LlamaCppNativeCounter
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
id | readonly | string | Human-readable identifier ('js-tiktoken@cl100k_base', …). | counter.ts:35 |
version | readonly | string | Tokenizer version string used for cache invalidation. | counter.ts:36 |
Methods
count()
ts
count(messages): Promise<number>;Defined in: 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: counter.ts:55
Count tokens in a raw text string.
Parameters
| Parameter | Type |
|---|---|
text | string |
Returns
Promise<number>