Class: LlmLogs::Batch
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- LlmLogs::Batch
- Defined in:
- app/models/llm_logs/batch.rb,
app/jobs/llm_logs/batch/poll_job.rb,
app/jobs/llm_logs/batch/flush_job.rb,
app/models/llm_logs/batch/submitter.rb,
app/models/llm_logs/batch/reconciler.rb,
app/models/llm_logs/batch/schema_format.rb,
app/models/llm_logs/batch/trace_recorder.rb,
app/models/llm_logs/batch/handler_registry.rb
Defined Under Namespace
Modules: HandlerRegistry, SchemaFormat, TraceRecorder Classes: FlushJob, PollJob, Reconciler, Submitter
Class Method Summary collapse
- .batchable?(model) ⇒ Boolean
- .enqueue(purpose:, model:, input:, instructions:, schema:, routing:, temperature: nil) ⇒ Object
- .submit_pending(purpose:, model:, metadata: {}) ⇒ Object
Instance Method Summary collapse
Class Method Details
.batchable?(model) ⇒ Boolean
45 46 47 48 49 |
# File 'app/models/llm_logs/batch.rb', line 45 def self.batchable?(model) return false unless LlmLogs.batch_enabled? !defined?(RubyLLM::Providers::OpenAIResponses).nil? end |
.enqueue(purpose:, model:, input:, instructions:, schema:, routing:, temperature: nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/llm_logs/batch.rb', line 21 def self.enqueue(purpose:, model:, input:, instructions:, schema:, routing:, temperature: nil) BatchRequest.create!( purpose: purpose, model: model, status: :pending, custom_id: "req_#{SecureRandom.hex(8)}", routing: routing, payload: { "input" => input, "instructions" => instructions, "schema" => schema, "temperature" => temperature }.compact ) end |
Instance Method Details
#reconcile! ⇒ Object
41 42 43 |
# File 'app/models/llm_logs/batch.rb', line 41 def reconcile! Reconciler.new(self).call end |