Skip to content

Graphorin API reference v0.1.0


Graphorin API reference / @graphorin/provider / / HeuristicCounter

Class: HeuristicCounter

Defined in: packages/provider/src/counters/heuristic.ts:39

Counter that estimates tokens via simple character division. The estimator is deterministic and side-effect-free apart from the one-time WARN.

Stable

Implements

Constructors

Constructor

ts
new HeuristicCounter(options?): HeuristicCounter;

Defined in: packages/provider/src/counters/heuristic.ts:47

Parameters

ParameterType
optionsHeuristicCounterOptions

Returns

HeuristicCounter

Properties

PropertyModifierTypeDescriptionDefined in
idreadonlystringHuman-readable identifier ('js-tiktoken@cl100k_base', …).packages/provider/src/counters/heuristic.ts:40
versionreadonlystringTokenizer version string used for cache invalidation.packages/provider/src/counters/heuristic.ts:41

Methods

count()

ts
count(messages): Promise<number>;

Defined in: packages/provider/src/counters/heuristic.ts:59

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: packages/provider/src/counters/heuristic.ts:69

Count tokens in a raw text string.

Parameters

ParameterType
textstring

Returns

Promise&lt;number&gt;

Implementation of

TokenCounter.countText