pub struct ProviderRegistry { /* private fields */ }
Expand description
Registry for managing LLM providers
Implementations§
Source§impl ProviderRegistry
impl ProviderRegistry
Sourcepub fn new(storage: Arc<dyn AuthStorage>) -> Self
pub fn new(storage: Arc<dyn AuthStorage>) -> Self
Create a new provider registry with authentication storage
Sourcepub fn register_provider(&mut self, provider: Arc<dyn Provider>) -> Result<()>
pub fn register_provider(&mut self, provider: Arc<dyn Provider>) -> Result<()>
Register a provider
Sourcepub fn get_provider(&self, provider_id: &str) -> Result<Arc<dyn Provider>>
pub fn get_provider(&self, provider_id: &str) -> Result<Arc<dyn Provider>>
Get a provider by ID
Sourcepub fn list_providers(&self) -> Vec<String>
pub fn list_providers(&self) -> Vec<String>
List all registered providers
Sourcepub async fn get_model(
&mut self,
provider_id: &str,
model_id: &str,
) -> Result<Arc<dyn Model>>
pub async fn get_model( &mut self, provider_id: &str, model_id: &str, ) -> Result<Arc<dyn Model>>
Get a model by provider and model ID
Sourcepub fn parse_model_string(&self, model_string: &str) -> Result<(String, String)>
pub fn parse_model_string(&self, model_string: &str) -> Result<(String, String)>
Parse a model string (format: “provider/model” or “provider:model”)
Sourcepub fn set_default_provider(&mut self, provider_id: &str) -> Result<()>
pub fn set_default_provider(&mut self, provider_id: &str) -> Result<()>
Set default provider
Sourcepub fn get_default_provider(&self) -> Option<&str>
pub fn get_default_provider(&self) -> Option<&str>
Get default provider
Sourcepub async fn list_all_models(&self) -> Result<Vec<ModelInfo>>
pub async fn list_all_models(&self) -> Result<Vec<ModelInfo>>
List all available models
Sourcepub async fn get_all_provider_health(&self) -> HashMap<String, ProviderHealth>
pub async fn get_all_provider_health(&self) -> HashMap<String, ProviderHealth>
Get provider health for all providers
Sourcepub fn clear_model_cache(&mut self)
pub fn clear_model_cache(&mut self)
Clear cached models
Sourcepub fn remove_provider(&mut self, provider_id: &str) -> Result<()>
pub fn remove_provider(&mut self, provider_id: &str) -> Result<()>
Remove a provider
Sourcepub async fn discover_from_env(&mut self) -> Result<()>
pub async fn discover_from_env(&mut self) -> Result<()>
Discover providers from environment variables
Sourcepub async fn discover_from_storage(&mut self) -> Result<()>
pub async fn discover_from_storage(&mut self) -> Result<()>
Discover providers from storage
Sourcepub async fn initialize_all(&mut self) -> Result<()>
pub async fn initialize_all(&mut self) -> Result<()>
Initialize all registered providers
Sourcepub async fn load_models_dev(&mut self) -> Result<()>
pub async fn load_models_dev(&mut self) -> Result<()>
Load models from models.dev API
Sourcepub async fn load_configs(&mut self, path: &str) -> Result<()>
pub async fn load_configs(&mut self, path: &str) -> Result<()>
Load configurations from a file
Sourcepub async fn get(&self, provider_id: &str) -> Option<Arc<dyn Provider>>
pub async fn get(&self, provider_id: &str) -> Option<Arc<dyn Provider>>
Get a provider by ID (async version)
Sourcepub fn parse_model(model_str: &str) -> (String, String)
pub fn parse_model(model_str: &str) -> (String, String)
Parse a model string (format: “provider/model” or just “model”)
Sourcepub async fn get_default_model(
&self,
provider_id: &str,
) -> Result<Arc<dyn Model>>
pub async fn get_default_model( &self, provider_id: &str, ) -> Result<Arc<dyn Model>>
Get the default model for a provider
Auto Trait Implementations§
impl Freeze for ProviderRegistry
impl !RefUnwindSafe for ProviderRegistry
impl Send for ProviderRegistry
impl Sync for ProviderRegistry
impl Unpin for ProviderRegistry
impl !UnwindSafe for ProviderRegistry
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more