pub struct ModelRegistry { /* private fields */ }Expand description
Curated map of model name → entry, plus a default model per task.
Implementations§
Source§impl ModelRegistry
impl ModelRegistry
Sourcepub fn register(&mut self, entry: ModelEntry) -> Result<(), RegistryError>
pub fn register(&mut self, entry: ModelEntry) -> Result<(), RegistryError>
Register a model.
§Errors
Returns RegistryError::DuplicateModel if a model with the same id is
already registered.
Sourcepub fn set_default(&mut self, task: Task, model: impl Into<String>)
pub fn set_default(&mut self, task: Task, model: impl Into<String>)
Set the default model for a task (the [ai.defaults] config block).
Sourcepub fn default_for(&self, task: Task) -> Option<&str>
pub fn default_for(&self, task: Task) -> Option<&str>
Default model name for a task, if one is configured.
Sourcepub fn resolve(&self, name: &str) -> Result<&ModelEntry, RegistryError>
pub fn resolve(&self, name: &str) -> Result<&ModelEntry, RegistryError>
Resolve a model by name.
§Errors
Returns RegistryError::UnknownModel if no model with that name is
registered.
Sourcepub fn validate(
&self,
name: &str,
task: Task,
) -> Result<&ModelEntry, RegistryError>
pub fn validate( &self, name: &str, task: Task, ) -> Result<&ModelEntry, RegistryError>
Resolve a model and confirm it supports task. This is the plan-time
gate behind every AI function call.
§Errors
Returns RegistryError::UnknownModel if the model is not registered,
or RegistryError::TaskUnsupported if it cannot perform task.
Sourcepub fn iter(&self) -> impl Iterator<Item = &ModelEntry>
pub fn iter(&self) -> impl Iterator<Item = &ModelEntry>
Iterate registered entries in unspecified order. Backs laminar.models.
Trait Implementations§
Source§impl Debug for ModelRegistry
impl Debug for ModelRegistry
Source§impl Default for ModelRegistry
impl Default for ModelRegistry
Source§fn default() -> ModelRegistry
fn default() -> ModelRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ModelRegistry
impl RefUnwindSafe for ModelRegistry
impl Send for ModelRegistry
impl Sync for ModelRegistry
impl Unpin for ModelRegistry
impl UnsafeUnpin for ModelRegistry
impl UnwindSafe for ModelRegistry
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more