Class: Legion::Extensions::Llm::Tokens
- Inherits:
-
Object
- Object
- Legion::Extensions::Llm::Tokens
- Defined in:
- lib/legion/extensions/llm/tokens.rb
Overview
Represents token usage for a response.
Instance Attribute Summary collapse
-
#cache_creation ⇒ Object
readonly
Returns the value of attribute cache_creation.
-
#cached ⇒ Object
readonly
Returns the value of attribute cached.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#thinking ⇒ Object
readonly
Returns the value of attribute thinking.
Class Method Summary collapse
-
.build(input: nil, output: nil, cached: nil, cache_creation: nil, thinking: nil, reasoning: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists.
Instance Method Summary collapse
-
#initialize(input: nil, output: nil, cached: nil, cache_creation: nil, thinking: nil, reasoning: nil) ⇒ Tokens
constructor
rubocop:disable Metrics/ParameterLists.
- #reasoning ⇒ Object
-
#to_h ⇒ Object
rubocop:enable Metrics/ParameterLists.
Constructor Details
#initialize(input: nil, output: nil, cached: nil, cache_creation: nil, thinking: nil, reasoning: nil) ⇒ Tokens
rubocop:disable Metrics/ParameterLists
11 12 13 14 15 16 17 |
# File 'lib/legion/extensions/llm/tokens.rb', line 11 def initialize(input: nil, output: nil, cached: nil, cache_creation: nil, thinking: nil, reasoning: nil) @input = input @output = output @cached = cached @cache_creation = cache_creation @thinking = thinking || reasoning end |
Instance Attribute Details
#cache_creation ⇒ Object (readonly)
Returns the value of attribute cache_creation.
8 9 10 |
# File 'lib/legion/extensions/llm/tokens.rb', line 8 def cache_creation @cache_creation end |
#cached ⇒ Object (readonly)
Returns the value of attribute cached.
8 9 10 |
# File 'lib/legion/extensions/llm/tokens.rb', line 8 def cached @cached end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
8 9 10 |
# File 'lib/legion/extensions/llm/tokens.rb', line 8 def input @input end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
8 9 10 |
# File 'lib/legion/extensions/llm/tokens.rb', line 8 def output @output end |
#thinking ⇒ Object (readonly)
Returns the value of attribute thinking.
8 9 10 |
# File 'lib/legion/extensions/llm/tokens.rb', line 8 def thinking @thinking end |
Class Method Details
.build(input: nil, output: nil, cached: nil, cache_creation: nil, thinking: nil, reasoning: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/legion/extensions/llm/tokens.rb', line 21 def self.build(input: nil, output: nil, cached: nil, cache_creation: nil, thinking: nil, reasoning: nil) return nil if [input, output, cached, cache_creation, thinking, reasoning].all?(&:nil?) new( input: input, output: output, cached: cached, cache_creation: cache_creation, thinking: thinking, reasoning: reasoning ) end |
Instance Method Details
#reasoning ⇒ Object
45 46 47 |
# File 'lib/legion/extensions/llm/tokens.rb', line 45 def reasoning thinking end |
#to_h ⇒ Object
rubocop:enable Metrics/ParameterLists
35 36 37 38 39 40 41 42 43 |
# File 'lib/legion/extensions/llm/tokens.rb', line 35 def to_h { input_tokens: input, output_tokens: output, cached_tokens: cached, cache_creation_tokens: cache_creation, thinking_tokens: thinking }.compact end |