pub struct TiktokenTokenizer { /* private fields */ }Expand description
OpenAI tiktoken-based tokenizer.
Supports cl100k_base (GPT-4) and o200k_base (GPT-4o) encodings.
Implementations§
Source§impl TiktokenTokenizer
impl TiktokenTokenizer
Sourcepub fn cl100k() -> Result<Self>
pub fn cl100k() -> Result<Self>
Create cl100k_base tokenizer (GPT-3.5, GPT-4).
§Errors
Returns error if tokenizer initialization fails.
Sourcepub fn o200k() -> Result<Self>
pub fn o200k() -> Result<Self>
Create o200k_base tokenizer (GPT-4o, o1, o3).
§Errors
Returns error if tokenizer initialization fails.
Sourcepub fn from_type(tokenizer_type: TokenizerType) -> Result<Self>
pub fn from_type(tokenizer_type: TokenizerType) -> Result<Self>
Create tokenizer from type.
§Errors
Returns error if tokenizer initialization fails or type is not tiktoken-based.
Trait Implementations§
Source§impl HydraTokenizer for TiktokenTokenizer
impl HydraTokenizer for TiktokenTokenizer
Auto Trait Implementations§
impl Freeze for TiktokenTokenizer
impl RefUnwindSafe for TiktokenTokenizer
impl Send for TiktokenTokenizer
impl Sync for TiktokenTokenizer
impl Unpin for TiktokenTokenizer
impl UnwindSafe for TiktokenTokenizer
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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