Skip to main content

AiProvider

Trait AiProvider 

Source
pub trait AiProvider: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn generate<'life0, 'async_trait>(
        &'life0 self,
        request: GenerationRequest,
    ) -> Pin<Box<dyn Future<Output = Result<GenerationResponse, AetherError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn generate_stream(
        &self,
        _request: GenerationRequest,
    ) -> Pin<Box<dyn Stream<Item = Result<StreamResponse, AetherError>> + Send>> { ... }
    fn generate_batch<'life0, 'async_trait>(
        &'life0 self,
        requests: Vec<GenerationRequest>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<GenerationResponse>, AetherError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool, AetherError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

Re-export core types for convenience. Trait that AI providers must implement.

This trait defines the interface for generating code from slots.

Required Methods§

Source

fn name(&self) -> &str

Get the provider name.

Source

fn generate<'life0, 'async_trait>( &'life0 self, request: GenerationRequest, ) -> Pin<Box<dyn Future<Output = Result<GenerationResponse, AetherError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Generate code for a slot.

§Arguments
  • request - The generation request containing slot info
§Returns

Generated code response or an error.

Provided Methods§

Source

fn generate_stream( &self, _request: GenerationRequest, ) -> Pin<Box<dyn Stream<Item = Result<StreamResponse, AetherError>> + Send>>

Generate a stream of code for a slot.

§Arguments
  • request - The generation request containing slot info
§Returns

A pinned stream of chunks or an error.

Source

fn generate_batch<'life0, 'async_trait>( &'life0 self, requests: Vec<GenerationRequest>, ) -> Pin<Box<dyn Future<Output = Result<Vec<GenerationResponse>, AetherError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Generate code for multiple slots in batch.

Default implementation calls generate for each slot sequentially.

Source

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

Check if the provider is available and configured correctly.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T> AiProvider for Arc<T>
where T: AiProvider + Send + Sync + ?Sized,

Source§

fn name(&self) -> &str

Source§

fn generate<'life0, 'async_trait>( &'life0 self, request: GenerationRequest, ) -> Pin<Box<dyn Future<Output = Result<GenerationResponse, AetherError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Source§

fn generate_stream( &self, request: GenerationRequest, ) -> Pin<Box<dyn Stream<Item = Result<StreamResponse, AetherError>> + Send>>

Source§

impl<T> AiProvider for Box<T>
where T: AiProvider + Send + Sync + ?Sized,

Source§

fn name(&self) -> &str

Source§

fn generate<'life0, 'async_trait>( &'life0 self, request: GenerationRequest, ) -> Pin<Box<dyn Future<Output = Result<GenerationResponse, AetherError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Box<T>: 'async_trait,

Source§

fn generate_stream( &self, request: GenerationRequest, ) -> Pin<Box<dyn Stream<Item = Result<StreamResponse, AetherError>> + Send>>

Implementors§