pub trait LlmClient: Send + Sync {
// Required method
fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
max_tokens: usize,
) -> Pin<Box<dyn Future<Output = Result<String, LlmError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn complete_structured<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
_schema: &'life2 Value,
max_tokens: usize,
) -> Pin<Box<dyn Future<Output = Result<Value, LlmError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Expand description
LLM client trait — users implement for their LLM provider.
Both methods are async (all LLM calls are network IO).
Required Methods§
Provided Methods§
Sourcefn complete_structured<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
_schema: &'life2 Value,
max_tokens: usize,
) -> Pin<Box<dyn Future<Output = Result<Value, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn complete_structured<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
_schema: &'life2 Value,
max_tokens: usize,
) -> Pin<Box<dyn Future<Output = Result<Value, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Send a prompt with structured output (JSON mode). Default implementation calls complete() and parses JSON.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".