Module: Openai::Client::Utils

Defined in:
lib/openai/client/utils.rb

Class Method Summary collapse

Class Method Details

.upload_io(data, param_names, content_type) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Internal: Creates the open IO object for the uploaded file.

Parameters:

  • data (Hash)

    request body

  • param_names (Array)

    parameter names

  • content_type (String)

    content type of the file data

Returns:

  • (Hash)

    request body



15
16
17
18
19
20
# File 'lib/openai/client/utils.rb', line 15

def upload_io(data, param_names, content_type)
  param_names.each do |param|
    data[param] = Faraday::FilePart.new(data[param], content_type) if data[param]
  end
  data
end