pub struct ModelManager { /* private fields */ }Expand description
Thread-safe model session manager with caching and hot-swap support.
Manages the lifecycle of ONNX models used for embedding generation, including loading, caching, and version management.
Implementations§
Source§impl ModelManager
impl ModelManager
Sourcepub fn new(config: ModelConfig) -> Result<Self, ModelError>
pub fn new(config: ModelConfig) -> Result<Self, ModelError>
Create a new model manager with the given configuration.
§Errors
Returns an error if the model directory doesn’t exist and can’t be created.
Sourcepub fn with_defaults() -> Result<Self, ModelError>
pub fn with_defaults() -> Result<Self, ModelError>
Create with default configuration
Sourcepub fn load_model(&self, name: &str) -> Result<Arc<OnnxInference>, ModelError>
pub fn load_model(&self, name: &str) -> Result<Arc<OnnxInference>, ModelError>
Sourcepub fn verify_checksum(
&self,
path: &Path,
expected: &str,
) -> Result<bool, ModelError>
pub fn verify_checksum( &self, path: &Path, expected: &str, ) -> Result<bool, ModelError>
Sourcepub async fn get_inference(&self) -> Result<Arc<OnnxInference>, ModelError>
pub async fn get_inference(&self) -> Result<Arc<OnnxInference>, ModelError>
Get the ONNX inference engine for the current model.
§Errors
Returns an error if no model is loaded.
Sourcepub fn current_version(&self) -> ModelVersion
pub fn current_version(&self) -> ModelVersion
Get the currently active model version.
Sourcepub fn set_active_version(&self, version: ModelVersion)
pub fn set_active_version(&self, version: ModelVersion)
Set the active model version.
Sourcepub fn get_model(&self, version_key: &str) -> Option<EmbeddingModel>
pub fn get_model(&self, version_key: &str) -> Option<EmbeddingModel>
Get model metadata for a version.
Sourcepub fn list_models(&self) -> Vec<EmbeddingModel>
pub fn list_models(&self) -> Vec<EmbeddingModel>
List all loaded models.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clear all cached sessions.
Sourcepub fn register_model(&self, model: EmbeddingModel)
pub fn register_model(&self, model: EmbeddingModel)
Register a model without loading it.
Sourcepub fn unload_model(&self, version_key: &str) -> bool
pub fn unload_model(&self, version_key: &str) -> bool
Unload a specific model version from cache.
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 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
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