pub struct AutomationUsage {
pub prompt_tokens: u32,
pub completion_tokens: u32,
pub total_tokens: u32,
pub llm_calls: u32,
pub search_calls: u32,
pub fetch_calls: u32,
pub webbrowser_calls: u32,
pub custom_tool_calls: HashMap<String, u32>,
pub api_calls: u32,
}Expand description
Token usage tracking for automation operations with granular call tracking.
Fields§
§prompt_tokens: u32Prompt tokens used.
completion_tokens: u32Completion tokens used.
total_tokens: u32Total tokens used.
llm_calls: u32Number of LLM API calls made.
search_calls: u32Number of search API calls made.
fetch_calls: u32Number of HTTP fetch calls made.
webbrowser_calls: u32Number of web browser automation calls made.
custom_tool_calls: HashMap<String, u32>Custom tool calls tracked by tool name.
api_calls: u32Total number of API/function calls made (sum of all calls).
Implementations§
Source§impl AutomationUsage
impl AutomationUsage
Sourcepub fn new(prompt_tokens: u32, completion_tokens: u32) -> Self
pub fn new(prompt_tokens: u32, completion_tokens: u32) -> Self
Create new usage stats (counts as 1 LLM call).
Sourcepub fn with_api_calls(
prompt_tokens: u32,
completion_tokens: u32,
api_calls: u32,
) -> Self
pub fn with_api_calls( prompt_tokens: u32, completion_tokens: u32, api_calls: u32, ) -> Self
Create new usage stats with API call count (legacy).
Sourcepub fn accumulate(&mut self, other: &Self)
pub fn accumulate(&mut self, other: &Self)
Accumulate usage from another instance.
Sourcepub fn increment_llm_calls(&mut self)
pub fn increment_llm_calls(&mut self)
Increment the LLM call count.
Sourcepub fn increment_search_calls(&mut self)
pub fn increment_search_calls(&mut self)
Increment the search call count.
Sourcepub fn increment_fetch_calls(&mut self)
pub fn increment_fetch_calls(&mut self)
Increment the fetch call count.
Sourcepub fn increment_webbrowser_calls(&mut self)
pub fn increment_webbrowser_calls(&mut self)
Increment the web browser call count.
Sourcepub fn increment_custom_tool_calls(&mut self, tool_name: &str)
pub fn increment_custom_tool_calls(&mut self, tool_name: &str)
Increment a custom tool call count by name.
Sourcepub fn get_custom_tool_calls(&self, tool_name: &str) -> u32
pub fn get_custom_tool_calls(&self, tool_name: &str) -> u32
Get the call count for a specific custom tool.
Sourcepub fn total_custom_tool_calls(&self) -> u32
pub fn total_custom_tool_calls(&self) -> u32
Get total custom tool calls across all tools.
Sourcepub fn increment_api_calls(&mut self)
pub fn increment_api_calls(&mut self)
Increment the API call count (legacy, prefer specific methods).
Trait Implementations§
Source§impl Add for AutomationUsage
impl Add for AutomationUsage
Source§impl AddAssign for AutomationUsage
impl AddAssign for AutomationUsage
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+= operation. Read moreSource§impl Clone for AutomationUsage
impl Clone for AutomationUsage
Source§fn clone(&self) -> AutomationUsage
fn clone(&self) -> AutomationUsage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more