pub struct ModelRegistry { /* private fields */ }Expand description
Concurrent registry of ModelMetadata keyed by model ID.
Implementations§
Source§impl ModelRegistry
impl ModelRegistry
Sourcepub fn register(&self, model: ModelMetadata)
pub fn register(&self, model: ModelMetadata)
Register or replace a model’s metadata.
Sourcepub fn get(&self, model_id: &str) -> Option<ModelMetadata>
pub fn get(&self, model_id: &str) -> Option<ModelMetadata>
Look up a model by ID.
Sourcepub fn all_models(&self) -> Vec<ModelMetadata>
pub fn all_models(&self) -> Vec<ModelMetadata>
Return all registered models.
Sourcepub fn models_with_capability(
&self,
cap: &ModelCapability,
) -> Vec<ModelMetadata>
pub fn models_with_capability( &self, cap: &ModelCapability, ) -> Vec<ModelMetadata>
Return non-deprecated models that have cap, sorted by cheapest input cost first.
Sourcepub fn cheapest_for_capability(
&self,
cap: &ModelCapability,
min_context: usize,
) -> Option<ModelMetadata>
pub fn cheapest_for_capability( &self, cap: &ModelCapability, min_context: usize, ) -> Option<ModelMetadata>
Return the cheapest model that has cap and fits within min_context tokens.
Sourcepub fn best_for_capability(
&self,
cap: &ModelCapability,
min_context: usize,
) -> Option<ModelMetadata>
pub fn best_for_capability( &self, cap: &ModelCapability, min_context: usize, ) -> Option<ModelMetadata>
Return the highest-tier model that has cap and fits within min_context tokens.
Sourcepub fn suggest_routing(
&self,
caps: &[ModelCapability],
context_size: usize,
budget_usd: Option<f64>,
) -> RoutingHint
pub fn suggest_routing( &self, caps: &[ModelCapability], context_size: usize, budget_usd: Option<f64>, ) -> RoutingHint
Suggest a routing strategy given required capabilities, context size, and optional budget.
Sourcepub fn built_in_registry() -> Self
pub fn built_in_registry() -> Self
Build a registry pre-populated with well-known models.
Sourcepub fn rate_limit_check(
&self,
model_id: &str,
requests_last_minute: u32,
tokens_last_minute: u32,
) -> bool
pub fn rate_limit_check( &self, model_id: &str, requests_last_minute: u32, tokens_last_minute: u32, ) -> bool
Check whether a model is within its rate limits.
Returns true if the model can accept more requests/tokens, false if a limit is exceeded.
Sourcepub fn deprecation_warnings(&self) -> Vec<String>
pub fn deprecation_warnings(&self) -> Vec<String>
Return deprecation warning strings for all deprecated models.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ModelRegistry
impl Freeze 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request