Skip to main content

AppleIntelligenceModels

Struct AppleIntelligenceModels 

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

Handle for Apple’s default on-device system language model.

Implementations§

Source§

impl AppleIntelligenceModels

Source

pub fn new() -> Self

Creates a handle to the default system language model.

Source

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.

Source

pub fn is_available(&self) -> bool

Returns true when the default system language model is available.

Source

pub fn session(&self) -> LanguageModelSessionBuilder

Starts building a stateful session.

Source

pub fn agent(&self) -> LanguageModelSessionBuilder

Alias for AppleIntelligenceModels::session for users coming from Rig’s agent builders.

Source

pub async fn respond<P>(&self, prompt: P) -> Result<String, Error>
where P: TryInto<Prompt>, P::Error: Into<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.

Source

pub async fn generate<P>(&self, prompt: P) -> Result<GeneratedText, Error>
where P: TryInto<Prompt>, P::Error: Into<Error>,

MLX-style alias for AppleIntelligenceModels::generate_text.

§Errors

Returns the same error variants as AppleIntelligenceModels::generate_text.

Source

pub async fn generate_with_options<P>( &self, prompt: P, options: &GenerationOptions, ) -> Result<GeneratedText, Error>
where P: TryInto<Prompt>, P::Error: Into<Error>,

Source

pub async fn complete<P>(&self, prompt: P) -> Result<ResponseText, Error>
where P: TryInto<Prompt>, P::Error: Into<Error>,

Sends a single prompt in a fresh session and returns typed response text.

§Errors

Returns the same error variants as AppleIntelligenceModels::respond.

Source

pub async fn generate_text<P>(&self, prompt: P) -> Result<ResponseText, Error>
where P: TryInto<Prompt>, P::Error: Into<Error>,

Generates typed response text in a fresh session.

§Errors

Returns the same error variants as AppleIntelligenceModels::respond.

Source

pub async fn generate_text_with_options<P>( &self, prompt: P, options: &GenerationOptions, ) -> Result<ResponseText, Error>
where P: TryInto<Prompt>, P::Error: Into<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.

Source

pub fn stream_text<P>(&self, prompt: P) -> Result<ResponseStream, Error>
where P: TryInto<Prompt>, P::Error: Into<Error>,

Streams response text from a fresh session.

§Errors

Returns the same error variants as AppleIntelligenceModels::generate_text.

Source

pub fn stream_text_with_options<P>( &self, prompt: P, options: &GenerationOptions, ) -> Result<ResponseStream, Error>
where P: TryInto<Prompt>, P::Error: Into<Error>,

Streams response text from a fresh session with explicit options.

§Errors

Returns the same error variants as AppleIntelligenceModels::generate_text_with_options.

Source

pub fn stream_generate<P>(&self, prompt: P) -> Result<ResponseStream, Error>
where P: TryInto<Prompt>, P::Error: Into<Error>,

MLX-style alias for AppleIntelligenceModels::stream_text.

§Errors

Returns the same error variants as AppleIntelligenceModels::stream_text.

Source

pub fn stream_generate_with_options<P>( &self, prompt: P, options: &GenerationOptions, ) -> Result<ResponseStream, Error>
where P: TryInto<Prompt>, P::Error: Into<Error>,

Trait Implementations§

Source§

impl Clone for AppleIntelligenceModels

Source§

fn clone(&self) -> AppleIntelligenceModels

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AppleIntelligenceModels

Source§

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

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

impl Default for AppleIntelligenceModels

Source§

fn default() -> AppleIntelligenceModels

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

impl LanguageModel for AppleIntelligenceModels

Source§

fn generate_text_with_options<P>( &self, prompt: P, options: GenerationOptions, ) -> impl Future<Output = Result<ResponseText, Error>> + '_
where P: TryInto<Prompt>, P::Error: Into<Error>,

Generates response text for a prompt with explicit generation options. Read more
Source§

fn stream_text_with_options<P>( &self, prompt: P, options: GenerationOptions, ) -> Result<ResponseStream, Error>
where P: TryInto<Prompt>, P::Error: Into<Error>,

Streams response text for a prompt with explicit generation options. Read more
Source§

impl Copy for AppleIntelligenceModels

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CompletionModel for T
where T: LanguageModel,

Source§

fn completion<P>( &self, prompt: P, options: GenerationOptions, ) -> impl Future<Output = Result<ResponseText, Error>> + '_
where P: TryInto<Prompt>, P::Error: Into<Error>,

Generates response text for a prompt with explicit generation options. Read more
Source§

fn stream_completion<P>( &self, prompt: P, options: GenerationOptions, ) -> Result<ResponseStream, Error>
where P: TryInto<Prompt>, P::Error: Into<Error>,

Streams response text for a prompt with explicit generation options. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GenerateText for T
where T: LanguageModel,

Source§

fn prompt<P>( &self, prompt: P, ) -> impl Future<Output = Result<ResponseText, Error>> + '_
where P: TryInto<Prompt>, P::Error: Into<Error>,

Sends a prompt with default generation options. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,