LlmProvider

Trait LlmProvider 

Source
pub trait LlmProvider:
    Send
    + Sync
    + Debug {
    // Required methods
    fn name(&self) -> &str;
    fn is_available<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn complete<'life0, 'async_trait>(
        &'life0 self,
        request: LlmRequest,
    ) -> Pin<Box<dyn Future<Output = Result<LlmResponse, LlmError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn ask<'life0, 'life1, 'async_trait>(
        &'life0 self,
        prompt: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<String, LlmError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Trait for LLM providers

Required Methods§

Source

fn name(&self) -> &str

Get the provider name

Source

fn is_available<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if the provider is available

Source

fn complete<'life0, 'async_trait>( &'life0 self, request: LlmRequest, ) -> Pin<Box<dyn Future<Output = Result<LlmResponse, LlmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Generate a completion

Provided Methods§

Source

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

Generate with a simple prompt (convenience method)

Implementors§