Skip to main content

Provider

Trait Provider 

Source
pub trait Provider: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn chat<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        request: &'life1 ChatRequest<'life2>,
    ) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided methods
    fn capabilities(&self) -> ProviderCapabilities { ... }
    fn simple_chat<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        message: &'life1 str,
        model: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

The core Provider trait. Implement this for each LLM backend (Anthropic, OpenAI, Gemini, Ollama, etc.)

Required Methods§

Source

fn name(&self) -> &str

Provider name (e.g., “anthropic”, “openai”, “ollama”)

Source

fn chat<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, request: &'life1 ChatRequest<'life2>, ) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Send a chat request and get a response.

Provided Methods§

Source

fn capabilities(&self) -> ProviderCapabilities

Query capabilities

Source

fn simple_chat<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, message: &'life1 str, model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Simple one-shot message (convenience wrapper)

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§