pub struct GenerationRequest<'controls> { /* private fields */ }Expand description
One bounded generation request and its optional execution controls.
The serializable GenerationPlan remains the durable contract. Pipelines
and observers are borrowed only for the synchronous generation call.
Implementations§
Source§impl<'controls> GenerationRequest<'controls>
impl<'controls> GenerationRequest<'controls>
Sourcepub fn new(max_tokens: u32) -> Result<Self>
pub fn new(max_tokens: u32) -> Result<Self>
Creates a request using the existing default native sampling plan.
§Errors
Returns an error when max_tokens is zero.
Sourcepub fn from_plan(plan: GenerationPlan) -> Result<Self>
pub fn from_plan(plan: GenerationPlan) -> Result<Self>
Creates a request from an exact backend-neutral plan.
§Errors
Returns an error when the plan is invalid.
Sourcepub fn sampling(self, sampling: SamplingPlan) -> Result<Self>
pub fn sampling(self, sampling: SamplingPlan) -> Result<Self>
Replaces the native sampling configuration.
§Errors
Returns an error when the resulting plan is invalid.
Sourcepub fn bias(self, token: TokenId, bias: f32) -> Result<Self>
pub fn bias(self, token: TokenId, bias: f32) -> Result<Self>
Appends one unique finite additive token bias.
§Errors
Returns an error for a duplicate token, non-finite bias, or collection bound violation.
Sourcepub fn grammar(self, grammar: Grammar) -> Result<Self>
pub fn grammar(self, grammar: Grammar) -> Result<Self>
Replaces the optional eager grammar.
§Errors
Returns an error when the grammar or resulting plan is invalid.
Sourcepub fn stop_bytes(self, stop: impl AsRef<[u8]>) -> Result<Self>
pub fn stop_bytes(self, stop: impl AsRef<[u8]>) -> Result<Self>
Appends one exact byte stop suffix.
§Errors
Returns an error when the suffix is empty or oversized, or the stop collection exceeds its public bound.
Sourcepub fn pipeline(self, pipeline: &'controls mut Pipeline) -> Result<Self>
pub fn pipeline(self, pipeline: &'controls mut Pipeline) -> Result<Self>
Attaches one mutable transform pipeline for the synchronous call.
§Errors
Returns an error if a pipeline was already attached.
Sourcepub fn observers(self, observers: &'controls mut ObserverSet) -> Result<Self>
pub fn observers(self, observers: &'controls mut ObserverSet) -> Result<Self>
Attaches one mutable observer set for the synchronous call.
§Errors
Returns an error if an observer set was already attached.
Sourcepub const fn plan(&self) -> &GenerationPlan
pub const fn plan(&self) -> &GenerationPlan
Returns the exact serializable generation plan.