pub struct TiktokenCounter { /* private fields */ }Expand description
Tiktoken counter (uses cl100k_base, for GPT-3.5 / 4 / 4o)
Implementations§
Source§impl TiktokenCounter
impl TiktokenCounter
Sourcepub fn new() -> Result<Self, TokenCounterError>
pub fn new() -> Result<Self, TokenCounterError>
Creates a Tiktoken counter (loads the cl100k_base BPE encoder).
Trait Implementations§
Source§impl TokenCounter for TiktokenCounter
impl TokenCounter for TiktokenCounter
Source§fn count_tokens(&self, text: &str) -> u32
fn count_tokens(&self, text: &str) -> u32
Counts tokens in a text
Source§fn count_messages(&self, messages: &[Message]) -> u32
fn count_messages(&self, messages: &[Message]) -> u32
Counts tokens in a message list
Auto Trait Implementations§
impl Freeze for TiktokenCounter
impl RefUnwindSafe for TiktokenCounter
impl Send for TiktokenCounter
impl Sync for TiktokenCounter
impl Unpin for TiktokenCounter
impl UnsafeUnpin for TiktokenCounter
impl UnwindSafe for TiktokenCounter
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