Class: Intelligence::ChatMetrics
- Inherits:
-
Object
- Object
- Intelligence::ChatMetrics
- Defined in:
- lib/intelligence/chat_metrics.rb
Overview
class. ChatMetrics
The ChatMetrics class encapsulates metrics information. These metrics include the number of input tokens consumed, the number of output tokens generated, the total number of tokens, and the duration of the request in milliseconds.
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
—————.
-
#input_tokens ⇒ Object
readonly
Returns the value of attribute input_tokens.
-
#output_tokens ⇒ Object
readonly
Returns the value of attribute output_tokens.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ ChatMetrics
constructor
A new instance of ChatMetrics.
- #total_tokens ⇒ Object
Constructor Details
#initialize(attributes) ⇒ ChatMetrics
Returns a new instance of ChatMetrics.
18 19 20 21 22 |
# File 'lib/intelligence/chat_metrics.rb', line 18 def initialize( attributes ) attributes.each do | key, value | instance_variable_set( "@#{key}", value ) if self.respond_to?( "#{key}" ) end end |
Instance Attribute Details
#duration ⇒ Object (readonly)
13 14 15 |
# File 'lib/intelligence/chat_metrics.rb', line 13 def duration @duration end |
#input_tokens ⇒ Object (readonly)
Returns the value of attribute input_tokens.
15 16 17 |
# File 'lib/intelligence/chat_metrics.rb', line 15 def input_tokens @input_tokens end |
#output_tokens ⇒ Object (readonly)
Returns the value of attribute output_tokens.
16 17 18 |
# File 'lib/intelligence/chat_metrics.rb', line 16 def output_tokens @output_tokens end |
Instance Method Details
#total_tokens ⇒ Object
24 25 26 27 28 |
# File 'lib/intelligence/chat_metrics.rb', line 24 def total_tokens @total_tokens = @input_tokens + @output_tokens \ if @total_tokens.nil? && @input_tokens && @output_tokens @total_tokens end |