Class: LlmCostTracker::Pricing::Explanation

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#effective_pricesObject (readonly)

Returns the value of attribute effective_prices

Returns:

  • (Object)

    the current value of effective_prices



7
8
9
# File 'lib/llm_cost_tracker/pricing/explainer.rb', line 7

def effective_prices
  @effective_prices
end

#matched_byObject (readonly)

Returns the value of attribute matched_by

Returns:

  • (Object)

    the current value of matched_by



7
8
9
# File 'lib/llm_cost_tracker/pricing/explainer.rb', line 7

def matched_by
  @matched_by
end

#matched_keyObject (readonly)

Returns the value of attribute matched_key

Returns:

  • (Object)

    the current value of matched_key



7
8
9
# File 'lib/llm_cost_tracker/pricing/explainer.rb', line 7

def matched_key
  @matched_key
end

#missing_price_keysObject (readonly)

Returns the value of attribute missing_price_keys

Returns:

  • (Object)

    the current value of missing_price_keys



7
8
9
# File 'lib/llm_cost_tracker/pricing/explainer.rb', line 7

def missing_price_keys
  @missing_price_keys
end

#modelObject (readonly)

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



7
8
9
# File 'lib/llm_cost_tracker/pricing/explainer.rb', line 7

def model
  @model
end

#pricesObject (readonly)

Returns the value of attribute prices

Returns:

  • (Object)

    the current value of prices



7
8
9
# File 'lib/llm_cost_tracker/pricing/explainer.rb', line 7

def prices
  @prices
end

#pricing_modeObject (readonly)

Returns the value of attribute pricing_mode

Returns:

  • (Object)

    the current value of pricing_mode



7
8
9
# File 'lib/llm_cost_tracker/pricing/explainer.rb', line 7

def pricing_mode
  @pricing_mode
end

#providerObject (readonly)

Returns the value of attribute provider

Returns:

  • (Object)

    the current value of provider



7
8
9
# File 'lib/llm_cost_tracker/pricing/explainer.rb', line 7

def provider
  @provider
end

#sourceObject (readonly)

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



7
8
9
# File 'lib/llm_cost_tracker/pricing/explainer.rb', line 7

def source
  @source
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


20
# File 'lib/llm_cost_tracker/pricing/explainer.rb', line 20

def complete? = matched? && missing_price_keys.empty?

#matched?Boolean

Returns:

  • (Boolean)


18
# File 'lib/llm_cost_tracker/pricing/explainer.rb', line 18

def matched? = !prices.nil?

#messageObject



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

def message
  return "No price entry matched #{provider}/#{model}" unless matched?
  return "Matched #{matched_key} from #{source} via #{matched_by}" if complete?

  "Matched #{matched_key} from #{source} via #{matched_by}, but missing #{missing_price_keys.join(', ')}"
end