pub struct Models { /* private fields */ }Expand description
Thread-safe model registry used by the engine.
It maintains two layers:
model: the primary default model for general requestsmodels: a label-based map for selecting specific models
The dedicated primary slot can be set explicitly via Models::set_model
or derived from the special label primary in the label map. This keeps
direct lookup (get) separate from default-routing (get_model).
Implementations§
Source§impl Models
impl Models
Sourcepub fn from_clone(other: &Models) -> Self
pub fn from_clone(other: &Models) -> Self
Creates a new Models instance by cloning the internal state of another Models instance.
Sourcepub fn replace(&self, other: &Models)
pub fn replace(&self, other: &Models)
Replaces this registry with a clone of another Models instance.
Sourcepub fn from_configs(configs: &[ModelConfig], http_client: Client) -> Self
pub fn from_configs(configs: &[ModelConfig], http_client: Client) -> Self
Builds a registry from model configs by registering every resolved label.
Sourcepub fn contains(&self, label: &str) -> bool
pub fn contains(&self, label: &str) -> bool
Returns whether a label exists in the direct lookup table.
Sourcepub fn model_names(&self) -> BTreeSet<String>
pub fn model_names(&self) -> BTreeSet<String>
Returns the set of all registered model names across all labels.
Sourcepub fn set_model(&self, model: Model)
pub fn set_model(&self, model: Model)
Sets the primary default model without mutating the label map.
Sourcepub fn set(&self, label: String, model: Model)
pub fn set(&self, label: String, model: Model)
Inserts or updates a single labeled model.
The special label primary also updates the dedicated routing slot.
If no primary exists yet, any inserted model is promoted
to become the primary default.
Sourcepub fn get(&self, label: &str) -> Option<Model>
pub fn get(&self, label: &str) -> Option<Model>
Returns a model by lowercase label if it exists.
This is a direct lookup only and never falls back to default routing.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Models
impl !RefUnwindSafe for Models
impl !UnwindSafe for Models
impl Send for Models
impl Sync for Models
impl Unpin for Models
impl UnsafeUnpin for Models
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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>
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