pub struct ModelRouter { /* private fields */ }Expand description
Multi-model router that dispatches to the right provider.
Implementations§
Source§impl ModelRouter
impl ModelRouter
Sourcepub fn new(config: RouterConfig) -> Self
pub fn new(config: RouterConfig) -> Self
Create a router with the given config. Loads API keys from config file (~/.mur/commander/config.toml), falling back to environment variables.
Sourcepub fn default_router() -> Self
pub fn default_router() -> Self
Create a router with default config.
Sourcepub fn role_for_step(&self, step_type: &StepType) -> ModelRole
pub fn role_for_step(&self, step_type: &StepType) -> ModelRole
Select the model role for a given step type.
Sourcepub fn config_for_role(&self, role: &ModelRole) -> Option<&ModelConfig>
pub fn config_for_role(&self, role: &ModelRole) -> Option<&ModelConfig>
Get the model config for a given role.
Sourcepub fn cli_provider(&self, name: &str) -> Option<&CliProvider>
pub fn cli_provider(&self, name: &str) -> Option<&CliProvider>
Get a CLI provider by name.
Sourcepub fn detected_cli_providers(&self) -> &[CliProvider]
pub fn detected_cli_providers(&self) -> &[CliProvider]
List detected CLI providers.
Sourcepub async fn complete_with_cli(
&self,
provider_name: &str,
prompt: &str,
) -> Result<ModelResponse>
pub async fn complete_with_cli( &self, provider_name: &str, prompt: &str, ) -> Result<ModelResponse>
Complete using a CLI provider directly.
Sourcepub async fn complete(
&self,
role: &ModelRole,
prompt: &str,
) -> Result<ModelResponse>
pub async fn complete( &self, role: &ModelRole, prompt: &str, ) -> Result<ModelResponse>
Route a completion request to the appropriate provider. If a default CLI provider is configured and available, uses it first.
Sourcepub async fn complete_for_step(
&self,
step_type: &StepType,
prompt: &str,
) -> Result<ModelResponse>
pub async fn complete_for_step( &self, step_type: &StepType, prompt: &str, ) -> Result<ModelResponse>
Route a step to the appropriate model and get a completion.
Sourcepub fn list_models(&self) -> Vec<(String, &ModelConfig)>
pub fn list_models(&self) -> Vec<(String, &ModelConfig)>
List all configured roles and their models.
Auto Trait Implementations§
impl Freeze for ModelRouter
impl !RefUnwindSafe for ModelRouter
impl Send for ModelRouter
impl Sync for ModelRouter
impl Unpin for ModelRouter
impl UnsafeUnpin for ModelRouter
impl !UnwindSafe for ModelRouter
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