Skip to main content

TokenCounter

Trait TokenCounter 

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

Trait defining the interface for tokenizers

Required Methods§

Source

fn count_tokens(&self, text: &str) -> TokenizerResult<TokenCount>

Count tokens in the given text

Source

fn model_context_window(&self) -> usize

Get the context window size for this model

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§