pub struct ModelManager { /* private fields */ }Expand description
Manager for handling embedding model lifecycle
Implementations§
Source§impl ModelManager
impl ModelManager
Sourcepub fn new(cache_dir: impl Into<PathBuf>, config: TurboPropConfig) -> Self
pub fn new(cache_dir: impl Into<PathBuf>, config: TurboPropConfig) -> Self
Create a new model manager with the specified cache directory and configuration
Sourcepub fn new_with_defaults(cache_dir: impl Into<PathBuf>) -> Self
pub fn new_with_defaults(cache_dir: impl Into<PathBuf>) -> Self
Create a new model manager with the specified cache directory and default configuration This is a convenience method for cases where only the cache directory is known
Sourcepub fn init_cache(&self) -> Result<()>
pub fn init_cache(&self) -> Result<()>
Initialize the cache directory, creating it if it doesn’t exist
Sourcepub fn is_model_cached(&self, model_name: &ModelName) -> bool
pub fn is_model_cached(&self, model_name: &ModelName) -> bool
Check if a model is cached locally
Sourcepub fn get_model_path(&self, model_name: &ModelName) -> PathBuf
pub fn get_model_path(&self, model_name: &ModelName) -> PathBuf
Get the local path where a model should be cached
Sourcepub fn get_available_models(&self) -> Vec<ModelInfo>
pub fn get_available_models(&self) -> Vec<ModelInfo>
Get information about available models
Sourcepub fn default_model() -> &'static str
pub fn default_model() -> &'static str
Get the default model name
Sourcepub fn clear_cache(&self) -> Result<()>
pub fn clear_cache(&self) -> Result<()>
Clear the model cache (removes all cached models)
Sourcepub fn remove_model(&self, model_name: &ModelName) -> Result<()>
pub fn remove_model(&self, model_name: &ModelName) -> Result<()>
Remove a specific model from the cache
Sourcepub async fn download_gguf_model(
&self,
model_info: &ModelInfo,
) -> Result<PathBuf>
pub async fn download_gguf_model( &self, model_info: &ModelInfo, ) -> Result<PathBuf>
Download a GGUF model file and cache it locally
This method downloads the model from the provided URL and stores it in the cache directory. If the model is already cached, it returns the existing path without re-downloading.
§Arguments
model_info- Model information including download URL
§Returns
Result<PathBuf>- Path to the cached model file
§Examples
let manager = ModelManager::default();
let model_info = ModelInfo::gguf_model(
ModelName::from("nomic-embed-code.Q5_K_S.gguf"),
"Nomic code embedding model".to_string(),
768,
2_500_000_000,
"https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/resolve/main/nomic-embed-code.Q5_K_S.gguf".to_string(),
);
let model_path = manager.download_gguf_model(&model_info).await.unwrap();Sourcepub async fn download_huggingface_model(
&self,
model_name: &str,
) -> Result<PathBuf>
pub async fn download_huggingface_model( &self, model_name: &str, ) -> Result<PathBuf>
Download a HuggingFace model and cache it locally
This method downloads a HuggingFace model using the transformers library format and stores it in the cache directory. For now, this is a placeholder that will be implemented when HuggingFace backend integration is complete.
§Arguments
model_name- Name of the HuggingFace model to download
§Returns
Result<PathBuf>- Path to the cached model directory
§Examples
let manager = ModelManager::default();
let model_path = manager.download_huggingface_model("Qwen/Qwen3-Embedding-0.6B").await.unwrap();Sourcepub fn get_cache_stats(&self) -> Result<CacheStats>
pub fn get_cache_stats(&self) -> Result<CacheStats>
Get cache statistics
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ModelManager
impl RefUnwindSafe for ModelManager
impl Send for ModelManager
impl Sync for ModelManager
impl Unpin for ModelManager
impl UnsafeUnpin for ModelManager
impl UnwindSafe for ModelManager
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
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> ErasedDestructor for Twhere
T: 'static,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().