Exception: LlmCostTracker::BudgetExceededError

Inherits:
Error
  • Object
show all
Defined in:
lib/llm_cost_tracker/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(budget:, budget_type:, total:, last_event: nil) ⇒ BudgetExceededError

Returns a new instance of BudgetExceededError.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/llm_cost_tracker/errors.rb', line 11

def initialize(budget:, budget_type:, total:, last_event: nil)
  @total = total
  @budget = budget
  @budget_type = budget_type
  @last_event = last_event

  super(
    "LLM #{@budget_type.to_s.tr('_', '-')} budget exceeded: " \
    "$#{format('%.6f', @total)} / $#{format('%.6f', budget)}"
  )
end

Instance Attribute Details

#budgetObject (readonly)

Returns the value of attribute budget.



9
10
11
# File 'lib/llm_cost_tracker/errors.rb', line 9

def budget
  @budget
end

#budget_typeObject (readonly)

Returns the value of attribute budget_type.



9
10
11
# File 'lib/llm_cost_tracker/errors.rb', line 9

def budget_type
  @budget_type
end

#last_eventObject (readonly)

Returns the value of attribute last_event.



9
10
11
# File 'lib/llm_cost_tracker/errors.rb', line 9

def last_event
  @last_event
end

#totalObject (readonly)

Returns the value of attribute total.



9
10
11
# File 'lib/llm_cost_tracker/errors.rb', line 9

def total
  @total
end