GenerationOptionsBuilder

Struct GenerationOptionsBuilder 

Source
pub struct GenerationOptionsBuilder { /* private fields */ }
Expand description

Builder for configuring GenerationOptions.

Implementations§

Source§

impl GenerationOptionsBuilder

Source

pub fn temperature(self, temp: f64) -> Self

Sets the temperature for generation.

Temperature influences the confidence of the model’s response. Higher values (e.g., 1.5) produce more random outputs. Lower values (e.g., 0.2) produce more deterministic outputs.

Valid range: 0.0 to 2.0. Values outside this range are ignored and the default temperature is used instead.

Source

pub fn try_temperature(self, temp: f64) -> Result<Self, Error>

Sets the temperature, returning an error if out of range.

This is the fallible version of temperature. Use this when you want to catch invalid temperature values at build time.

§Errors

Returns an error if temp is not in the range 0.0 to 2.0.

Source

pub fn sampling(self, sampling: Sampling) -> Self

Sets the sampling strategy.

Source

pub fn max_response_tokens(self, tokens: u32) -> Self

Sets the maximum number of tokens in the response.

Only use this when you need to protect against unexpectedly verbose responses. Enforcing a strict token limit can lead to malformed or grammatically incorrect output.

Source

pub fn seed(self, seed: u64) -> Self

Sets the random seed for reproducible generation.

Note: This is currently not supported by Apple’s GenerationOptions API and will be ignored. Included for potential future use.

Source

pub fn build(self) -> GenerationOptions

Builds the GenerationOptions.

Trait Implementations§

Source§

impl Debug for GenerationOptionsBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GenerationOptionsBuilder

Source§

fn default() -> GenerationOptionsBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.