pub trait ModelProvider: Send + Sync {
// Required methods
fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ModelEntry>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn invoke_model<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<ModelStream, CompletionError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
A backend that can list and invoke completion models.
Implementations handle any provider-specific request parameters inside
invoke_model. Providers have no identity of their
own — callers that manage multiple providers (e.g. the daemon) assign each
one a stable unique id at registration time.
Required Methods§
Sourcefn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ModelEntry>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ModelEntry>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List the models available from this provider. The first entry is the provider’s default model.
Sourcefn invoke_model<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<ModelStream, CompletionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn invoke_model<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<ModelStream, CompletionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Invoke a model by its provider-scoped id, streaming the completion response.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".