pub enum ProviderError {
RateLimited {
retry_after: Option<Duration>,
},
Transient(String),
InvalidRequest(String),
InvalidTools(String),
Auth(String),
Billing {
message: String,
affordable_tokens: Option<u64>,
},
QuotaExhausted {
message: String,
resets_at: Option<SystemTime>,
per_model: bool,
in_stream: bool,
},
NotFound(String),
ContextOverflow {
message: String,
limit: Option<u64>,
},
Malformed {
message: String,
parse: bool,
},
Other(String),
NotConfigured,
}Variants§
RateLimited
Transient(String)
InvalidRequest(String)
InvalidTools(String)
The provider refused the request’s tool definitions (a schema it does not compile). Dropping media or options cannot cure it: the same tools are refused again, so only another model may answer.
Auth(String)
Billing
The account cannot pay for the request. affordable_tokens is the
output the provider says it could still pay for, when it says.
QuotaExhausted
A usage quota (a subscription plan’s cap, a daily allowance) is
used up until resets_at, when the provider says. Unlike
ProviderError::RateLimited, waiting seconds does not help.
per_model is true when the quota covers only the requested model;
otherwise it covers every model on the account. in_stream is true
when the provider reported it inside a response it had already
started, so the request was admitted and may have used tokens;
false when the request was refused before any answer.
NotFound(String)
The model or endpoint does not exist here.
ContextOverflow
The request does not fit the model’s context window. limit is
the window in tokens, when the provider states it.
Malformed
The reply could not be read. parse is true when it was not valid
at all (often a cut-off stream, worth another attempt), false when it
parsed but had the wrong shape.
Other(String)
NotConfigured
No model is connected: the daemon holds a stand-in provider that answers every call with this, without any network call.
Implementations§
Source§impl ProviderError
impl ProviderError
Sourcepub fn proves_nothing_spent(&self) -> bool
pub fn proves_nothing_spent(&self) -> bool
The provider refused the request before doing any work, so the call used no tokens: bad credentials, an unknown model, no credit, or a used-up quota reported as a refusal. Anything else (a timeout, a server error, a cut-off or malformed reply, a quota reported inside an answer already started) may have been paid for.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Worth another attempt at the same provider.
Trait Implementations§
Source§impl Clone for ProviderError
impl Clone for ProviderError
Source§impl Debug for ProviderError
impl Debug for ProviderError
Source§impl Display for ProviderError
impl Display for ProviderError
Source§impl Error for ProviderError
impl Error for ProviderError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()