Class: Langfuse::Models::Usage

Inherits:
Object
  • Object
show all
Defined in:
lib/langfuse/models/usage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Usage



8
9
10
11
12
# File 'lib/langfuse/models/usage.rb', line 8

def initialize(attributes = {})
  attributes.each do |key, value|
    send("#{key}=", value) if respond_to?("#{key}=")
  end
end

Instance Attribute Details

#completion_tokensObject

Returns the value of attribute completion_tokens.



4
5
6
# File 'lib/langfuse/models/usage.rb', line 4

def completion_tokens
  @completion_tokens
end

#inputObject

Returns the value of attribute input.



4
5
6
# File 'lib/langfuse/models/usage.rb', line 4

def input
  @input
end

#input_costObject

Returns the value of attribute input_cost.



4
5
6
# File 'lib/langfuse/models/usage.rb', line 4

def input_cost
  @input_cost
end

#outputObject

Returns the value of attribute output.



4
5
6
# File 'lib/langfuse/models/usage.rb', line 4

def output
  @output
end

#output_costObject

Returns the value of attribute output_cost.



4
5
6
# File 'lib/langfuse/models/usage.rb', line 4

def output_cost
  @output_cost
end

#prompt_tokensObject

Returns the value of attribute prompt_tokens.



4
5
6
# File 'lib/langfuse/models/usage.rb', line 4

def prompt_tokens
  @prompt_tokens
end

#totalObject

Returns the value of attribute total.



4
5
6
# File 'lib/langfuse/models/usage.rb', line 4

def total
  @total
end

#total_costObject

Returns the value of attribute total_cost.



4
5
6
# File 'lib/langfuse/models/usage.rb', line 4

def total_cost
  @total_cost
end

#total_tokensObject

Returns the value of attribute total_tokens.



4
5
6
# File 'lib/langfuse/models/usage.rb', line 4

def total_tokens
  @total_tokens
end

#unitObject

Returns the value of attribute unit.



4
5
6
# File 'lib/langfuse/models/usage.rb', line 4

def unit
  @unit
end

Instance Method Details

#to_hObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/langfuse/models/usage.rb', line 14

def to_h
  {
    input: @input,
    output: @output,
    total: @total,
    unit: @unit,
    inputCost: @input_cost,
    outputCost: @output_cost,
    totalCost: @total_cost,
    promptTokens: @prompt_tokens,
    completionTokens: @completion_tokens,
    totalTokens: @total_tokens
  }.compact
end