Skip to main content

Model

Trait Model 

Source
pub trait Model: Send + Sync {
    // Required methods
    fn capabilities<'a>(
        &'a self,
        model: &'a ModelRef,
    ) -> ModelFuture<'a, Result<ModelCapabilities, ModelError>>;
    fn stream(
        &self,
        request: ModelRequest,
        context: ModelCallContext,
    ) -> ModelFuture<'_, Result<ModelEventStream, ModelError>>;

    // Provided method
    fn invoke(
        &self,
        request: ModelRequest,
        context: ModelCallContext,
    ) -> ModelFuture<'_, Result<ModelResponse, ModelError>> { ... }
}
Expand description

Object-safe boundary implemented by model provider adapters.

Streaming is the source of truth. Model::invoke is a canonical collector over that stream, so streamed and non-streamed calls cannot silently develop different normalization behavior.

Required Methods§

Source

fn capabilities<'a>( &'a self, model: &'a ModelRef, ) -> ModelFuture<'a, Result<ModelCapabilities, ModelError>>

Resolves capabilities for a provider-qualified model.

Source

fn stream( &self, request: ModelRequest, context: ModelCallContext, ) -> ModelFuture<'_, Result<ModelEventStream, ModelError>>

Opens a canonical event stream for a request.

Provided Methods§

Source

fn invoke( &self, request: ModelRequest, context: ModelCallContext, ) -> ModelFuture<'_, Result<ModelResponse, ModelError>>

Invokes the model and reconstructs its terminal response.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§