class RubyLLM::ActiveRecord::Batch
A provider-side batch of persisted chats, in RubyLLM’s ruby_llm_batches table. RubyLLM.batch writes a row when it submits persisted chats of one class, and RubyLLM::Batch.find reads it back in any process.
RubyLLM::ActiveRecord::Batch.where(completed: false).pluck(:provider_batch_id)
Its columns:
provider_batch_id-
The provider’s id for the batch.
provider-
The provider’s slug.
status-
"pending","succeeded","failed", or"cancelled". raw_status-
The status as the provider last reported it.
completed-
Whether the provider has finished the batch.
request_counts-
The provider’s request counts, as a Hash.
reported_cost-
The cost the provider reported, as a Hash.
chat_type,chat_ids-
The class and ids of the submitted chats.
RubyLLM writes these rows. Read and query them, and add scopes and columns of your own, but do not create or update them. Use RubyLLM::Batch to refresh a batch and deliver its results.
Public Instance Methods
Source
# File lib/ruby_llm/active_record/batch.rb, line 83 def chats klass = chat_type.constantize by_id = klass.where(klass.primary_key => Array(chat_ids)) .index_by { |chat| chat.public_send(klass.primary_key) } Array(chat_ids).map { |id| by_id[id] } end
Returns the submitted chat records in submission order, with nil for a chat that no longer exists.