Skip to main content

TokenCounter

Trait TokenCounter 

Source
pub trait TokenCounter: Send + Sync {
    // Required method
    fn count_tokens(&self, text: &str) -> usize;
}
Expand description

Abstraction for counting tokens in a string.

Implement this trait to plug in an accurate tokenizer such as tiktoken-rs.

Required Methods§

Source

fn count_tokens(&self, text: &str) -> usize

Implementors§