pub struct TokenEstimationMeta {
pub bytes_per_token_est: f64,
pub bytes_per_token_low: f64,
pub bytes_per_token_high: f64,
pub tokens_min: usize,
pub tokens_est: usize,
pub tokens_max: usize,
pub source_bytes: usize,
}Expand description
Metadata about how token estimates were produced.
Rails are NOT guaranteed bounds — they are heuristic fences. Default divisors: est=4.0, low=3.0 (conservative → more tokens), high=5.0 (optimistic → fewer tokens).
Invariant: tokens_min <= tokens_est <= tokens_max.
Fields§
§bytes_per_token_est: f64Divisor used for main estimate (default 4.0).
bytes_per_token_low: f64Conservative divisor — more tokens (default 3.0).
bytes_per_token_high: f64Optimistic divisor — fewer tokens (default 5.0).
tokens_min: usizetokens = source_bytes / bytes_per_token_high (optimistic, fewest tokens).
tokens_est: usizetokens = source_bytes / bytes_per_token_est.
tokens_max: usizetokens = source_bytes / bytes_per_token_low (conservative, most tokens).
source_bytes: usizeTotal source bytes used to compute estimates.
Implementations§
Source§impl TokenEstimationMeta
impl TokenEstimationMeta
Sourcepub const DEFAULT_BPT_EST: f64 = 4.0
pub const DEFAULT_BPT_EST: f64 = 4.0
Default bytes-per-token divisors.
pub const DEFAULT_BPT_LOW: f64 = 3.0
pub const DEFAULT_BPT_HIGH: f64 = 5.0
Sourcepub fn from_bytes(bytes: usize, bpt: f64) -> Self
pub fn from_bytes(bytes: usize, bpt: f64) -> Self
Create estimation from source byte count using default divisors.
Trait Implementations§
Source§impl Clone for TokenEstimationMeta
impl Clone for TokenEstimationMeta
Source§fn clone(&self) -> TokenEstimationMeta
fn clone(&self) -> TokenEstimationMeta
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TokenEstimationMeta
impl Debug for TokenEstimationMeta
Source§impl<'de> Deserialize<'de> for TokenEstimationMeta
impl<'de> Deserialize<'de> for TokenEstimationMeta
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TokenEstimationMeta
impl RefUnwindSafe for TokenEstimationMeta
impl Send for TokenEstimationMeta
impl Sync for TokenEstimationMeta
impl Unpin for TokenEstimationMeta
impl UnsafeUnpin for TokenEstimationMeta
impl UnwindSafe for TokenEstimationMeta
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