Class: Coolhand::OpenAi::BatchResultProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/coolhand/open_ai/batch_result_processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_data:) ⇒ BatchResultProcessor

Returns a new instance of BatchResultProcessor.



8
9
10
# File 'lib/coolhand/open_ai/batch_result_processor.rb', line 8

def initialize(event_data:)
  @event_data = event_data
end

Instance Attribute Details

#event_dataObject (readonly)

Returns the value of attribute event_data.



6
7
8
# File 'lib/coolhand/open_ai/batch_result_processor.rb', line 6

def event_data
  @event_data
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/coolhand/open_ai/batch_result_processor.rb', line 12

def call
  Rails.logger.info("[Interceptor] BatchResultProcessor: #{event_data}")

  case batch_info["status"]
  when "completed"
    process_completed_batch
  when "failed", "expired", "cancelled"
    handle_failed_batch
  when "in_progress", "validating", "finalizing"
    Rails.logger.info("[Interceptor] OpenAI batch #{event_data} still processing")
  else
    Rails.logger.warn("[Interceptor] Unknown batch status: #{batch_info['status']} for batch #{event_data}")
  end
rescue StandardError => e
  Rails.logger.error("[Interceptor] Failed to process OpenAI batch results for #{event_data}: #{e.message}")
end