pub struct LlmClient { /* private fields */ }Expand description
Cheap to clone (everything shareable lives behind Arc). Share one instance
across tasks so they all observe the same circuit-breaker state.
Implementations§
Source§impl LlmClient
impl LlmClient
Sourcepub fn new(config: LlmConfig) -> Result<Self>
pub fn new(config: LlmConfig) -> Result<Self>
Build a client with a fresh, default circuit breaker.
Sourcepub fn with_breaker(
config: LlmConfig,
breaker: Arc<CircuitBreaker>,
) -> Result<Self>
pub fn with_breaker( config: LlmConfig, breaker: Arc<CircuitBreaker>, ) -> Result<Self>
Build a client sharing an existing circuit breaker (e.g. one breaker across several clients hitting the same provider).
Sourcepub fn with_image_resolver(self, resolver: Arc<dyn ImageResolver>) -> Self
pub fn with_image_resolver(self, resolver: Arc<dyn ImageResolver>) -> Self
Bind a caller-aware image resolver. Text-only clients need no resolver.
Sourcepub fn breaker(&self) -> &Arc<CircuitBreaker> ⓘ
pub fn breaker(&self) -> &Arc<CircuitBreaker> ⓘ
Access the shared circuit breaker (health checks, metrics).
Sourcepub async fn complete_stream_single_attempt<F>(
&self,
request: &CompletionRequest,
on_delta: F,
) -> Result<CompletionResponse>
pub async fn complete_stream_single_attempt<F>( &self, request: &CompletionRequest, on_delta: F, ) -> Result<CompletionResponse>
Execute one auditable streaming provider attempt. Retry and durable
attempt accounting belong exclusively to af-agent-runtime.
Sourcepub async fn complete_stream_single_attempt_controlled<F>(
&self,
request: &CompletionRequest,
cancellation: &CancellationToken,
deadline: Instant,
on_delta: F,
) -> Result<CompletionResponse>
pub async fn complete_stream_single_attempt_controlled<F>( &self, request: &CompletionRequest, cancellation: &CancellationToken, deadline: Instant, on_delta: F, ) -> Result<CompletionResponse>
Execute one provider attempt bounded by caller cancellation and deadline.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for LlmClient
impl !UnwindSafe for LlmClient
impl Freeze for LlmClient
impl Send for LlmClient
impl Sync for LlmClient
impl Unpin for LlmClient
impl UnsafeUnpin for LlmClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more