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§
Sourcefn 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,
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§
Sourcefn generate_stream(
&self,
_request: GenerationRequest,
) -> Pin<Box<dyn Stream<Item = Result<StreamResponse, AetherError>> + Send>>
fn generate_stream( &self, _request: GenerationRequest, ) -> Pin<Box<dyn Stream<Item = Result<StreamResponse, AetherError>> + Send>>
Sourcefn 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 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.
Sourcefn 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,
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".