Constructs a ModelRouter instance.
The router must be initialized via initialize() before use.
Async Initializes the model router with its configuration and necessary dependencies, such as the AIModelProviderManager for accessing information about available models and providers.
Router-specific configuration (e.g., rules, model preferences).
An instance of AIModelProviderManager or a similar service that provides access to available models and providers.
Optional _promptEngine: anyOptional: An instance of PromptEngine, if the router uses LLM-based routing decisions.
A promise that resolves upon successful initialization.
If initialization fails (e.g., invalid configuration).
Async Selects an AI model and provider based on the provided parameters and the router's internal logic.
The parameters and context for the routing decision.
Optional availableModels: ModelInfo[]Optional: A pre-fetched list of available models. If not provided,
the router may need to fetch this list from its providerManager.
A promise that resolves with the routing decision, or null if no suitable model/provider could be found that meets the criteria.
If a critical error occurs during the selection process.
Readonly routerA unique identifier for this specific router implementation.
Implements
A rule-based implementation of
IModelRouter. It selects an AI model by evaluating a configured set of rules in order of priority. This router is designed to be flexible and extensible through declarative rules and custom condition evaluators.