Graphorin API reference v0.15.1
Graphorin API reference / @graphorin/provider / / HeuristicCounter
Class: HeuristicCounter
Defined in: packages/provider/src/counters/heuristic.ts:39
Stable
Counter that estimates tokens via simple character division. The estimator is deterministic and side-effect-free apart from the one-time WARN.
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
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>