pub struct WorkflowTracker { /* private fields */ }Expand description
Tracks costs and usage per workflow
Implementations§
Source§impl WorkflowTracker
impl WorkflowTracker
Sourcepub fn set_budget(&self, workflow_id: &str, budget: BudgetLimit)
pub fn set_budget(&self, workflow_id: &str, budget: BudgetLimit)
Set a budget limit for a workflow
Sourcepub fn record_usage(
&self,
workflow_id: &str,
prompt_tokens: u32,
completion_tokens: u32,
cost_cents: u64,
)
pub fn record_usage( &self, workflow_id: &str, prompt_tokens: u32, completion_tokens: u32, cost_cents: u64, )
Record usage for a workflow
Sourcepub fn can_afford(&self, workflow_id: &str, estimated_cost_cents: u64) -> bool
pub fn can_afford(&self, workflow_id: &str, estimated_cost_cents: u64) -> bool
Check if a workflow can afford a request (budget check)
Sourcepub fn get_stats(&self, workflow_id: &str) -> WorkflowStats
pub fn get_stats(&self, workflow_id: &str) -> WorkflowStats
Get statistics for a workflow
Sourcepub fn get_all_stats(&self) -> Vec<WorkflowStats>
pub fn get_all_stats(&self) -> Vec<WorkflowStats>
Get statistics for all workflows
Trait Implementations§
Source§impl Clone for WorkflowTracker
impl Clone for WorkflowTracker
Source§fn clone(&self) -> WorkflowTracker
fn clone(&self) -> WorkflowTracker
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WorkflowTracker
impl RefUnwindSafe for WorkflowTracker
impl Send for WorkflowTracker
impl Sync for WorkflowTracker
impl Unpin for WorkflowTracker
impl UnwindSafe for WorkflowTracker
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