pub enum TokenizationBlock {
ServerUsage {
counts_special_tokens: bool,
counts_prompt_echo: bool,
},
ClientTokenizer {
tokenizer_sha256: String,
counts_special_tokens: bool,
counts_prompt_echo: bool,
},
}Expand description
§4.4.6 — the tokenization block, required in every receipt.
method has no default (PP-11). The variants below make
“client_tokenizer with no digest” unrepresentable rather than merely
rejected, and counts_special_tokens / counts_prompt_echo are plain
non-optional booleans the caller must state.
counts_*underserver_usageis an operator declaration about the server’s counting semantics, not a client measurement — §4.4.6 is titled “Token counting must be declared”. It is required rather than defaulted precisely so it cannot be silently wrong.
Variants§
ServerUsage
Server-reported counts.
Fields
ClientTokenizer
Client-side counts with the model’s own tokenizer.
Implementations§
Source§impl TokenizationBlock
impl TokenizationBlock
Sourcepub fn method(&self) -> TokenCountingMethod
pub fn method(&self) -> TokenCountingMethod
The declared counting method.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
§Errors
When a client_tokenizer digest is not 64 lowercase hex characters.
Sourcepub fn require_counter(&self, has_client_counter: bool) -> Result<(), String>
pub fn require_counter(&self, has_client_counter: bool) -> Result<(), String>
Poka-yoke for transports: a declared method the transport cannot honour is refused at construction, not silently downgraded at measure time.
§Errors
When the declared method and the available counting machinery disagree.
Trait Implementations§
Source§impl Clone for TokenizationBlock
impl Clone for TokenizationBlock
Source§fn clone(&self) -> TokenizationBlock
fn clone(&self) -> TokenizationBlock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TokenizationBlock
impl Debug for TokenizationBlock
Source§impl<'de> Deserialize<'de> for TokenizationBlock
impl<'de> Deserialize<'de> for TokenizationBlock
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>,
impl Eq for TokenizationBlock
Source§impl PartialEq for TokenizationBlock
impl PartialEq for TokenizationBlock
Source§impl Serialize for TokenizationBlock
impl Serialize for TokenizationBlock
impl StructuralPartialEq for TokenizationBlock
Auto Trait Implementations§
impl Freeze for TokenizationBlock
impl RefUnwindSafe for TokenizationBlock
impl Send for TokenizationBlock
impl Sync for TokenizationBlock
impl Unpin for TokenizationBlock
impl UnsafeUnpin for TokenizationBlock
impl UnwindSafe for TokenizationBlock
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> ⓘ
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> ⓘ
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