Skip to main content

AiProvider

Trait AiProvider 

Source
pub trait AiProvider: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn is_available<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn request<'life0, 'life1, 'async_trait>(
        &'life0 self,
        req: &'life1 AiRequest,
        events: Option<UnboundedSender<AiEvent>>,
    ) -> Pin<Box<dyn Future<Output = Result<AiResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Trait for AI backends that can process requests.

Implementors provide access to an AI model, either through a local CLI tool (Tier 1) or a direct HTTP API client (Tier 2, future).

Required Methods§

Source

fn name(&self) -> &str

Human-readable name of this provider (e.g., “claude”, “gemini”).

Source

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

Check whether this provider is available (e.g., CLI tool is installed).

Source

fn request<'life0, 'life1, 'async_trait>( &'life0 self, req: &'life1 AiRequest, events: Option<UnboundedSender<AiEvent>>, ) -> Pin<Box<dyn Future<Output = Result<AiResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a request to the AI provider.

If events is provided, real-time events (like tool calls) are sent through the channel during processing.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§