pub struct ModelRegistry { /* private fields */ }Expand description
Model registry manager
Implementations§
Source§impl ModelRegistry
impl ModelRegistry
pub fn new(storage: Arc<ModelStorage>) -> Result<Self>
Sourcepub async fn refresh_openrouter_catalog_from_api(
&mut self,
api_key: &str,
) -> Result<()>
pub async fn refresh_openrouter_catalog_from_api( &mut self, api_key: &str, ) -> Result<()>
Refresh the OpenRouter model catalog from the live OpenRouter API. This replaces any existing OpenRouter entries with the up-to-date list of models visible to the provided API key.
Sourcepub async fn refresh_huggingface_catalog_from_api(
&mut self,
limit: usize,
) -> Result<()>
pub async fn refresh_huggingface_catalog_from_api( &mut self, limit: usize, ) -> Result<()>
Refresh the Hugging Face GGUF/GGML model catalog from the HF Hub API. Fetches top models by downloads and extracts available quantized files.
Sourcepub fn update_compatibility_scores(
&mut self,
recommender: &ModelRecommender,
hardware: &HardwareProfile,
)
pub fn update_compatibility_scores( &mut self, recommender: &ModelRecommender, hardware: &HardwareProfile, )
Recompute compatibility scores for all known local models based on the current hardware profile and user preferences. This is used by the model manager to support “Best Match” sorting in the UI.
Sourcepub async fn scan_storage(&mut self) -> Result<()>
pub async fn scan_storage(&mut self) -> Result<()>
Scan local storage for existing models and populate registry
Sourcepub async fn update_model_status_from_storage(
&mut self,
model_id: &str,
) -> Result<()>
pub async fn update_model_status_from_storage( &mut self, model_id: &str, ) -> Result<()>
Update model status based on file existence
Sourcepub async fn update_all_model_statuses_from_storage(&mut self) -> Result<()>
pub async fn update_all_model_statuses_from_storage(&mut self) -> Result<()>
Update all model statuses based on file existence in storage
Sourcepub fn get_installed_model_path(&self, model_id: &str) -> Option<PathBuf>
pub fn get_installed_model_path(&self, model_id: &str) -> Option<PathBuf>
Get the path of an installed model by ID
Sourcepub async fn get_model_metadata(&self, model_id: &str) -> Option<ModelMetadata>
pub async fn get_model_metadata(&self, model_id: &str) -> Option<ModelMetadata>
Get the complete model metadata including runtime binaries information
Sourcepub fn get_model_mut(&mut self, model_id: &str) -> Option<&mut ModelInfo>
pub fn get_model_mut(&mut self, model_id: &str) -> Option<&mut ModelInfo>
Get mutable reference to model information
Sourcepub fn list_models(&self) -> Vec<&ModelInfo>
pub fn list_models(&self) -> Vec<&ModelInfo>
List all models in registry
Sourcepub fn list_models_by_status(&self, status: ModelStatus) -> Vec<&ModelInfo>
pub fn list_models_by_status(&self, status: ModelStatus) -> Vec<&ModelInfo>
List models by status
Sourcepub fn search_models(&self, query: &str) -> Vec<&ModelInfo>
pub fn search_models(&self, query: &str) -> Vec<&ModelInfo>
Search models by name or tags
Sourcepub fn get_recommended_models(&self, max_results: usize) -> Vec<&ModelInfo>
pub fn get_recommended_models(&self, max_results: usize) -> Vec<&ModelInfo>
Get models sorted by compatibility score for current hardware
Sourcepub fn update_model_status(&mut self, model_id: &str, status: ModelStatus)
pub fn update_model_status(&mut self, model_id: &str, status: ModelStatus)
Update model status
Sourcepub fn remove_model(&mut self, model_id: &str) -> bool
pub fn remove_model(&mut self, model_id: &str) -> bool
Remove a model from registry
Sourcepub fn get_statistics(&self) -> RegistryStats
pub fn get_statistics(&self) -> RegistryStats
Get registry statistics
Sourcepub fn get_models_by_category(&self, category: &str) -> Vec<&ModelInfo>
pub fn get_models_by_category(&self, category: &str) -> Vec<&ModelInfo>
Get models by category/tags
Sourcepub fn get_trending_models(&self, limit: usize) -> Vec<&ModelInfo>
pub fn get_trending_models(&self, limit: usize) -> Vec<&ModelInfo>
Get trending models (recently added or popular tags)
Sourcepub fn get_models_by_task(&self, task: &str) -> Vec<&ModelInfo>
pub fn get_models_by_task(&self, task: &str) -> Vec<&ModelInfo>
Get models by task type (e.g., “chat”, “coding”, “text-generation”)
Sourcepub async fn save_registry(&self) -> Result<()>
pub async fn save_registry(&self) -> Result<()>
Save registry to persistent storage
Sourcepub fn populate_default_catalog(&mut self)
pub fn populate_default_catalog(&mut self)
Populate the registry with well-known models from all sources. Only adds models that are not already in the registry. Also removes stale models that are no longer available.
Sourcepub async fn populate_default_openrouter_models(&mut self)
pub async fn populate_default_openrouter_models(&mut self)
Populate registry with OpenRouter models fetched from the public API. This is called when no API key is available to show users what models are available.
Auto Trait Implementations§
impl Freeze for ModelRegistry
impl RefUnwindSafe for ModelRegistry
impl Send for ModelRegistry
impl Sync for ModelRegistry
impl Unpin for ModelRegistry
impl UnsafeUnpin for ModelRegistry
impl UnwindSafe 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
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>
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>
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