pub struct GenerationOptions { /* private fields */ }Expand description
Tuning parameters for a single generation request.
Values are optional; None uses the model’s built-in default. Numeric
settings are stored as Temperature and MaxTokens so validated
generation semantics cannot be bypassed after construction.
Implementations§
Source§impl GenerationOptions
impl GenerationOptions
Sourcepub fn temperature(self, temperature: Temperature) -> Self
pub fn temperature(self, temperature: Temperature) -> Self
Sets the generation temperature.
Range: 0.0 (fully deterministic) to 2.0 (very creative).
Sourcepub fn with_temperature(self, temperature: Temperature) -> Self
pub fn with_temperature(self, temperature: Temperature) -> Self
Alias for GenerationOptions::temperature.
Sourcepub fn try_temperature(self, temperature: f64) -> Result<Self, Error>
pub fn try_temperature(self, temperature: f64) -> Result<Self, Error>
Parses and sets a generation temperature from a raw boundary value.
Prefer GenerationOptions::temperature when your code already has a
Temperature. Use this at IO boundaries such as CLI, JSON, or UI input.
§Errors
Returns Error::InvalidTemperature when temperature is outside
Apple Intelligence’s supported range.
Sourcepub fn max_tokens(self, max_tokens: MaxTokens) -> Self
pub fn max_tokens(self, max_tokens: MaxTokens) -> Self
Sets the maximum number of response tokens.
The model’s session has a combined context window of 4 096 tokens (instructions + all prompts + all responses). Leaving this unset lets the model decide.
Sourcepub fn with_max_tokens(self, max_tokens: MaxTokens) -> Self
pub fn with_max_tokens(self, max_tokens: MaxTokens) -> Self
Alias for GenerationOptions::max_tokens.
Sourcepub fn try_max_tokens(self, max_tokens: usize) -> Result<Self, Error>
pub fn try_max_tokens(self, max_tokens: usize) -> Result<Self, Error>
Parses and sets a maximum token count from a raw boundary value.
Prefer GenerationOptions::max_tokens when your code already has a
MaxTokens. Use this at IO boundaries such as CLI, JSON, or UI input.
§Errors
Returns Error::InvalidMaxTokens when the value cannot be represented
by the Swift bridge.
Sourcepub fn temperature_value(&self) -> Option<Temperature>
pub fn temperature_value(&self) -> Option<Temperature>
Returns the configured typed temperature, if any.
Sourcepub fn max_tokens_value(&self) -> Option<MaxTokens>
pub fn max_tokens_value(&self) -> Option<MaxTokens>
Returns the configured typed maximum response token count, if any.
Sourcepub fn validate(&self) -> Result<(), Error>
pub fn validate(&self) -> Result<(), Error>
Validates all configured option values.
Values constructed through this type are already validated. This method is kept so generic setup code can verify options before storing them.
§Examples
use aimx::{GenerationOptions, MaxTokens, Temperature};
let options = GenerationOptions::new()
.temperature(Temperature::new(0.4)?)
.max_tokens(MaxTokens::new(128)?);
options.validate()?;§Errors
This method returns errors only if options were constructed through a future boundary path that can carry invalid data.
Trait Implementations§
Source§impl Clone for GenerationOptions
impl Clone for GenerationOptions
Source§fn clone(&self) -> GenerationOptions
fn clone(&self) -> GenerationOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more