pub struct CostTrackingLayer { /* private fields */ }Expand description
Tracks per-request and cumulative cost; optionally enforces a budget.
Implementations§
Source§impl CostTrackingLayer
impl CostTrackingLayer
Sourcepub fn new() -> CostTrackingLayer
pub fn new() -> CostTrackingLayer
Track cost with no spending cap.
Sourcepub fn with_budget(budget_usd: f64) -> CostTrackingLayer
pub fn with_budget(budget_usd: f64) -> CostTrackingLayer
Track cost and refuse requests once budget_usd is reached.
Sourcepub fn session_cost(&self) -> SessionCost
pub fn session_cost(&self) -> SessionCost
Handle to read the running session cost.
Trait Implementations§
Source§impl Clone for CostTrackingLayer
impl Clone for CostTrackingLayer
Source§fn clone(&self) -> CostTrackingLayer
fn clone(&self) -> CostTrackingLayer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for CostTrackingLayer
impl Default for CostTrackingLayer
Source§fn default() -> CostTrackingLayer
fn default() -> CostTrackingLayer
Returns the “default value” for a type. Read more
Source§impl LlmLayer for CostTrackingLayer
impl LlmLayer for CostTrackingLayer
Source§type Provider = CostTracking
type Provider = CostTracking
The provider produced by wrapping
inner.Source§fn layer(self, inner: Arc<dyn LlmProvider>) -> CostTracking
fn layer(self, inner: Arc<dyn LlmProvider>) -> CostTracking
Wrap
inner, returning the decorated provider.Auto Trait Implementations§
impl Freeze for CostTrackingLayer
impl RefUnwindSafe for CostTrackingLayer
impl Send for CostTrackingLayer
impl Sync for CostTrackingLayer
impl Unpin for CostTrackingLayer
impl UnsafeUnpin for CostTrackingLayer
impl UnwindSafe for CostTrackingLayer
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