pub struct ModelSelector { /* private fields */ }Expand description
Registry and selection engine for ModelProfiles.
Implementations§
Source§impl ModelSelector
impl ModelSelector
Sourcepub fn new(strategy: SelectionStrategy) -> Self
pub fn new(strategy: SelectionStrategy) -> Self
Create a new selector with no registered profiles.
Sourcepub fn register(&mut self, profile: ModelProfile)
pub fn register(&mut self, profile: ModelProfile)
Register (or replace) a model profile.
Sourcepub fn select(&self, criteria: &SelectionCriteria) -> Option<&ModelProfile>
pub fn select(&self, criteria: &SelectionCriteria) -> Option<&ModelProfile>
Return the best model according to the active strategy that satisfies
all hard constraints in criteria, or None if no model qualifies.
Sourcepub fn rank_all(&self, criteria: &SelectionCriteria) -> Vec<&ModelProfile>
pub fn rank_all(&self, criteria: &SelectionCriteria) -> Vec<&ModelProfile>
Return all eligible profiles ranked from best to worst by the active strategy.
Sourcepub fn estimate_cost(
&self,
model_id: &str,
tokens_in: usize,
tokens_out: usize,
) -> f64
pub fn estimate_cost( &self, model_id: &str, tokens_in: usize, tokens_out: usize, ) -> f64
Estimate the cost in USD for a single request on model_id.
Uses the profile’s blended cost_per_1k_tokens applied to the total
token count (tokens_in + tokens_out). Returns 0.0 if the model ID
is not registered.
Sourcepub fn cheapest_for_quality(&self, min_quality: f64) -> Option<&ModelProfile>
pub fn cheapest_for_quality(&self, min_quality: f64) -> Option<&ModelProfile>
Return the cheapest registered model whose quality_score >= min_quality,
or None if no model meets the threshold.
Auto Trait Implementations§
impl Freeze for ModelSelector
impl RefUnwindSafe for ModelSelector
impl Send for ModelSelector
impl Sync for ModelSelector
impl Unpin for ModelSelector
impl UnsafeUnpin for ModelSelector
impl UnwindSafe for ModelSelector
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