Skip to main content

Provider

Trait Provider 

Source
pub trait Provider: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn auth(&self) -> AuthStyle;
    fn encode(&self, request: &Request<'_>) -> HttpCall;
    fn decode(&self, body: &Value) -> Result<Reply, LlmError>;
    fn error(&self, status: u16, headers: &HeaderMap, body: &str) -> LlmError;
}
Expand description

One wire format. Pure: no network, no clock, no database.

Required Methods§

Source

fn name(&self) -> &'static str

Short name for logs and the audit record (anthropic).

Source

fn auth(&self) -> AuthStyle

How the API key goes into the request.

Source

fn encode(&self, request: &Request<'_>) -> HttpCall

The HTTP request of one model call.

Source

fn decode(&self, body: &Value) -> Result<Reply, LlmError>

The reply from a successful response body.

Source

fn error(&self, status: u16, headers: &HeaderMap, body: &str) -> LlmError

The error for a response with a status outside 2xx.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§