Skip to main content

AiProvider

Trait AiProvider 

Source
pub trait AiProvider: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn supported_models(&self) -> HashSet<Model>;
    fn converse<'life0, 'async_trait>(
        &'life0 self,
        request: ConversationRequest,
    ) -> Pin<Box<dyn Future<Output = Result<ConversationResponse, AiError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_cost(&self, model: &Model) -> Cost;

    // Provided methods
    fn converse_stream<'life0, 'async_trait>(
        &'life0 self,
        request: ConversationRequest,
    ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamEvent, AiError>> + Send>>, AiError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn tweaks(&self) -> ModelTweaks { ... }
}

Required Methods§

Source

fn name(&self) -> &'static str

Source

fn supported_models(&self) -> HashSet<Model>

Source

fn converse<'life0, 'async_trait>( &'life0 self, request: ConversationRequest, ) -> Pin<Box<dyn Future<Output = Result<ConversationResponse, AiError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn get_cost(&self, model: &Model) -> Cost

Provided Methods§

Source

fn converse_stream<'life0, 'async_trait>( &'life0 self, request: ConversationRequest, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamEvent, AiError>> + Send>>, AiError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn tweaks(&self) -> ModelTweaks

Implementors§