pub struct Client { /* private fields */ }Expand description
The main client for interacting with the modelexpress_server via gRPC
Implementations§
Source§impl Client
impl Client
Sourcepub async fn new(config: Config) -> CommonResult<Self>
pub async fn new(config: Config) -> CommonResult<Self>
Create a new client with the given configuration
Sourcepub async fn new_with_cache(
config: Config,
cache_config: CacheConfig,
) -> CommonResult<Self>
pub async fn new_with_cache( config: Config, cache_config: CacheConfig, ) -> CommonResult<Self>
Create a new client with cache configuration
Sourcepub fn get_cache_config(&self) -> Option<&CacheConfig>
pub fn get_cache_config(&self) -> Option<&CacheConfig>
Get cache configuration
Sourcepub fn set_cache_config(&mut self, cache_config: CacheConfig)
pub fn set_cache_config(&mut self, cache_config: CacheConfig)
Set cache configuration
Sourcepub fn list_cached_models(&self) -> CommonResult<CacheStats>
pub fn list_cached_models(&self) -> CommonResult<CacheStats>
List cached models
Sourcepub fn clear_cached_model(&self, model_name: &str) -> CommonResult<()>
pub fn clear_cached_model(&self, model_name: &str) -> CommonResult<()>
Clear specific model from cache
Sourcepub fn clear_all_cached_models(&self) -> CommonResult<()>
pub fn clear_all_cached_models(&self) -> CommonResult<()>
Clear entire cache
pub async fn get_model_path(&self, model_name: &str) -> Result<PathBuf>
Sourcepub async fn preload_model_to_cache(
&mut self,
model_name: &str,
provider: ModelProvider,
ignore_weights: bool,
) -> CommonResult<()>
pub async fn preload_model_to_cache( &mut self, model_name: &str, provider: ModelProvider, ignore_weights: bool, ) -> CommonResult<()>
Pre-download model to cache
Sourcepub async fn health_check(&mut self) -> CommonResult<Status>
pub async fn health_check(&mut self) -> CommonResult<Status>
Get the server health status
Sourcepub async fn send_request<T: DeserializeOwned>(
&mut self,
action: impl Into<String>,
payload: Option<HashMap<String, Value>>,
) -> CommonResult<T>
pub async fn send_request<T: DeserializeOwned>( &mut self, action: impl Into<String>, payload: Option<HashMap<String, Value>>, ) -> CommonResult<T>
Send a request to the server
Sourcepub async fn request_model_with_provider_and_fallback(
&mut self,
model_name: impl Into<String>,
provider: ModelProvider,
ignore_weights: bool,
) -> CommonResult<()>
pub async fn request_model_with_provider_and_fallback( &mut self, model_name: impl Into<String>, provider: ModelProvider, ignore_weights: bool, ) -> CommonResult<()>
Request a model from the server with a specific provider and automatic fallback This function will first try to use the server for streaming downloads. If the server is unavailable, it will fallback to downloading directly.
Sourcepub async fn request_model_with_provider(
&mut self,
model_name: impl Into<String>,
provider: ModelProvider,
ignore_weights: bool,
) -> CommonResult<()>
pub async fn request_model_with_provider( &mut self, model_name: impl Into<String>, provider: ModelProvider, ignore_weights: bool, ) -> CommonResult<()>
Request a model from the server with a specific provider This function will wait until the model is downloaded using streaming updates
Sourcepub async fn request_model(
&mut self,
model_name: impl Into<String>,
ignore_weights: bool,
) -> CommonResult<()>
pub async fn request_model( &mut self, model_name: impl Into<String>, ignore_weights: bool, ) -> CommonResult<()>
Request a model from the server using the default provider (Hugging Face) with automatic fallback This function will first try to use the server, then fallback to direct download if needed
Sourcepub async fn request_model_server_only(
&mut self,
model_name: impl Into<String>,
ignore_weights: bool,
) -> CommonResult<()>
pub async fn request_model_server_only( &mut self, model_name: impl Into<String>, ignore_weights: bool, ) -> CommonResult<()>
Request a model from the server only (no fallback) This function will wait until the model is downloaded using streaming updates from the server
Sourcepub async fn request_model_with_smart_fallback(
model_name: impl Into<String>,
provider: ModelProvider,
config: Config,
ignore_weights: bool,
) -> CommonResult<()>
pub async fn request_model_with_smart_fallback( model_name: impl Into<String>, provider: ModelProvider, config: Config, ignore_weights: bool, ) -> CommonResult<()>
Request a model with automatic server fallback, creating client connection only if needed This function will try to download via server if possible, otherwise download directly
Sourcepub async fn download_model_directly(
model_name: impl Into<String>,
provider: ModelProvider,
ignore_weights: bool,
) -> CommonResult<()>
pub async fn download_model_directly( model_name: impl Into<String>, provider: ModelProvider, ignore_weights: bool, ) -> CommonResult<()>
Download a model directly without using the server This bypasses the server entirely and downloads the model using the specified provider
Auto Trait Implementations§
impl !Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request