pub trait Provider: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn call<'a>(
&'a self,
req: LlmRequest,
) -> BoxFut<'a, Result<AssistantMessage, RuntimeError>>;
fn call_streaming(&self, req: LlmRequest) -> Observable<AssistantMessage>;
// Provided methods
fn capabilities(&self) -> ProviderCapabilities { ... }
fn context_prefix(
&self,
req: &LlmRequest,
) -> Result<ContextPrefixSnapshot, RuntimeError> { ... }
fn discover_models(&self) -> BoxFut<'static, Vec<DiscoveredModel>> { ... }
fn try_discover_models(
&self,
) -> BoxFut<'static, Result<Vec<DiscoveredModelDetails>, ModelDiscoveryError>> { ... }
fn test_connection(&self) -> BoxFut<'_, Result<String, String>> { ... }
}Required Methods§
fn name(&self) -> &str
fn call<'a>( &'a self, req: LlmRequest, ) -> BoxFut<'a, Result<AssistantMessage, RuntimeError>>
fn call_streaming(&self, req: LlmRequest) -> Observable<AssistantMessage>
Provided Methods§
fn capabilities(&self) -> ProviderCapabilities
Sourcefn context_prefix(
&self,
req: &LlmRequest,
) -> Result<ContextPrefixSnapshot, RuntimeError>
fn context_prefix( &self, req: &LlmRequest, ) -> Result<ContextPrefixSnapshot, RuntimeError>
Project the cacheable prompt sequence in provider order.
The default preserves provider-neutral tool/system/message boundaries. Providers with a distinct wire projection override this method.
Sourcefn discover_models(&self) -> BoxFut<'static, Vec<DiscoveredModel>>
fn discover_models(&self) -> BoxFut<'static, Vec<DiscoveredModel>>
Discover available models without capability provenance.
Sourcefn try_discover_models(
&self,
) -> BoxFut<'static, Result<Vec<DiscoveredModelDetails>, ModelDiscoveryError>>
fn try_discover_models( &self, ) -> BoxFut<'static, Result<Vec<DiscoveredModelDetails>, ModelDiscoveryError>>
Discover available models with capability provenance and typed failures. The default treats non-empty compatibility results as legacy capability data and reports an empty result as unsupported.
fn test_connection(&self) -> BoxFut<'_, Result<String, String>>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".