Class: Parse::Agent::MCPClient::Usage
- Inherits:
-
Struct
- Object
- Struct
- Parse::Agent::MCPClient::Usage
- Defined in:
- lib/parse/agent/mcp_client.rb
Overview
Token + cost roll-up. ‘cost_usd` is computed from the model’s pricing row; values are USD dollars (NOT cents). Returned per-call and as a running total via ‘client.usage`.
Instance Attribute Summary collapse
-
#completion_tokens ⇒ Object
Returns the value of attribute completion_tokens.
-
#cost_usd ⇒ Object
Returns the value of attribute cost_usd.
-
#prompt_tokens ⇒ Object
Returns the value of attribute prompt_tokens.
-
#total_tokens ⇒ Object
Returns the value of attribute total_tokens.
Instance Method Summary collapse
- #+(other) ⇒ Object
- #to_s ⇒ Object (also: #inspect)
Instance Attribute Details
#completion_tokens ⇒ Object
Returns the value of attribute completion_tokens
114 115 116 |
# File 'lib/parse/agent/mcp_client.rb', line 114 def completion_tokens @completion_tokens end |
#cost_usd ⇒ Object
Returns the value of attribute cost_usd
114 115 116 |
# File 'lib/parse/agent/mcp_client.rb', line 114 def cost_usd @cost_usd end |
#prompt_tokens ⇒ Object
Returns the value of attribute prompt_tokens
114 115 116 |
# File 'lib/parse/agent/mcp_client.rb', line 114 def prompt_tokens @prompt_tokens end |
#total_tokens ⇒ Object
Returns the value of attribute total_tokens
114 115 116 |
# File 'lib/parse/agent/mcp_client.rb', line 114 def total_tokens @total_tokens end |
Instance Method Details
#+(other) ⇒ Object
115 116 117 118 119 120 121 122 |
# File 'lib/parse/agent/mcp_client.rb', line 115 def +(other) Usage.new( prompt_tokens: prompt_tokens + other.prompt_tokens, completion_tokens: completion_tokens + other.completion_tokens, total_tokens: total_tokens + other.total_tokens, cost_usd: cost_usd + other.cost_usd, ) end |
#to_s ⇒ Object Also known as: inspect
124 125 126 127 |
# File 'lib/parse/agent/mcp_client.rb', line 124 def to_s format("%d in + %d out = %d tokens $%.6f", prompt_tokens, completion_tokens, total_tokens, cost_usd) end |