pub struct AppleIntelligenceModels { /* private fields */ }Expand description
Handle for Apple’s default on-device system language model.
Implementations§
Source§impl AppleIntelligenceModels
impl AppleIntelligenceModels
Sourcepub fn availability(&self) -> Result<(), AvailabilityError>
pub fn availability(&self) -> Result<(), AvailabilityError>
Returns Ok(()) when Apple Intelligence is ready for this model.
This mirrors Swift’s SystemLanguageModel.default.availability shape,
but maps unavailable states into AvailabilityError.
§Errors
Returns AvailabilityError describing why the local model cannot be
used on the current machine.
Sourcepub fn is_available(&self) -> bool
pub fn is_available(&self) -> bool
Returns true when the default system language model is available.
Sourcepub fn session(&self) -> LanguageModelSessionBuilder
pub fn session(&self) -> LanguageModelSessionBuilder
Starts building a stateful session.
Sourcepub fn agent(&self) -> LanguageModelSessionBuilder
pub fn agent(&self) -> LanguageModelSessionBuilder
Alias for AppleIntelligenceModels::session for users coming from Rig’s agent builders.
Sourcepub async fn respond<P>(&self, prompt: P) -> Result<String, Error>
pub async fn respond<P>(&self, prompt: P) -> Result<String, Error>
Sends a single prompt in a fresh session and returns plain response text.
§Errors
Returns Error::NullByte for prompt text that cannot cross the C FFI
boundary, Error::Unavailable when Apple Intelligence is unavailable,
or Error::Generation when the model or bridge fails.
Sourcepub async fn generate<P>(&self, prompt: P) -> Result<GeneratedText, Error>
pub async fn generate<P>(&self, prompt: P) -> Result<GeneratedText, Error>
MLX-style alias for AppleIntelligenceModels::generate_text.
§Errors
Returns the same error variants as AppleIntelligenceModels::generate_text.
Sourcepub async fn generate_with_options<P>(
&self,
prompt: P,
options: &GenerationOptions,
) -> Result<GeneratedText, Error>
pub async fn generate_with_options<P>( &self, prompt: P, options: &GenerationOptions, ) -> Result<GeneratedText, Error>
MLX-style alias for AppleIntelligenceModels::generate_text_with_options.
§Errors
Returns the same error variants as AppleIntelligenceModels::generate_text_with_options.
Sourcepub async fn complete<P>(&self, prompt: P) -> Result<ResponseText, Error>
pub async fn complete<P>(&self, prompt: P) -> Result<ResponseText, Error>
Sends a single prompt in a fresh session and returns typed response text.
§Errors
Returns the same error variants as AppleIntelligenceModels::respond.
Sourcepub async fn generate_text<P>(&self, prompt: P) -> Result<ResponseText, Error>
pub async fn generate_text<P>(&self, prompt: P) -> Result<ResponseText, Error>
Generates typed response text in a fresh session.
§Errors
Returns the same error variants as AppleIntelligenceModels::respond.
Sourcepub async fn generate_text_with_options<P>(
&self,
prompt: P,
options: &GenerationOptions,
) -> Result<ResponseText, Error>
pub async fn generate_text_with_options<P>( &self, prompt: P, options: &GenerationOptions, ) -> Result<ResponseText, Error>
Generates typed response text in a fresh session with explicit options.
§Errors
Returns Error::NullByte for invalid prompt text,
Error::InvalidTemperature or Error::InvalidMaxTokens for invalid
options, Error::Unavailable when Apple Intelligence is unavailable,
or Error::Generation when the model or bridge fails.
Sourcepub fn stream_text<P>(&self, prompt: P) -> Result<ResponseStream, Error>
pub fn stream_text<P>(&self, prompt: P) -> Result<ResponseStream, Error>
Streams response text from a fresh session.
§Errors
Returns the same error variants as AppleIntelligenceModels::generate_text.
Sourcepub fn stream_text_with_options<P>(
&self,
prompt: P,
options: &GenerationOptions,
) -> Result<ResponseStream, Error>
pub fn stream_text_with_options<P>( &self, prompt: P, options: &GenerationOptions, ) -> Result<ResponseStream, Error>
Streams response text from a fresh session with explicit options.
§Errors
Returns the same error variants as AppleIntelligenceModels::generate_text_with_options.
Sourcepub fn stream_generate<P>(&self, prompt: P) -> Result<ResponseStream, Error>
pub fn stream_generate<P>(&self, prompt: P) -> Result<ResponseStream, Error>
MLX-style alias for AppleIntelligenceModels::stream_text.
§Errors
Returns the same error variants as AppleIntelligenceModels::stream_text.
Sourcepub fn stream_generate_with_options<P>(
&self,
prompt: P,
options: &GenerationOptions,
) -> Result<ResponseStream, Error>
pub fn stream_generate_with_options<P>( &self, prompt: P, options: &GenerationOptions, ) -> Result<ResponseStream, Error>
MLX-style alias for AppleIntelligenceModels::stream_text_with_options.
§Errors
Returns the same error variants as AppleIntelligenceModels::stream_text_with_options.
Trait Implementations§
Source§impl Clone for AppleIntelligenceModels
impl Clone for AppleIntelligenceModels
Source§fn clone(&self) -> AppleIntelligenceModels
fn clone(&self) -> AppleIntelligenceModels
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more