Skip to main content

Provider

Trait Provider 

Source
pub trait Provider: Send + Sync {
    // Required methods
    fn id(&self) -> &str;
    fn default_model(&self) -> &str;
    fn complete<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        req: &'life1 CompletionRequest,
        sink: Option<&'life2 StreamSink>,
    ) -> Pin<Box<dyn Future<Output = Result<CompletionResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn vision(&self) -> bool { ... }
}

Required Methods§

Source

fn id(&self) -> &str

Stable identifier used in config and --provider.

Source

fn default_model(&self) -> &str

Model used when the caller doesn’t name one.

Source

fn complete<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, req: &'life1 CompletionRequest, sink: Option<&'life2 StreamSink>, ) -> Pin<Box<dyn Future<Output = Result<CompletionResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Run one turn. With sink, stream and emit deltas as they arrive; the accumulated response is still returned.

Provided Methods§

Source

fn vision(&self) -> bool

Whether this provider will actually put an image in front of a model.

Asked by whatever is about to build an image block — the Slack connector, the TUI — so it can name a file instead of reading and base64-encoding one that would only be rendered as text anyway. The encoders degrade correctly without this; what it saves is a megabyte of base64 written into a transcript for nothing.

Defaults to false, so a provider added later is text-only until somebody says otherwise — the direction that fails safe, on the unrouted_domains reasoning: forgetting costs a feature that does not fire, and the alternative costs a failed request.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§