pub trait LlmExecutor: Send + Sync {
// Required methods
fn exec_chat_response<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model: &'life1 str,
chat_req: ChatRequest,
options: Option<&'life2 ChatOptions>,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn exec_chat_stream_events<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model: &'life1 str,
chat_req: ChatRequest,
options: Option<&'life2 ChatOptions>,
) -> Pin<Box<dyn Future<Output = Result<LlmEventStream>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn name(&self) -> &'static str;
}Expand description
Abstraction over LLM inference backends.
The agent loop calls this trait for both non-streaming (exec_chat_response)
and streaming (exec_chat_stream_events) inference. The default
implementation (GenaiLlmExecutor) delegates to genai::Client.
Required Methods§
Sourcefn exec_chat_response<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model: &'life1 str,
chat_req: ChatRequest,
options: Option<&'life2 ChatOptions>,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn exec_chat_response<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model: &'life1 str,
chat_req: ChatRequest,
options: Option<&'life2 ChatOptions>,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Run a non-streaming chat completion.
Sourcefn exec_chat_stream_events<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model: &'life1 str,
chat_req: ChatRequest,
options: Option<&'life2 ChatOptions>,
) -> Pin<Box<dyn Future<Output = Result<LlmEventStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn exec_chat_stream_events<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model: &'life1 str,
chat_req: ChatRequest,
options: Option<&'life2 ChatOptions>,
) -> Pin<Box<dyn Future<Output = Result<LlmEventStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Run a streaming chat completion, returning a boxed event stream.