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§
Sourcefn count_tokens(&self, text: &str) -> TokenizerResult<TokenCount>
fn count_tokens(&self, text: &str) -> TokenizerResult<TokenCount>
Count tokens in the given text
Sourcefn model_context_window(&self) -> usize
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".