Class: LlmCostTracker::Event

Inherits:
Data
  • Object
show all
Defined in:
lib/llm_cost_tracker/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cache_read_input_tokensObject (readonly)

Returns the value of attribute cache_read_input_tokens

Returns:

  • (Object)

    the current value of cache_read_input_tokens



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def cache_read_input_tokens
  @cache_read_input_tokens
end

#cache_write_input_tokensObject (readonly)

Returns the value of attribute cache_write_input_tokens

Returns:

  • (Object)

    the current value of cache_write_input_tokens



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def cache_write_input_tokens
  @cache_write_input_tokens
end

#costObject (readonly)

Returns the value of attribute cost

Returns:

  • (Object)

    the current value of cost



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def cost
  @cost
end

#hidden_output_tokensObject (readonly)

Returns the value of attribute hidden_output_tokens

Returns:

  • (Object)

    the current value of hidden_output_tokens



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def hidden_output_tokens
  @hidden_output_tokens
end

#input_tokensObject (readonly)

Returns the value of attribute input_tokens

Returns:

  • (Object)

    the current value of input_tokens



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def input_tokens
  @input_tokens
end

#latency_msObject (readonly)

Returns the value of attribute latency_ms

Returns:

  • (Object)

    the current value of latency_ms



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def latency_ms
  @latency_ms
end

#modelObject (readonly)

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def model
  @model
end

#output_tokensObject (readonly)

Returns the value of attribute output_tokens

Returns:

  • (Object)

    the current value of output_tokens



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def output_tokens
  @output_tokens
end

#pricing_modeObject (readonly)

Returns the value of attribute pricing_mode

Returns:

  • (Object)

    the current value of pricing_mode



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def pricing_mode
  @pricing_mode
end

#providerObject (readonly)

Returns the value of attribute provider

Returns:

  • (Object)

    the current value of provider



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def provider
  @provider
end

#provider_response_idObject (readonly)

Returns the value of attribute provider_response_id

Returns:

  • (Object)

    the current value of provider_response_id



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def provider_response_id
  @provider_response_id
end

#streamObject (readonly)

Returns the value of attribute stream

Returns:

  • (Object)

    the current value of stream



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def stream
  @stream
end

#tagsObject (readonly)

Returns the value of attribute tags

Returns:

  • (Object)

    the current value of tags



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def tags
  @tags
end

#total_tokensObject (readonly)

Returns the value of attribute total_tokens

Returns:

  • (Object)

    the current value of total_tokens



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def total_tokens
  @total_tokens
end

#tracked_atObject (readonly)

Returns the value of attribute tracked_at

Returns:

  • (Object)

    the current value of tracked_at



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def tracked_at
  @tracked_at
end

#usage_sourceObject (readonly)

Returns the value of attribute usage_source

Returns:

  • (Object)

    the current value of usage_source



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def usage_source
  @usage_source
end

Instance Method Details

#to_hObject



22
23
24
25
26
27
# File 'lib/llm_cost_tracker/event.rb', line 22

def to_h
  super.merge(
    cost: cost&.to_h,
    tags: tags ? tags.to_h : {}
  )
end