pub struct ModelCatalog { /* private fields */ }Expand description
All registered providers and their available models.
Implementations§
Source§impl ModelCatalog
impl ModelCatalog
Sourcepub async fn new(
providers: Vec<(String, Arc<dyn ModelProvider>)>,
) -> Result<Self, Box<dyn Error + Send + Sync>>
pub async fn new( providers: Vec<(String, Arc<dyn ModelProvider>)>, ) -> Result<Self, Box<dyn Error + Send + Sync>>
Build a catalog from (provider_id, provider) pairs (in registration
order). Provider ids must be stable, unique, and non-empty. The first
model of the first provider becomes the global default.
Sourcepub fn models(&self) -> &[CatalogModel]
pub fn models(&self) -> &[CatalogModel]
All available models, in registration order.
Sourcepub fn default_ref(&self) -> &ModelRef
pub fn default_ref(&self) -> &ModelRef
The global default model.
Sourcepub fn default_entry(&self) -> &ModelEntry
pub fn default_entry(&self) -> &ModelEntry
The entry for the global default model.
Sourcepub fn find(&self, model: &ModelRef) -> Option<&ModelEntry>
pub fn find(&self, model: &ModelRef) -> Option<&ModelEntry>
Look up a model’s entry by reference.
Sourcepub fn provider(&self, provider_id: &str) -> Option<&Arc<dyn ModelProvider>>
pub fn provider(&self, provider_id: &str) -> Option<&Arc<dyn ModelProvider>>
Look up a provider by its id.
Sourcepub fn resolve(&self, selected: &ModelRef) -> (ModelRef, &ModelEntry, bool)
pub fn resolve(&self, selected: &ModelRef) -> (ModelRef, &ModelEntry, bool)
Resolve a selected model to a concrete (ModelRef, entry), falling
back to the global default when the selection is no longer available.
Returns (model, entry, fell_back) where fell_back is true when a
stale selection was replaced by the default.
Auto Trait Implementations§
impl !RefUnwindSafe for ModelCatalog
impl !UnwindSafe for ModelCatalog
impl Freeze for ModelCatalog
impl Send for ModelCatalog
impl Sync for ModelCatalog
impl Unpin for ModelCatalog
impl UnsafeUnpin for ModelCatalog
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