Skip to main content

LanguageModel

Trait LanguageModel 

Source
pub trait LanguageModel:
    Sealed
    + Send
    + Sync {
    // Provided methods
    fn is_available(&self) -> bool { ... }
    fn availability(&self) -> ModelAvailability { ... }
    fn ensure_available(&self) -> Result<()> { ... }
    fn context_size(&self) -> Result<u64> { ... }
}
Expand description

A Foundation Models implementation that can create a crate::Session.

This sealed abstraction supports both the on-device model and model types introduced by newer Apple SDKs without allowing invalid external FFI implementations.

Provided Methods§

Source

fn is_available(&self) -> bool

Checks whether the model is currently available.

Source

fn availability(&self) -> ModelAvailability

Returns the current reason-specific model availability.

Source

fn ensure_available(&self) -> Result<()>

Returns a reason-specific error if the model is unavailable.

Source

fn context_size(&self) -> Result<u64>

Returns the model context window size in tokens.

For the on-device model this is reported synchronously (26.4+ build SDK required); for Private Cloud Compute it performs a network request and can fail with Error::NetworkFailure or Error::ServiceUnavailable.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl LanguageModel for PrivateCloudComputeLanguageModel

Available on crate feature private-cloud-compute only.
Source§

impl LanguageModel for SystemLanguageModel