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
| Parameter | Type |
|---|---|
options | HeuristicCounterOptions |
Returns
HeuristicCounter
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
id | readonly | string | Human-readable identifier ('js-tiktoken@cl100k_base', …). | packages/provider/src/counters/heuristic.ts:40 |
version | readonly | string | Tokenizer 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
| Parameter | Type |
|---|---|
messages | readonly Message[] |
Returns
Promise<number>
Implementation of
countText()
ts
countText(text): Promise<number>;Defined in: packages/provider/src/counters/heuristic.ts:69
Count tokens in a raw text string.
Parameters
| Parameter | Type |
|---|---|
text | string |
Returns
Promise<number>