Skip to main content

LLMClient

Trait LLMClient 

Source
pub trait LLMClient: Send + Sync {
Show 14 methods // Required methods fn generate<'life0, 'life1, 'async_trait>( &'life0 self, prompt: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<String, AppError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn generate_with_system<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, system: &'life1 str, prompt: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<String, AppError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait; fn generate_with_history<'life0, 'life1, 'async_trait>( &'life0 self, messages: &'life1 [(String, String)], ) -> Pin<Box<dyn Future<Output = Result<LLMResponse, AppError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn generate_with_tools<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, prompt: &'life1 str, tools: &'life2 [ToolDefinition], ) -> Pin<Box<dyn Future<Output = Result<LLMResponse, AppError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait; fn generate_with_tools_and_history<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, messages: &'life1 [ConversationMessage], tools: &'life2 [ToolDefinition], ) -> Pin<Box<dyn Future<Output = Result<LLMResponse, AppError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait; fn stream<'life0, 'life1, 'async_trait>( &'life0 self, prompt: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<String, AppError>> + Unpin + Send>, AppError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn stream_with_system<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, system: &'life1 str, prompt: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<String, AppError>> + Unpin + Send>, AppError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait; fn stream_with_history<'life0, 'life1, 'async_trait>( &'life0 self, messages: &'life1 [(String, String)], ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<String, AppError>> + Unpin + Send>, AppError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn model_name(&self) -> &str; // Provided methods fn supports_hints(&self) -> bool { ... } fn set_hints(&self, _hints: GenerationHints) { ... } fn embed<'life0, 'life1, 'async_trait>( &'life0 self, _inputs: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, AppError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait { ... } fn supports_vision(&self) -> bool { ... } fn supports_provider_web_search(&self) -> bool { ... }
}
Expand description

Generic LLM client trait for provider abstraction

Required Methods§

Source

fn generate<'life0, 'life1, 'async_trait>( &'life0 self, prompt: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<String, AppError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Generate a completion from a prompt

Source

fn generate_with_system<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, system: &'life1 str, prompt: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<String, AppError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Generate with system prompt

Source

fn generate_with_history<'life0, 'life1, 'async_trait>( &'life0 self, messages: &'life1 [(String, String)], ) -> Pin<Box<dyn Future<Output = Result<LLMResponse, AppError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Generate with conversation history, returning full response with token usage

Source

fn generate_with_tools<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, prompt: &'life1 str, tools: &'life2 [ToolDefinition], ) -> Pin<Box<dyn Future<Output = Result<LLMResponse, AppError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Generate with tool calling support

Source

fn generate_with_tools_and_history<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, messages: &'life1 [ConversationMessage], tools: &'life2 [ToolDefinition], ) -> Pin<Box<dyn Future<Output = Result<LLMResponse, AppError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Generate with conversation history AND tool definitions.

Source

fn stream<'life0, 'life1, 'async_trait>( &'life0 self, prompt: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<String, AppError>> + Unpin + Send>, AppError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Stream a completion

Source

fn stream_with_system<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, system: &'life1 str, prompt: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<String, AppError>> + Unpin + Send>, AppError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Stream a completion with system prompt

Source

fn stream_with_history<'life0, 'life1, 'async_trait>( &'life0 self, messages: &'life1 [(String, String)], ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<String, AppError>> + Unpin + Send>, AppError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Stream a completion with conversation history

Source

fn model_name(&self) -> &str

Get the model name/identifier

Provided Methods§

Source

fn supports_hints(&self) -> bool

Whether this client honors GenerationHints set via LLMClient::set_hints. Defaults to false; hint-aware providers override this together with set_hints.

Source

fn set_hints(&self, _hints: GenerationHints)

Store generation hints applying to SUBSEQUENT generate calls, until replaced (clear with GenerationHints::default()). Default impl is a no-op so unmodified providers keep compiling unchanged.

Source

fn embed<'life0, 'life1, 'async_trait>( &'life0 self, _inputs: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, AppError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Embed one or more input strings. Default: not supported.

Source

fn supports_vision(&self) -> bool

Whether this client can send image/file parts.

Whether this client can attach the provider built-in web search tool.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§