Trait LLM

Source
pub trait LLM:
    Sync
    + Send
    + LLMClone {
    // Required methods
    fn generate<'life0, 'life1, 'async_trait>(
        &'life0 self,
        messages: &'life1 [Message],
    ) -> Pin<Box<dyn Future<Output = Result<GenerateResult, LLMError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn stream<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _messages: &'life1 [Message],
    ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamData, LLMError>> + Send>>, LLMError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn invoke<'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 { ... }
    fn add_options(&mut self, _options: CallOptions) { ... }
    fn messages_to_string(&self, messages: &[Message]) -> String { ... }
}

Required Methods§

Source

fn generate<'life0, 'life1, 'async_trait>( &'life0 self, messages: &'life1 [Message], ) -> Pin<Box<dyn Future<Output = Result<GenerateResult, LLMError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn stream<'life0, 'life1, 'async_trait>( &'life0 self, _messages: &'life1 [Message], ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamData, LLMError>> + Send>>, LLMError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Provided Methods§

Source

fn invoke<'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,

Source

fn add_options(&mut self, _options: CallOptions)

This is usefull when you want to create a chain and override LLM options

Source

fn messages_to_string(&self, messages: &[Message]) -> String

Trait Implementations§

Source§

impl<L> From<L> for Box<dyn LLM>
where L: 'static + LLM,

Source§

fn from(llm: L) -> Self

Converts to this type from the input type.

Implementors§

Source§

impl LLM for Claude

Source§

impl<C: Config + Send + Sync + 'static> LLM for OpenAI<C>