pub struct RefreshingProvider<P, F> { /* private fields */ }Expand description
Wraps a provider with host-driven credential refresh on 401.
The inner provider is stored behind Arc<Mutex<P>> so it can be swapped
atomically when the refresh callback produces a new provider. Cloning a
wrapper is cheap — clones share the same inner state.
Metadata (model, provider, configured_thinking) and capability shaping
(capabilities, default_max_tokens, validate_thinking_config,
structured_output_support) are captured from the initial provider at
construction time and assumed constant across refreshes (the refresh
callback rebuilds the same provider shape with a fresh token, not a
different model).
Implementations§
Source§impl<P, F, Fut> RefreshingProvider<P, F>
impl<P, F, Fut> RefreshingProvider<P, F>
Sourcepub fn new(inner: P, refresh: F) -> Self
pub fn new(inner: P, refresh: F) -> Self
Build a wrapper from an initial provider and a refresh callback.
The refresh callback is invoked each time the inner provider emits a 401 response. It must be idempotent and safe to call concurrently. The callback should return a fully-built provider ready to use; typically it reads fresh credentials from its auth store and calls the inner provider’s constructor.
Trait Implementations§
Source§impl<P: Clone, F> Clone for RefreshingProvider<P, F>
impl<P: Clone, F> Clone for RefreshingProvider<P, F>
Source§impl<P, F, Fut> LlmProvider for RefreshingProvider<P, F>
impl<P, F, Fut> LlmProvider for RefreshingProvider<P, F>
Source§fn chat<'life0, 'async_trait>(
&'life0 self,
request: ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatOutcome>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat<'life0, 'async_trait>(
&'life0 self,
request: ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatOutcome>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn chat_stream(&self, request: ChatRequest) -> StreamBox<'_>
fn chat_stream(&self, request: ChatRequest) -> StreamBox<'_>
fn model(&self) -> &str
fn provider(&self) -> &'static str
Source§fn configured_thinking(&self) -> Option<&ThinkingConfig>
fn configured_thinking(&self) -> Option<&ThinkingConfig>
Source§fn capabilities(&self) -> Option<&'static ModelCapabilities>
fn capabilities(&self) -> Option<&'static ModelCapabilities>
Source§fn validate_thinking_config(
&self,
thinking: Option<&ThinkingConfig>,
) -> Result<()>
fn validate_thinking_config( &self, thinking: Option<&ThinkingConfig>, ) -> Result<()>
Source§fn default_max_tokens(&self) -> u32
fn default_max_tokens(&self) -> u32
AgentConfig.max_tokens.Source§fn structured_output_support(&self) -> StructuredOutputSupport
fn structured_output_support(&self) -> StructuredOutputSupport
ResponseFormat) request. Read more