pub struct SystemLanguageModel { /* private fields */ }Expand description
The system language model provided by Apple Intelligence.
This is the main entry point for using on-device AI capabilities.
Use SystemLanguageModel::new() to get the default model.
§Example
use fm_rs::SystemLanguageModel;
let model = SystemLanguageModel::new()?;
if model.is_available() {
println!("Model is ready to use!");
}Implementations§
Source§impl SystemLanguageModel
impl SystemLanguageModel
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates the default system language model.
§Errors
Returns an error if the model cannot be created or if FoundationModels
is not available on the device.
Sourcepub fn is_available(&self) -> bool
pub fn is_available(&self) -> bool
Checks if the model is available for use.
Returns true if the model is available and ready to generate responses.
Sourcepub fn availability(&self) -> ModelAvailability
pub fn availability(&self) -> ModelAvailability
Gets the current availability status of the model.
This provides more detailed information about why the model might not be available.
Sourcepub fn ensure_available(&self) -> Result<()>
pub fn ensure_available(&self) -> Result<()>
Returns a reason-specific error if the model is unavailable.
Trait Implementations§
Source§impl Debug for SystemLanguageModel
impl Debug for SystemLanguageModel
Source§impl Drop for SystemLanguageModel
impl Drop for SystemLanguageModel
impl Send for SystemLanguageModel
impl Sync for SystemLanguageModel
Auto Trait Implementations§
impl Freeze for SystemLanguageModel
impl RefUnwindSafe for SystemLanguageModel
impl Unpin for SystemLanguageModel
impl UnwindSafe for SystemLanguageModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more