TokenEstimator
Protocol for records that can estimate their own token count. Implement this on your record type and the TokenBatcher will call it automatically when no explicit estimated_tokens is passed to TokenBatcher.submit.
Methods
estimate_tokens()
@classmethod
def estimate_tokens() - > int
Calculates an approximate count of tokens for the record to assist with batching and rate-limiting logic.
Returns
| Type | Description |
|---|---|
int | The estimated number of tokens contained within the record instance. |