Class: Llmshim::Usage
- Inherits:
-
Struct
- Object
- Struct
- Llmshim::Usage
- Defined in:
- lib/llmshim/types.rb
Overview
Token accounting returned with a chat response or a usage stream event.
Mirrors the Usage schema in api/openapi.yaml.
Instance Attribute Summary collapse
-
#input_tokens ⇒ Object
Returns the value of attribute input_tokens.
-
#output_tokens ⇒ Object
Returns the value of attribute output_tokens.
-
#reasoning_tokens ⇒ Object
Returns the value of attribute reasoning_tokens.
-
#total_tokens ⇒ Object
Returns the value of attribute total_tokens.
Class Method Summary collapse
Instance Attribute Details
#input_tokens ⇒ Object
Returns the value of attribute input_tokens
7 8 9 |
# File 'lib/llmshim/types.rb', line 7 def input_tokens @input_tokens end |
#output_tokens ⇒ Object
Returns the value of attribute output_tokens
7 8 9 |
# File 'lib/llmshim/types.rb', line 7 def output_tokens @output_tokens end |
#reasoning_tokens ⇒ Object
Returns the value of attribute reasoning_tokens
7 8 9 |
# File 'lib/llmshim/types.rb', line 7 def reasoning_tokens @reasoning_tokens end |
#total_tokens ⇒ Object
Returns the value of attribute total_tokens
7 8 9 |
# File 'lib/llmshim/types.rb', line 7 def total_tokens @total_tokens end |
Class Method Details
.from_hash(hash) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/llmshim/types.rb', line 11 def self.from_hash(hash) return nil if hash.nil? new( input_tokens: hash["input_tokens"], output_tokens: hash["output_tokens"], reasoning_tokens: hash["reasoning_tokens"], total_tokens: hash["total_tokens"] ) end |