pub struct HeuristicTokenCounter;Expand description
Heuristic token counter that estimates ~4 characters per token.
Trait Implementations§
Source§impl TokenCounter for HeuristicTokenCounter
impl TokenCounter for HeuristicTokenCounter
Source§fn count_text(&self, text: &str) -> usize
fn count_text(&self, text: &str) -> usize
Count the number of tokens in a text string.
Source§fn count_messages(&self, messages: &[Message]) -> usize
fn count_messages(&self, messages: &[Message]) -> usize
Count the total number of tokens in a slice of messages.
Default implementation sums count_text(content) + 4 per message overhead.
Auto Trait Implementations§
impl Freeze for HeuristicTokenCounter
impl RefUnwindSafe for HeuristicTokenCounter
impl Send for HeuristicTokenCounter
impl Sync for HeuristicTokenCounter
impl Unpin for HeuristicTokenCounter
impl UnsafeUnpin for HeuristicTokenCounter
impl UnwindSafe for HeuristicTokenCounter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more