Skip to main content

BaseProvider

Trait BaseProvider 

Source
pub trait BaseProvider: Send + Sync {
    // Required methods
    fn config(&self) -> &ProviderConfig;
    fn build_request(&self, request: &LLMRequest) -> Result<Request, LLMError>;
    fn parse_response(&self, response: Value) -> Result<LLMResponse, LLMError>;

    // Provided method
    fn execute_request<'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 { ... }
}
Expand description

Base provider trait with common functionality

Required Methods§

Source

fn config(&self) -> &ProviderConfig

Get provider configuration

Source

fn build_request(&self, request: &LLMRequest) -> Result<Request, LLMError>

Build HTTP request for the provider

Source

fn parse_response(&self, response: Value) -> Result<LLMResponse, LLMError>

Parse response from the provider

Provided Methods§

Source

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

Execute LLM request with common error handling and retry logic

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§