pub struct ModelRegistry { /* private fields */ }Expand description
Routes model requests to the appropriate adapter.
Register adapters by system_name() (e.g. “anthropic”, “openai”).
The registry selects an adapter based on the model prefix in the request config,
or falls back to the default adapter.
Implementations§
Source§impl ModelRegistry
impl ModelRegistry
pub fn new() -> Self
Sourcepub fn register(self, adapter: Arc<dyn ModelAdapter>) -> Self
pub fn register(self, adapter: Arc<dyn ModelAdapter>) -> Self
Register an adapter under its system name.
Sourcepub fn route_prefix(
self,
prefix: impl Into<String>,
system: impl Into<String>,
) -> Self
pub fn route_prefix( self, prefix: impl Into<String>, system: impl Into<String>, ) -> Self
Route model name prefix to a system (e.g. “claude-” → “anthropic”).
Sourcepub fn with_default(self, system: impl Into<String>) -> Self
pub fn with_default(self, system: impl Into<String>) -> Self
Set the default adapter to use when no prefix matches.
Sourcepub async fn chat(
&self,
request: ModelRequest,
) -> Result<ModelResponse, ModelError>
pub async fn chat( &self, request: ModelRequest, ) -> Result<ModelResponse, ModelError>
Send a chat request, routing to the appropriate adapter.
Sourcepub async fn structured_output(
&self,
request: StructuredRequest,
) -> Result<ModelResponse, ModelError>
pub async fn structured_output( &self, request: StructuredRequest, ) -> Result<ModelResponse, ModelError>
Send a structured output request, routing to the appropriate adapter.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ModelRegistry
impl !UnwindSafe for ModelRegistry
impl Freeze for ModelRegistry
impl Send for ModelRegistry
impl Sync for ModelRegistry
impl Unpin for ModelRegistry
impl UnsafeUnpin for ModelRegistry
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