pub trait TokenCounter: WasmCompatSend + WasmCompatSync {
// Required method
fn count(&self, message: &Message) -> usize;
}Expand description
Counts the tokens contributed by a single Message.
Implementors should pick a counting strategy appropriate for their target
provider (for example, tiktoken-rs for OpenAI). Counting must be cheap;
it runs once per message on every memory load.
Required Methods§
Trait Implementations§
Source§impl TokenCounter for Box<dyn TokenCounter>
impl TokenCounter for Box<dyn TokenCounter>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".