Class: Raif::ModelCompletionBatches::Google

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

Overview

Google Gemini batch persistence. The Gemini Batch API is a long-running operation: create returns a resource named "batches/id" whose state lives at metadata.state (see Raif::Concerns::Llms::Google::BatchInference for the response-shape parsing). The provider_response jsonb caches the most recent operation envelope so we can pull inline results on the success poll without another round-trip:

{
"operation_name" => "batches/123456",
"state" => "JOB_STATE_RUNNING",
"done" => false,
"response" => { ... last-seen response sub-tree, only populated on success ... }
}

provider_batch_id stores just the trailing id (not the full "batches/" path).

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

#latest_response_payloadObject



64
65
66
# File 'app/models/raif/model_completion_batches/google.rb', line 64

def latest_response_payload
  provider_response&.dig("response")
end

#operation_nameObject



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

def operation_name
  provider_response&.dig("operation_name").presence || (provider_batch_id.present? ? "batches/#{provider_batch_id}" : nil)
end