Skip to main content

Module tokens

Module tokens 

Source
Expand description

Token estimation utilities

Re-exports from vtcode-commons for backward compatibility.

Constants§

CHARS_PER_TOKEN
Approximate bytes per token used by the byte-length heuristic.

Functions§

estimate_tokens
Count the number of tokens in text using tiktoken BPE.
format_token_count
Format a token count with a compact decimal suffix for transcript labels.
heuristic_tokens_from_byte_len
Approximate token count from a byte length without running the tokenizer.
heuristic_tokens_from_byte_len_u64
u64 twin of heuristic_tokens_from_byte_len for lifetime byte counters that never narrow to usize.
truncate_to_tokens
Truncate text to at most max_tokens tokens.