pub struct ModelRouter { /* private fields */ }Expand description
Routes LLM requests to the correct provider based on model prefix. claude-* → Anthropic gpt-, o1, o3* → OpenAI ollama:* → Ollama zai:, glm- → ZAI mock* → Mock
Implementations§
Source§impl ModelRouter
impl ModelRouter
pub fn new() -> Self
pub fn with_provider(self, provider: Arc<dyn LlmProvider>) -> Self
pub fn add_provider(&mut self, provider: Arc<dyn LlmProvider>)
Trait Implementations§
Source§impl Default for ModelRouter
impl Default for ModelRouter
Source§impl LlmProvider for ModelRouter
impl LlmProvider for ModelRouter
Source§fn generate<'life0, 'async_trait>(
&'life0 self,
req: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate<'life0, 'async_trait>(
&'life0 self,
req: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Generate a response (non-streaming)
Source§fn supports_model(&self, model: &str) -> bool
fn supports_model(&self, model: &str) -> bool
Models supported by this provider (prefix matching)
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