pub struct TierSelector { /* private fields */ }Expand description
Type-safe selector for a specific model tier
This newtype wrapper validates that at least one endpoint exists for the specified tier at construction time, then provides type-safe selection from that tier.
§Tier Selection for LLM Routing
When used by the LLM-based router, the tier choice impacts routing performance:
-
FAST (8B): Lowest latency (~50-200ms) but may misroute complex requests. Risk of bad routing decisions outweighs latency savings.
-
BALANCED (30B): Recommended default. Good reasoning for classification with acceptable latency (~100-500ms). Best balance of accuracy and speed.
-
DEEP (120B): Highest accuracy but very slow (~2-5s). Router latency may exceed the time to just run the user query on BALANCED. Rarely worth it.
§Construction-Time Validation
The tier is validated at construction (checks that at least one endpoint exists) and stored immutably. The selector cannot switch tiers after construction, but tier selection itself is a runtime parameter, not a compile-time guarantee.
Implementations§
Source§impl TierSelector
impl TierSelector
Sourcepub fn new(selector: Arc<ModelSelector>, tier: TargetModel) -> AppResult<Self>
pub fn new(selector: Arc<ModelSelector>, tier: TargetModel) -> AppResult<Self>
Create a new TierSelector for the specified tier
Returns an error if the ModelSelector has no endpoints for the specified tier. This validation ensures the router can never be in an invalid state.
§Arguments
selector- The underlying ModelSelectortier- Which tier (Fast, Balanced, Deep) to select from
§Errors
Returns AppError::Config if no endpoints are configured for the specified tier.
Sourcepub async fn select(&self, exclude: &ExclusionSet) -> Option<&ModelEndpoint>
pub async fn select(&self, exclude: &ExclusionSet) -> Option<&ModelEndpoint>
Select an endpoint from this selector’s tier with health filtering and exclusion
§Arguments
exclude- Set of endpoint names to exclude (for retry logic)
§Returns
Some(&ModelEndpoint)if a healthy, non-excluded endpoint exists for this tierNoneif all endpoints for this tier are unhealthy or excluded
Sourcepub fn tier(&self) -> TargetModel
pub fn tier(&self) -> TargetModel
Get the tier this selector operates on
Sourcepub fn endpoint_count(&self) -> usize
pub fn endpoint_count(&self) -> usize
Get the number of configured endpoints for this selector’s tier
Sourcepub fn health_checker(&self) -> &Arc<HealthChecker>
pub fn health_checker(&self) -> &Arc<HealthChecker>
Get a reference to the health checker for external use (e.g., marking success/failure)