Zum Inhalt

selection

module wittgenstein_llm_router.selection

Model selection strategies — cost, performance, balanced, and custom rules.

Ported from wittgenstein-core's backend/src/services/llm_router/model_selection.py (ADR-092): the backend's hand-tuned scoring algorithm is the canonical implementation now, not the simpler placeholder heuristics this lib previously shipped. Operates directly on this package's LLMModel/ModelRouter — no wrapper-dict indirection, that's backend-specific plumbing the caller is responsible for if it needs it.

Classes

  • ModelSelector — Selects a model from a candidate list using a named routing strategy.

wittgenstein_llm_router.selection.ModelSelector

class ModelSelector()

Selects a model from a candidate list using a named routing strategy.

Methods

wittgenstein_llm_router.selection.ModelSelector.select_by_strategy

method ModelSelector.select_by_strategy(router: Optional[ModelRouter], available_models: List[LLMModel], request_type: str, estimated_tokens: Optional[int]) → LLMModel

Select a model based on the router's routing strategy.

Falls back to the first available model if the strategy yields nothing (e.g. a custom-rules router whose rules don't match).