Module: LlmCostTracker::Ingestion
- Defined in:
- lib/llm_cost_tracker/ingestion.rb,
lib/llm_cost_tracker/ingestion/batch.rb,
lib/llm_cost_tracker/ingestion/inbox.rb,
lib/llm_cost_tracker/ingestion/worker.rb,
lib/llm_cost_tracker/ingestion/lease_claim.rb,
app/models/llm_cost_tracker/ingestion/event.rb,
app/models/llm_cost_tracker/ingestion/lease.rb
Defined Under Namespace
Classes: Batch, Event, Inbox, Lease, LeaseClaim, Worker
Constant Summary
collapse
- VERIFY_TAG =
"llm_cost_tracker_verify"
Class Method Summary
collapse
Class Method Details
.ensure_current_schema! ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/llm_cost_tracker/ingestion.rb', line 18
def ensure_current_schema!
unless Ledger::Call.table_exists?
raise Error, "llm_api_calls table is missing; run install generator and migrate"
end
schema_errors = Ledger::Schema::Calls.current_schema_errors
message = "llm_api_calls table is not on the current schema: #{schema_errors.join('; ')}"
raise Error, message if schema_errors.any?
period_total_errors = Ledger::Schema::PeriodTotals.current_schema_errors
return if period_total_errors.empty?
message = "llm_cost_tracker_period_totals table is not on the current schema: " \
"#{period_total_errors.join('; ')}; " \
"run bin/rails generate llm_cost_tracker:add_period_totals && bin/rails db:migrate"
raise Error, message
end
|
.verify ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/llm_cost_tracker/ingestion.rb', line 36
def verify
unless LlmCostTracker::Ledger::Call.table_exists?
return [
LlmCostTracker::Doctor::Check.new(
:error,
"active_record",
"llm_api_calls table is missing; run install generator and migrate"
)
]
end
[capture_check]
rescue StandardError => e
[LlmCostTracker::Doctor::Check.new(:error, "active_record", "#{e.class}: #{e.message}")]
end
|