pub struct FallbackEstimator { /* private fields */ }Expand description
spc_011-C-01: real-BPE-backed counter, the production default. CharApproxCounter’s
char/4 divisor only holds for English text — on CJK-heavy text it underestimates real BPE
counts by 40-70% (its own doc comment claims “~0.5 tokens/char” for CJK, but the
implementation applies the same 0.25 tokens/char divisor to every script). This wraps
deepstrike-tokenizer’s real cl100k BPE tokenizer (previously an orphaned crate — not a
workspace member, zero call sites anywhere) and adds a fixed margin on top. That only
guarantees a value above the selected cl100k_base estimate; it does not prove that the
result is conservative for every provider model. Native Anthropic/Gemini token counts take
precedence where callers explicitly request them.
Implementations§
Source§impl FallbackEstimator
impl FallbackEstimator
pub fn new(backend: TokenizerBackend, safety_margin: f64) -> Self
Trait Implementations§
Source§impl Default for FallbackEstimator
impl Default for FallbackEstimator
Source§impl TokenCounter for FallbackEstimator
impl TokenCounter for FallbackEstimator
Auto Trait Implementations§
impl Freeze for FallbackEstimator
impl RefUnwindSafe for FallbackEstimator
impl Send for FallbackEstimator
impl Sync for FallbackEstimator
impl Unpin for FallbackEstimator
impl UnsafeUnpin for FallbackEstimator
impl UnwindSafe for FallbackEstimator
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