Skip to main content

TokenCounter

Trait TokenCounter 

Source
pub trait TokenCounter {
    // Required methods
    fn count(&self, text: &str) -> usize;
    fn unit(&self) -> &'static str;
}
Expand description

Inject the selected model’s real tokenizer for token-denominated budgets. The built-in ByteCounter is deliberately BYTE-denominated, not chars/4.

Required Methods§

Source

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

Source

fn unit(&self) -> &'static str

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§