Class: ActiveHarness::Costs::ModelCost

Inherits:
Struct
  • Object
show all
Defined in:
lib/active_harness/costs.rb

Overview

Value object representing the pricing for a single model.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cache_read_input_per_millionObject

Returns the value of attribute cache_read_input_per_million

Returns:

  • (Object)

    the current value of cache_read_input_per_million



57
58
59
# File 'lib/active_harness/costs.rb', line 57

def cache_read_input_per_million
  @cache_read_input_per_million
end

#cache_write_input_per_millionObject

Returns the value of attribute cache_write_input_per_million

Returns:

  • (Object)

    the current value of cache_write_input_per_million



57
58
59
# File 'lib/active_harness/costs.rb', line 57

def cache_write_input_per_million
  @cache_write_input_per_million
end

#context_windowObject

Returns the value of attribute context_window

Returns:

  • (Object)

    the current value of context_window



57
58
59
# File 'lib/active_harness/costs.rb', line 57

def context_window
  @context_window
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



57
58
59
# File 'lib/active_harness/costs.rb', line 57

def id
  @id
end

#input_modalitiesObject

Returns the value of attribute input_modalities

Returns:

  • (Object)

    the current value of input_modalities



57
58
59
# File 'lib/active_harness/costs.rb', line 57

def input_modalities
  @input_modalities
end

#input_per_millionObject

Returns the value of attribute input_per_million

Returns:

  • (Object)

    the current value of input_per_million



57
58
59
# File 'lib/active_harness/costs.rb', line 57

def input_per_million
  @input_per_million
end

#max_output_tokensObject

Returns the value of attribute max_output_tokens

Returns:

  • (Object)

    the current value of max_output_tokens



57
58
59
# File 'lib/active_harness/costs.rb', line 57

def max_output_tokens
  @max_output_tokens
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



57
58
59
# File 'lib/active_harness/costs.rb', line 57

def name
  @name
end

#output_modalitiesObject

Returns the value of attribute output_modalities

Returns:

  • (Object)

    the current value of output_modalities



57
58
59
# File 'lib/active_harness/costs.rb', line 57

def output_modalities
  @output_modalities
end

#output_per_millionObject

Returns the value of attribute output_per_million

Returns:

  • (Object)

    the current value of output_per_million



57
58
59
# File 'lib/active_harness/costs.rb', line 57

def output_per_million
  @output_per_million
end

#providerObject

Returns the value of attribute provider

Returns:

  • (Object)

    the current value of provider



57
58
59
# File 'lib/active_harness/costs.rb', line 57

def provider
  @provider
end

Instance Method Details

#categoriesObject

Returns capability tags derived from modality data and model id/name. Possible values: “vision”, “pdf”, “audio”, “video”, “imggen”, “embed”



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/active_harness/costs.rb', line 73

def categories
  inp = input_modalities  || []
  out = output_modalities || []
  cats = []
  cats << "vision" if inp.include?("image")
  cats << "pdf"    if inp.include?("pdf")
  cats << "audio"  if inp.include?("audio") || out.include?("audio")
  cats << "video"  if inp.include?("video")  || out.include?("video")
  cats << "imggen" if out.include?("image")
  cats << "embed"  if id.to_s.match?(/embed/i) || name.to_s.match?(/embed/i)
  cats
end

#inspectObject



86
87
88
89
90
91
92
93
# File 'lib/active_harness/costs.rb', line 86

def inspect
  parts = ["id=#{id.inspect}", "provider=#{provider.inspect}"]
  parts << "input=$#{input_per_million}/M"  if input_per_million
  parts << "output=$#{output_per_million}/M" if output_per_million
  parts << "ctx=#{context_window}"           if context_window
  parts << "cats=#{categories.join(',')}"    if categories.any?
  "#<ModelCost #{parts.join(' ')}>"
end