Class: GroqRuby::Resources::Batches

Inherits:
Base
  • Object
show all
Defined in:
lib/groq_ruby/resources/batches.rb

Overview

‘client.batches.*` — async batch processing of chat completions or embeddings against an uploaded JSONL file.

Constant Summary collapse

BASE_PATH =
"/openai/v1/batches".freeze
CREATE_SCHEMA =
Dry::Schema.define do
  required(:input_file_id).filled(:string)
  required(:endpoint).filled(:string)
  required(:completion_window).filled(:string)
  optional(:metadata).value(:hash)
end

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from GroqRuby::Resources::Base

Instance Method Details

#cancel(batch_id) ⇒ GroqRuby::Models::Batch

Returns with ‘status` advanced toward `cancelled`.

Parameters:

  • batch_id (String)

Returns:



39
40
41
# File 'lib/groq_ruby/resources/batches.rb', line 39

def cancel(batch_id)
  GroqRuby::Models::Batch.from_hash(perform(Request.new(method: :post, path: "#{BASE_PATH}/#{batch_id}/cancel")))
end

#create(**params) ⇒ GroqRuby::Models::Batch

Parameters:

  • params (Hash)

    required: ‘:input_file_id`, `:endpoint`, `:completion_window` (e.g. `“24h”`). Optional: `:metadata`.

Returns:

Raises:



21
22
23
24
# File 'lib/groq_ruby/resources/batches.rb', line 21

def create(**params)
  body = validate!(CREATE_SCHEMA, params)
  GroqRuby::Models::Batch.from_hash(perform(Request.new(method: :post, path: BASE_PATH, body: body)))
end

#listGroqRuby::Models::BatchList



33
34
35
# File 'lib/groq_ruby/resources/batches.rb', line 33

def list
  GroqRuby::Models::BatchList.from_hash(perform(Request.new(method: :get, path: BASE_PATH)))
end

#retrieve(batch_id) ⇒ GroqRuby::Models::Batch

Parameters:

  • batch_id (String)

Returns:



28
29
30
# File 'lib/groq_ruby/resources/batches.rb', line 28

def retrieve(batch_id)
  GroqRuby::Models::Batch.from_hash(perform(Request.new(method: :get, path: "#{BASE_PATH}/#{batch_id}")))
end