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>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn generate_stream(
&self,
_request: GenerationRequest,
) -> BoxStream<'static, Result<StreamResponse>> { ... }
fn generate_batch<'life0, 'async_trait>(
&'life0 self,
requests: Vec<GenerationRequest>,
) -> Pin<Box<dyn Future<Output = Result<Vec<GenerationResponse>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
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>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate<'life0, 'async_trait>(
&'life0 self,
request: GenerationRequest,
) -> Pin<Box<dyn Future<Output = Result<GenerationResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Provided Methods§
Sourcefn generate_stream(
&self,
_request: GenerationRequest,
) -> BoxStream<'static, Result<StreamResponse>>
fn generate_stream( &self, _request: GenerationRequest, ) -> BoxStream<'static, Result<StreamResponse>>
Sourcefn generate_batch<'life0, 'async_trait>(
&'life0 self,
requests: Vec<GenerationRequest>,
) -> Pin<Box<dyn Future<Output = Result<Vec<GenerationResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate_batch<'life0, 'async_trait>(
&'life0 self,
requests: Vec<GenerationRequest>,
) -> Pin<Box<dyn Future<Output = Result<Vec<GenerationResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Generate code for multiple slots in batch.
Default implementation calls generate for each slot sequentially.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".