Skip to main content

GenerationRequest

Struct GenerationRequest 

Source
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>

Source

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.

Source

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.

Source

pub fn sampling(self, sampling: SamplingPlan) -> Result<Self>

Replaces the native sampling configuration.

§Errors

Returns an error when the resulting plan is invalid.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub const fn plan(&self) -> &GenerationPlan

Returns the exact serializable generation plan.

Auto Trait Implementations§

§

impl<'controls> !RefUnwindSafe for GenerationRequest<'controls>

§

impl<'controls> !Send for GenerationRequest<'controls>

§

impl<'controls> !Sync for GenerationRequest<'controls>

§

impl<'controls> !UnwindSafe for GenerationRequest<'controls>

§

impl<'controls> Freeze for GenerationRequest<'controls>

§

impl<'controls> Unpin for GenerationRequest<'controls>

§

impl<'controls> UnsafeUnpin for GenerationRequest<'controls>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more