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:, last_event: nil, budget_type: nil, total: nil, monthly_total: nil, daily_total: nil, call_cost: nil) ⇒ BudgetExceededError

Returns a new instance of BudgetExceededError.



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

def initialize(budget:, last_event: nil, budget_type: nil, total: nil, monthly_total: nil, daily_total: nil,
               call_cost: nil)
  @monthly_total = monthly_total
  @daily_total = daily_total
  @call_cost = call_cost
  @total = total || monthly_total || daily_total || call_cost
  @budget = budget
  @budget_type = budget_type || inferred_budget_type
  @last_event = last_event

  super("LLM #{budget_label} 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

#call_costObject (readonly)

Returns the value of attribute call_cost.



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

def call_cost
  @call_cost
end

#daily_totalObject (readonly)

Returns the value of attribute daily_total.



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

def daily_total
  @daily_total
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

#monthly_totalObject (readonly)

Returns the value of attribute monthly_total.



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

def monthly_total
  @monthly_total
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