Class: LlmLogs::Batch::Reconciler

Inherits:
Object
  • Object
show all
Defined in:
app/models/llm_logs/batch/reconciler.rb

Overview

Resumes a submitted batch by id, and once terminal, records a trace per request, routes each result to its registered handler, and updates statuses. Idempotent at the request level (succeeded/failed/fell_back requests are skipped on re-run).

Instance Method Summary collapse

Constructor Details

#initialize(batch) ⇒ Reconciler

Returns a new instance of Reconciler.



7
8
9
# File 'app/models/llm_logs/batch/reconciler.rb', line 7

def initialize(batch)
  @batch = batch
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/llm_logs/batch/reconciler.rb', line 11

def call
  adapter = LlmLogs::Batch.adapter_for(@batch.provider)
  status = adapter.terminal_status(@batch)
  case status
  when "completed"
    reconcile_completed(adapter)
  when "failed", "expired", "cancelled"
    fail_all(status)
  end
  @batch
end