Skip to main content

TokenEstimator

Trait TokenEstimator 

Source
pub trait TokenEstimator {
    // Required methods
    fn info(&self) -> EstimatorInfo;
    fn count_bytes(&self, bytes: &[u8]) -> usize;
}

Required Methods§

Source

fn info(&self) -> EstimatorInfo

Estimator provenance for CompressionReport.estimator.

Source

fn count_bytes(&self, bytes: &[u8]) -> usize

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl TokenEstimator for ByteHeuristicEstimator

Source§

impl TokenEstimator for TiktokenEstimator

Available on crate feature tiktoken only.