Skip to content

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

ParameterType
optionsLlamaCppNativeCounterOptions

Returns

LlamaCppNativeCounter

Properties

PropertyModifierTypeDescriptionDefined in
idreadonlystringHuman-readable identifier ('js-tiktoken@cl100k_base', …).counter.ts:35
versionreadonlystringTokenizer 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

ParameterType
messagesreadonly Message[]

Returns

Promise&lt;number&gt;

Implementation of

TokenCounter.count


countText()

ts
countText(text): Promise<number>;

Defined in: counter.ts:55

Count tokens in a raw text string.

Parameters

ParameterType
textstring

Returns

Promise&lt;number&gt;

Implementation of

TokenCounter.countText