pub struct ModelCatalog { /* private fields */ }Expand description
An in-memory, immutable view over a ModelCatalogSnapshot.
Construct it from the embedded seed (ModelCatalog::seed) or from custom
JSON, then look entries up by (provider, model_id) or by model id alone.
Lookups also match an entry’s aliases.
Implementations§
Source§impl ModelCatalog
impl ModelCatalog
Sourcepub fn from_snapshot(snapshot: ModelCatalogSnapshot) -> Self
pub fn from_snapshot(snapshot: ModelCatalogSnapshot) -> Self
Wraps an already-parsed ModelCatalogSnapshot.
Sourcepub fn from_json(source: &str) -> Result<Self>
pub fn from_json(source: &str) -> Result<Self>
Parses a catalog from a JSON snapshot string.
§Errors
Returns an error if source is not a valid ModelCatalogSnapshot.
Sourcepub fn seed() -> Result<Self>
pub fn seed() -> Result<Self>
Loads the catalog from the snapshot embedded in the crate at build time.
§Errors
Returns an error if the embedded snapshot fails to parse (which would indicate a corrupted checked-in file).
Sourcepub fn snapshot(&self) -> &ModelCatalogSnapshot
pub fn snapshot(&self) -> &ModelCatalogSnapshot
Returns the underlying snapshot, including its metadata and sources.
Sourcepub fn models(&self) -> &[ModelCatalogEntry]
pub fn models(&self) -> &[ModelCatalogEntry]
Returns all catalog entries.
Sourcepub fn get_by_model_id(&self, model_id: &str) -> Option<&ModelCatalogEntry>
pub fn get_by_model_id(&self, model_id: &str) -> Option<&ModelCatalogEntry>
Looks up an entry by model id (or alias) across all providers, returning
the first match. Use get when the provider is known and
the same id might appear under more than one provider.
Sourcepub fn profile(&self, provider: &str, model_id: &str) -> Option<ModelProfile>
pub fn profile(&self, provider: &str, model_id: &str) -> Option<ModelProfile>
Hydrates a runtime
ModelProfile from the catalog
entry for provider/model_id, bridging offline catalog facts into the
capability profile resolution and fallback consume. Returns None when
no entry matches.
Trait Implementations§
Source§impl Clone for ModelCatalog
impl Clone for ModelCatalog
Source§fn clone(&self) -> ModelCatalog
fn clone(&self) -> ModelCatalog
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more