Class: LlmLogs::Batch::Adapters::OpenaiResponses
- Inherits:
-
Object
- Object
- LlmLogs::Batch::Adapters::OpenaiResponses
- Defined in:
- app/models/llm_logs/batch/adapters/openai_responses.rb
Overview
Wraps ruby_llm-responses_api's OpenAI Batch API. Contains the remote-API logic previously inline in Submitter/Reconciler; the DB/claim lifecycle stays in those.
Constant Summary collapse
- PROVIDER =
:openai_responses
Instance Method Summary collapse
- #error_ids(batch) ⇒ Object
- #results(batch) ⇒ Object
- #submit(_batch, requests) ⇒ Object
- #terminal_status(batch) ⇒ Object
Instance Method Details
#error_ids(batch) ⇒ Object
33 34 35 |
# File 'app/models/llm_logs/batch/adapters/openai_responses.rb', line 33 def error_ids(batch) resume(batch).errors.filter_map { |e| e["custom_id"] } end |
#results(batch) ⇒ Object
29 30 31 |
# File 'app/models/llm_logs/batch/adapters/openai_responses.rb', line 29 def results(batch) resume(batch).results end |
#submit(_batch, requests) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/llm_logs/batch/adapters/openai_responses.rb', line 9 def submit(_batch, requests) rubyllm_batch = RubyLLM.batch(model: requests.first.model, provider: PROVIDER) requests.each do |request| payload = request.payload rubyllm_batch.add( payload["input"], id: request.custom_id, instructions: payload["instructions"], temperature: payload["temperature"], **schema_extra(payload["schema"]) ) end rubyllm_batch.create! {provider_batch_id: rubyllm_batch.id, openai_batch_id: rubyllm_batch.id, provider_metadata: {}} end |
#terminal_status(batch) ⇒ Object
25 26 27 |
# File 'app/models/llm_logs/batch/adapters/openai_responses.rb', line 25 def terminal_status(batch) resume(batch).status end |