Class: Raif::ModelCompletionBatches::XAi
- Inherits:
-
Raif::ModelCompletionBatch
- Object
- ApplicationRecord
- Raif::ModelCompletionBatch
- Raif::ModelCompletionBatches::XAi
- 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!:
{ "expire_time" => "...", "cancel_by_xai_message" => "...",
"cost_breakdown" => { ... } }
Constant Summary
Constants inherited from Raif::ModelCompletionBatch
Raif::ModelCompletionBatch::STATUSES, Raif::ModelCompletionBatch::TERMINAL_STATUSES
Instance Method Summary collapse
- #cost_breakdown ⇒ Object
-
#expires_at ⇒ Object
xAI's field is
expire_time(and it carries a date, not a timestamp). -
#rejection_message ⇒ Object
xAI's stated reason for killing the batch server-side, when it gave one.
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_breakdown ⇒ Object
68 69 70 |
# File 'app/models/raif/model_completion_batches/x_ai.rb', line 68 def cost_breakdown provider_response&.dig("cost_breakdown") end |
#expires_at ⇒ Object
xAI's field is expire_time (and it carries a date, not a timestamp).
54 55 56 57 58 59 60 61 |
# File 'app/models/raif/model_completion_batches/x_ai.rb', line 54 def expires_at ts = provider_response&.dig("expire_time") return if ts.blank? Time.zone.parse(ts.to_s) rescue ArgumentError nil end |
#rejection_message ⇒ Object
xAI's stated reason for killing the batch server-side, when it gave one.
64 65 66 |
# File 'app/models/raif/model_completion_batches/x_ai.rb', line 64 def provider_response&.dig("cancel_by_xai_message") end |