pub trait ModelClient: Send + Sync {
// Required method
fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ModelRequest,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, CoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn stream<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ModelRequest,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<String, CoreError>>, CoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn complete_with_tools<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 ModelRequest,
_tools: &'life2 [Tool],
) -> Pin<Box<dyn Future<Output = Result<ModelTurn, CoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Expand description
LLM access seam. Implement this to plug in any backend.
Required Methods§
Sourcefn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ModelRequest,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, CoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ModelRequest,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, CoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Produce a complete reply in one shot.
Provided Methods§
Sourcefn stream<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ModelRequest,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<String, CoreError>>, CoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stream<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ModelRequest,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<String, CoreError>>, CoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Stream the reply as a sequence of tokens. The default implementation
yields the full ModelResponse::text as a single chunk, so backends
that only support non-streaming calls work unchanged.
Sourcefn complete_with_tools<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 ModelRequest,
_tools: &'life2 [Tool],
) -> Pin<Box<dyn Future<Output = Result<ModelTurn, CoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn complete_with_tools<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 ModelRequest,
_tools: &'life2 [Tool],
) -> Pin<Box<dyn Future<Output = Result<ModelTurn, CoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Produce a reply that may request tool calls (agentic loop). The default
implementation ignores tools and delegates to
ModelClient::complete, so backends without function-calling support
degrade to a single-shot reply. Override this to drive the agentic loop.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".