pub trait LlmProvider: Send + Sync {
// Required method
fn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn complete_structured<'life0, 'async_trait>(
&'life0 self,
_req: StructuredRequest,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
stream_tx: Option<StreamSender>,
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Required Methods§
fn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Provided Methods§
Sourcefn complete_structured<'life0, 'async_trait>(
&'life0 self,
_req: StructuredRequest,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn complete_structured<'life0, 'async_trait>(
&'life0 self,
_req: StructuredRequest,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Request a JSON response conforming to a caller-supplied schema. Default impl returns an error. Providers that support structured output (e.g. OpenAI-compatible) override this.
Sourcefn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
stream_tx: Option<StreamSender>,
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
stream_tx: Option<StreamSender>,
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Stream a completion token-by-token.
The default implementation delegates to LlmProvider::complete and emits the
entire content as a single delta via the channel (if configured).
Providers that support native SSE streaming should override this.
The stream_tx channel receives partial-token deltas as they are
parsed. The returned Completion is the fully accumulated result.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".