Skip to main content

Model

Struct Model 

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

The public model type.

A Model may represent either a group of variants (as returned by Catalog::get_model) or a single variant (as returned by Catalog::get_model_variant or Model::variants).

Implementations§

Source§

impl Model

Source

pub fn id(&self) -> &str

Unique identifier of the (selected) variant.

Source

pub fn alias(&self) -> &str

Alias shared by all variants of this model.

Source

pub fn info(&self) -> Result<ModelInfo, FoundryLocalError>

Full catalog metadata for the (selected) variant.

The native model is the source of truth. Each call returns a fresh point-in-time snapshot so cache state remains correct after download or removal.

Source

pub fn context_length(&self) -> Option<u64>

Maximum context length (in tokens), or None if unknown.

Source

pub fn input_modalities(&self) -> Option<&str>

Comma-separated input modalities (e.g. "text,image"), or None.

Source

pub fn output_modalities(&self) -> Option<&str>

Comma-separated output modalities (e.g. "text"), or None.

Source

pub fn capabilities(&self) -> Option<&str>

Capability tags (e.g. "reasoning"), or None.

Source

pub fn supports_tool_calling(&self) -> Option<bool>

Whether the model supports tool/function calling, or None.

Source

pub async fn is_cached(&self) -> Result<bool, FoundryLocalError>

Whether the (selected) variant is cached on disk.

Source

pub async fn is_loaded(&self) -> Result<bool, FoundryLocalError>

Whether the (selected) variant is loaded into memory.

Source

pub async fn download<F>( &self, progress: Option<F>, ) -> Result<(), FoundryLocalError>
where F: FnMut(f64) + Send + 'static,

Download the (selected) variant. If progress is provided it receives download progress as a percentage (0.0–100.0).

Source

pub fn download_builder(&self) -> DownloadBuilder<'_>

Configure and run a model download with a builder.

Use this for call sites that need progress, cancellation, or future download options.

Source

pub async fn path(&self) -> Result<PathBuf, FoundryLocalError>

Return the local file-system path of the (selected) variant.

Source

pub async fn load(&self) -> Result<(), FoundryLocalError>

Load the (selected) variant into memory.

Source

pub async fn unload(&self) -> Result<(), FoundryLocalError>

Unload the (selected) variant from memory.

Source

pub async fn remove_from_cache(&self) -> Result<(), FoundryLocalError>

Remove the (selected) variant from the local cache.

Source

pub fn create_chat_client(&self) -> ChatClient

👎Deprecated since 2.0.0:

The OpenAI direct clients are deprecated; use ChatSession::new(&model) instead.

Create a ChatClient bound to the (selected) variant.

Source

pub fn create_audio_client(&self) -> AudioClient

👎Deprecated since 2.0.0:

The OpenAI direct clients are deprecated; use AudioSession::new(&model) instead.

Create an AudioClient bound to the (selected) variant.

Source

pub fn create_embedding_client(&self) -> EmbeddingClient

👎Deprecated since 2.0.0:

The OpenAI direct clients are deprecated; use EmbeddingsSession::new(&model) instead.

Create an EmbeddingClient bound to the (selected) variant.

Source

pub fn variants(&self) -> Vec<Arc<Model>>

Available variants of this model.

For a single-variant model (e.g. from Catalog::get_model_variant), this returns a single-element list containing itself.

Source

pub fn select_variant(&self, variant: &Model) -> Result<(), FoundryLocalError>

Select a variant to use for subsequent operations.

The variant must be one of the models returned by variants.

§Errors

Returns an error if the variant does not belong to this model. For single-variant models this always returns an error — use Catalog::get_model to obtain a model with all variants available.

Source

pub fn select_variant_by_id(&self, id: &str) -> Result<(), FoundryLocalError>

Select a variant by its unique id string.

This is a convenience method for cases where you have a variant id from an external source. Prefer select_variant when you already have a Model reference from variants.

§Errors

Returns an error if no variant with the given id exists. For single-variant models this always returns an error — use Catalog::get_model to obtain a model with all variants available.

Trait Implementations§

Source§

impl Clone for Model

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Model

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Model

§

impl RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

§

impl UnwindSafe for Model

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more