Class: Raif::ModelCompletionBatches::XAi

Inherits:
Raif::ModelCompletionBatch show all
Defined in:
app/models/raif/model_completion_batches/x_ai.rb

Overview

xAI batch persistence. xAI's Batch API does not expose a batch-level state enum -- progress is tracked through counts (num_pending, num_success, num_error, num_cancelled). The most relevant xAI-side metadata is mirrored into provider_response by Raif::Llms::XAi#fetch_batch_status!:

{ "expires_at" => "...", "cost_breakdown" => { ... } }

Constant Summary

Constants inherited from Raif::ModelCompletionBatch

Raif::ModelCompletionBatch::STATUSES, Raif::ModelCompletionBatch::TERMINAL_STATUSES

Instance Method Summary collapse

Methods inherited from Raif::ModelCompletionBatch

#add_task, #assert_submittable!, #cancel!, #dispatch_completion_handler!, #enqueue_first_poll!, #expire!, #fetch_results!, #fetch_status!, #finalize!, #force_fail!, #llm, #max_age_exceeded?, #recalculate_costs!, #submit!, #successful?, #tasks, #terminal?

Instance Method Details

#cost_breakdownObject



60
61
62
# File 'app/models/raif/model_completion_batches/x_ai.rb', line 60

def cost_breakdown
  provider_response&.dig("cost_breakdown")
end

#expires_atObject



51
52
53
54
55
56
57
58
# File 'app/models/raif/model_completion_batches/x_ai.rb', line 51

def expires_at
  ts = provider_response&.dig("expires_at")
  return if ts.blank?

  Time.zone.parse(ts.to_s)
rescue ArgumentError
  nil
end