Skip to main content

ModelGateway

Trait ModelGateway 

Source
pub trait ModelGateway: Send + Sync {
    // Required method
    fn invoke<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        request: &'life1 ModelRequest,
        control: &'life2 AttemptControl,
    ) -> Pin<Box<dyn Future<Output = Result<ModelOutput, ModelInvokeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn stream<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        request: &'life1 ModelRequest,
        control: &'life2 AttemptControl,
    ) -> Pin<Box<dyn Future<Output = Result<ModelStream, ModelInvokeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

The model-invocation port: concrete gateways (provider adapters) live outside the kernel and translate ModelRequests onto their transport, honoring the attempt’s control plane.

Required Methods§

Source

fn invoke<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, request: &'life1 ModelRequest, control: &'life2 AttemptControl, ) -> Pin<Box<dyn Future<Output = Result<ModelOutput, ModelInvokeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Runs one attempt: renders request for the provider and returns the assembled ModelOutput, or a classified ModelInvokeError. Cancellation and the deadline arrive through control.

Provided Methods§

Source

fn stream<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, request: &'life1 ModelRequest, control: &'life2 AttemptControl, ) -> Pin<Box<dyn Future<Output = Result<ModelStream, ModelInvokeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Streaming completion. Default implementation: degenerates to a single StreamDelta::Done after invoke — providers that never implemented streaming keep working through the same port; streaming providers override to expose real token increments.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§