pub trait ModelClient: Send + Sync {
// Required method
fn stream<'life0, 'async_trait>(
&'life0 self,
input: ModelTurnInput,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<ModelChunk, ModelClientError>>, ModelClientError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn next<'life0, 'async_trait>(
&'life0 self,
input: ModelTurnInput,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ModelClientError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Required Methods§
Sourcefn stream<'life0, 'async_trait>(
&'life0 self,
input: ModelTurnInput,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<ModelChunk, ModelClientError>>, ModelClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stream<'life0, 'async_trait>(
&'life0 self,
input: ModelTurnInput,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<ModelChunk, ModelClientError>>, ModelClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stream the model’s response as a sequence of ModelChunks. Production
ScriptedModelClient / OpenAiCompatibleModelClient implement this;
next() is provided as a folding convenience for callers that don’t
need token-level events.
Provided Methods§
Sourcefn next<'life0, 'async_trait>(
&'life0 self,
input: ModelTurnInput,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ModelClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn next<'life0, 'async_trait>(
&'life0 self,
input: ModelTurnInput,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ModelClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Buffer the stream into a single ModelResponse. Default impl
awaits every chunk and then runs collect_model_response. Override
only if a provider has a cheaper non-streaming path (none today —
even OpenAI’s non-stream call still goes through the same SSE-or-not
branch on our side).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".