pub enum GrammarStart {
Unknown,
AfterReasoning,
FirstToken,
}Expand description
Where the engine that runs a forced call’s grammar starts applying it on a
prompt that ends inside the model’s thinking block, as its worker
advertises it (the constrained_decoding_start label).
An engine’s own server picks the grammar’s shape from this: it sends
xgrammar’s reasoning-aware tags (the thought, its close, then the calls)
when it runs no reasoning parser and the bare calls when it does, because
its grammar backend then waits for the thought’s end; an engine with a
reasoning parser set (and enable_in_reasoning off) waits the same way.
The gateway reads the same fact from the worker and shapes the calls’
prefix accordingly.
Variants§
Unknown
The worker does not say (an older servicer, an engine without the label): free text with nothing owed at its end precedes the calls, which fits an engine of either kind.
AfterReasoning
The engine applies the grammar only once its reasoning parser has
seen the model’s own </think>: nothing precedes the calls, so the
call is forced right at that gate, as the engine’s own server does.
FirstToken
The engine applies the grammar from the first generated token: the thought, its close and then the calls, so the call is not forced into the thought.
Implementations§
Source§impl GrammarStart
impl GrammarStart
Sourcepub const AFTER_REASONING: &'static str = "after_reasoning"
pub const AFTER_REASONING: &'static str = "after_reasoning"
The label’s value for Self::AfterReasoning.
Sourcepub const FIRST_TOKEN: &'static str = "first_token"
pub const FIRST_TOKEN: &'static str = "first_token"
The label’s value for Self::FirstToken.
Sourcepub fn from_label(value: Option<&str>) -> Self
pub fn from_label(value: Option<&str>) -> Self
The start a worker’s constrained_decoding_start label names; anything
else, the label’s absence included, is Self::Unknown.
Trait Implementations§
Source§impl Clone for GrammarStart
impl Clone for GrammarStart
impl Copy for GrammarStart
Source§impl Debug for GrammarStart
impl Debug for GrammarStart
Source§impl Default for GrammarStart
impl Default for GrammarStart
impl Eq for GrammarStart
Source§impl PartialEq for GrammarStart
impl PartialEq for GrammarStart
impl StructuralPartialEq for GrammarStart
Auto Trait Implementations§
impl Freeze for GrammarStart
impl RefUnwindSafe for GrammarStart
impl Send for GrammarStart
impl Sync for GrammarStart
impl Unpin for GrammarStart
impl UnsafeUnpin for GrammarStart
impl UnwindSafe for GrammarStart
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,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> ⓘ
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