MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / select_from_pool

Function select_from_pool

uncommon_route/router/selector.py:1247–1729  ·  view source on GitHub ↗

Select the best model from the full discovered pool. Unlike ``select_model`` which picks from a per-tier list, this evaluates ALL available models and lets ``complexity`` drive the cost-vs-quality trade-off via weight interpolation.

(
    complexity: float,
    mode: RoutingMode,
    confidence: float,
    reasoning_text: str,
    available_models: list[str],
    estimated_input_tokens: int,
    max_output_tokens: int,
    prompt: str,
    pricing: dict[str, ModelPricing],
    capabilities: dict[str, ModelCapabilities],
    requirements: RequestRequirements,
    constraints: RoutingConstraints | None = None,
    workload_hints: WorkloadHints | None = None,
    routing_features: RoutingFeatures | None = None,
    answer_depth: AnswerDepth = AnswerDepth.STANDARD,
    answer_depth_multiplier: float = 1.0,
    agentic_score: float = 0.0,
    user_keyed_models: set[str] | None = None,
    selection_weights: SelectionWeights | None = None,
    bandit_config: BanditConfig | None = None,
    model_experience: object | None = None,
    raw_confidence: float | None = None,
    confidence_source: str = "classifier",
    calibration_version: str = "",
    calibration_sample_count: int = 0,
    calibration_temperature: float = 1.0,
    calibration_applied_tags: tuple[str, ...] = (),
)

Source from the content-addressed store, hash-verified

1245
1246
1247def select_from_pool(
1248 complexity: float,
1249 mode: RoutingMode,
1250 confidence: float,
1251 reasoning_text: str,
1252 available_models: list[str],
1253 estimated_input_tokens: int,
1254 max_output_tokens: int,
1255 prompt: str,
1256 pricing: dict[str, ModelPricing],
1257 capabilities: dict[str, ModelCapabilities],
1258 requirements: RequestRequirements,
1259 constraints: RoutingConstraints | None = None,
1260 workload_hints: WorkloadHints | None = None,
1261 routing_features: RoutingFeatures | None = None,
1262 answer_depth: AnswerDepth = AnswerDepth.STANDARD,
1263 answer_depth_multiplier: float = 1.0,
1264 agentic_score: float = 0.0,
1265 user_keyed_models: set[str] | None = None,
1266 selection_weights: SelectionWeights | None = None,
1267 bandit_config: BanditConfig | None = None,
1268 model_experience: object | None = None,
1269 raw_confidence: float | None = None,
1270 confidence_source: str = "classifier",
1271 calibration_version: str = "",
1272 calibration_sample_count: int = 0,
1273 calibration_temperature: float = 1.0,
1274 calibration_applied_tags: tuple[str, ...] = (),
1275) -> RoutingDecision:
1276 """Select the best model from the full discovered pool.
1277
1278 Unlike ``select_model`` which picks from a per-tier list, this
1279 evaluates ALL available models and lets ``complexity`` drive the
1280 cost-vs-quality trade-off via weight interpolation.
1281 """
1282 weights = selection_weights or SelectionWeights()
1283 bc = bandit_config or BanditConfig()
1284 hard_constraints = constraints or RoutingConstraints()
1285 hints = workload_hints or WorkloadHints()
1286 tier = _derive_tier(complexity)
1287 effective_features = routing_features or RoutingFeatures()
1288 step_stable = _stabilize_agent_step_selection(effective_features)
1289 if step_stable and bc.enabled:
1290 bc = replace(bc, enabled=False)
1291 lane = request_capability_lane(effective_features)
1292
1293 if not available_models:
1294 _raise_no_available_models()
1295
1296 filtered_candidates, excluded = _filter_candidates(
1297 available_models, requirements, capabilities)
1298 if not filtered_candidates:
1299 _raise_capability_infeasible(
1300 available_models=available_models,
1301 candidate_count=len(available_models),
1302 requirements=requirements,
1303 excluded=excluded,
1304 constraints=hard_constraints,

Calls 15

SelectionWeightsClass · 0.90
BanditConfigClass · 0.90
RoutingConstraintsClass · 0.90
WorkloadHintsClass · 0.90
RoutingFeaturesClass · 0.90
request_capability_laneFunction · 0.90
estimate_output_budgetFunction · 0.90
apply_quality_guardsFunction · 0.90
get_benchmark_cacheFunction · 0.90
ModelCapabilitiesClass · 0.90