Class: LlmCostTracker::Configuration::Budgets

Inherits:
Section
  • Object
show all
Defined in:
lib/llm_cost_tracker/configuration/budgets.rb

Constant Summary collapse

EXCEEDED_BEHAVIORS =
%i[notify raise block_requests].freeze
TOTALS_SOURCES =
%i[ledger cache].freeze
PER_TAG_WINDOWS =
%i[daily weekly monthly].freeze
PER_TAG_OPTIONS =
%i[behavior on_exceeded].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Section

attributes, enum_attribute

Constructor Details

#initialize(owner) ⇒ Budgets

Returns a new instance of Budgets.



21
22
23
24
25
26
27
28
29
30
# File 'lib/llm_cost_tracker/configuration/budgets.rb', line 21

def initialize(owner)
  super
  @monthly = nil
  @daily = nil
  @per_call = nil
  @on_exceeded = nil
  @per_tag = {}
  self.exceeded_behavior = :notify
  self.totals_source = :ledger
end

Instance Attribute Details

#per_tagObject

Returns the value of attribute per_tag.



19
20
21
# File 'lib/llm_cost_tracker/configuration/budgets.rb', line 19

def per_tag
  @per_tag
end

Instance Method Details

#finalize!Object



37
38
39
# File 'lib/llm_cost_tracker/configuration/budgets.rb', line 37

def finalize!
  @per_tag = deep_freeze(@per_tag || {})
end