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) -> AutomationUsage
pub fn new(prompt_tokens: u32, completion_tokens: u32) -> AutomationUsage
Create new usage stats (counts as 1 LLM call).
Sourcepub fn with_api_calls(
prompt_tokens: u32,
completion_tokens: u32,
api_calls: u32,
) -> AutomationUsage
pub fn with_api_calls( prompt_tokens: u32, completion_tokens: u32, api_calls: u32, ) -> AutomationUsage
Create new usage stats with API call count (legacy).
Sourcepub fn accumulate(&mut self, other: &AutomationUsage)
pub fn accumulate(&mut self, other: &AutomationUsage)
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§type Output = AutomationUsage
type Output = AutomationUsage
+ operator.Source§fn add(self, other: AutomationUsage) -> AutomationUsage
fn add(self, other: AutomationUsage) -> AutomationUsage
+ operation. Read moreSource§impl AddAssign for AutomationUsage
impl AddAssign for AutomationUsage
Source§fn add_assign(&mut self, other: AutomationUsage)
fn add_assign(&mut self, other: AutomationUsage)
+= 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 moreSource§impl Debug for AutomationUsage
impl Debug for AutomationUsage
Source§impl Default for AutomationUsage
impl Default for AutomationUsage
Source§fn default() -> AutomationUsage
fn default() -> AutomationUsage
Source§impl<'de> Deserialize<'de> for AutomationUsage
impl<'de> Deserialize<'de> for AutomationUsage
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<AutomationUsage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AutomationUsage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for AutomationUsage
impl PartialEq for AutomationUsage
Source§impl Serialize for AutomationUsage
impl Serialize for AutomationUsage
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for AutomationUsage
Auto Trait Implementations§
impl Freeze for AutomationUsage
impl RefUnwindSafe for AutomationUsage
impl Send for AutomationUsage
impl Sync for AutomationUsage
impl Unpin for AutomationUsage
impl UnwindSafe for AutomationUsage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.