pub struct TokenCounter { /* private fields */ }Implementations§
Source§impl TokenCounter
impl TokenCounter
pub fn new() -> Result<Self>
pub fn from_model(model_name: &str) -> Result<Self>
pub fn model_name(&self) -> &str
pub fn count_tokens(&self, content: &str) -> usize
pub fn count_tokens_parallel<'a, I>(&self, contents: I) -> Vec<usize>where
I: ParallelIterator<Item = &'a str>,
pub fn analyze_batch<'a, I>(&self, contents: I) -> (usize, f64)where
I: ParallelIterator<Item = &'a str>,
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TokenCounter
impl RefUnwindSafe for TokenCounter
impl Send for TokenCounter
impl Sync for TokenCounter
impl Unpin for TokenCounter
impl UnwindSafe for TokenCounter
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more