pub struct MistralRs { /* private fields */ }
Expand description
The MistralRs struct handles sending requests to multiple engines.
It is the core multi-threaded component of mistral.rs, and uses mpsc
Sender
and Receiver
primitives to send and receive requests to the
appropriate engine based on model ID.
Implementations§
Source§impl MistralRs
impl MistralRs
Sourcepub fn get_sender(
&self,
model_id: Option<&str>,
) -> Result<Sender<Request>, MistralRsError>
pub fn get_sender( &self, model_id: Option<&str>, ) -> Result<Sender<Request>, MistralRsError>
Get sender for a specific model. If model_id is None, uses default engine.
pub fn get_id(&self) -> String
pub fn get_creation_time(&self) -> u64
Sourcepub fn get_model_category(
&self,
model_id: Option<&str>,
) -> Result<ModelCategory, MistralRsError>
pub fn get_model_category( &self, model_id: Option<&str>, ) -> Result<ModelCategory, MistralRsError>
Get model category for a specific model. If model_id is None, uses default engine.
pub fn next_request_id(&self) -> usize
Sourcepub async fn add_model(
&self,
model_id: String,
pipeline: Arc<Mutex<dyn Pipeline>>,
method: SchedulerConfig,
config: AddModelConfig,
) -> Result<(), String>
pub async fn add_model( &self, model_id: String, pipeline: Arc<Mutex<dyn Pipeline>>, method: SchedulerConfig, config: AddModelConfig, ) -> Result<(), String>
Add a new model engine to the MistralRs instance
Sourcepub fn remove_model(&self, model_id: &str) -> Result<(), String>
pub fn remove_model(&self, model_id: &str) -> Result<(), String>
Remove a model engine from the MistralRs instance
Sourcepub fn get_default_model_id(&self) -> Result<Option<String>, String>
pub fn get_default_model_id(&self) -> Result<Option<String>, String>
Get the current default model ID
Sourcepub fn set_default_model_id(&self, model_id: &str) -> Result<(), String>
pub fn set_default_model_id(&self, model_id: &str) -> Result<(), String>
Set the default model ID
Sourcepub fn send_request(&self, request: Request) -> Result<(), MistralRsError>
pub fn send_request(&self, request: Request) -> Result<(), MistralRsError>
Dispatch a request to the appropriate engine based on the model_id in the request
pub fn maybe_log_request(this: Arc<Self>, repr: String)
pub fn maybe_log_response<T: Serialize>(this: Arc<Self>, resp: &T)
pub fn maybe_log_error(this: Arc<Self>, err: &dyn Error)
Sourcepub fn get_tools_count(&self, model_id: Option<&str>) -> Result<usize, String>
pub fn get_tools_count(&self, model_id: Option<&str>) -> Result<usize, String>
Get the number of tools available for a specific model (including MCP tools)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MistralRs
impl RefUnwindSafe for MistralRs
impl Send for MistralRs
impl Sync for MistralRs
impl Unpin for MistralRs
impl UnwindSafe for MistralRs
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
§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Forward to the method defined on the type
Any
.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Forward to the method defined on the type
Any
.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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