pub trait LLMAdapter: Send + Sync {
// Required methods
fn provider(&self) -> &str;
fn model(&self) -> &str;
fn generate<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: &'life1 [LLMMessage],
) -> Pin<Box<dyn Future<Output = Result<LLMResponse, LLMError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn generate_stream(
&self,
messages: &[LLMMessage],
) -> Pin<Box<dyn Stream<Item = Result<StreamChunk, LLMError>> + Send + '_>>;
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool, LLMError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Trait for LLM adapters.
Implement this trait to add support for a new LLM provider.
Required Methods§
Sourcefn generate<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: &'life1 [LLMMessage],
) -> Pin<Box<dyn Future<Output = Result<LLMResponse, LLMError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn generate<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: &'life1 [LLMMessage],
) -> Pin<Box<dyn Future<Output = Result<LLMResponse, LLMError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn generate_stream(
&self,
messages: &[LLMMessage],
) -> Pin<Box<dyn Stream<Item = Result<StreamChunk, LLMError>> + Send + '_>>
fn generate_stream( &self, messages: &[LLMMessage], ) -> Pin<Box<dyn Stream<Item = Result<StreamChunk, LLMError>> + Send + '_>>
Generate a streaming completion.
Returns a stream of chunks that can be processed as they arrive.