pub trait LlmBackend: Send + Sync {
// Required methods
fn id(&self) -> String;
fn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model: &'life1 str,
messages: &'life2 [Message],
) -> Pin<Box<dyn Future<Output = Result<Message>> + 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,
model: &'life1 str,
messages: &'life2 [Message],
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<Message>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
A streamable LLM backend (ollama HTTP, llama.cpp in-process, etc).
Required Methods§
Sourcefn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model: &'life1 str,
messages: &'life2 [Message],
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model: &'life1 str,
messages: &'life2 [Message],
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Single-shot completion. Implementations MAY buffer a streamed
response internally — see stream for the streamed
API.
Sourcefn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model: &'life1 str,
messages: &'life2 [Message],
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<Message>>>> + 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,
model: &'life1 str,
messages: &'life2 [Message],
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<Message>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Streamed completion. Yields incremental Message deltas; the last
delta has the final assistant turn.