Expand description
Token estimation using character-based heuristics.
Uses the chars / 4 rule-of-thumb to estimate token counts without
requiring a tokenizer. The 20,000-token buffer in compaction absorbs
estimation error, and the heuristic is consistent with industry practice.
Functionsยง
- estimate_
content_ part_ tokens - Estimates the token count for a content part.
- estimate_
message_ tokens - Estimates the total token count for a provider
Message. - estimate_
messages_ tokens - Estimates the total token count for a slice of provider
Messages. - estimate_
tokens - Estimates the number of tokens for a string.
- estimate_
tool_ call_ tokens - Estimates the token count for a tool call.