Sha256: dfb48f806c8c665edabe6d77302e55dae9fd6fadbc48c49dc4ee78093a3cf6c0

Contents?: true

Size: 721 Bytes

Versions: 21

Compression:

Stored size: 721 Bytes

Contents

module OpenAI
  class Images
    def initialize(client: nil)
      @client = client
    end

    def generate(parameters: {})
      @client.json_post(path: "/images/generations", parameters: parameters)
    end

    def edit(parameters: {})
      @client.multipart_post(path: "/images/edits", parameters: open_files(parameters))
    end

    def variations(parameters: {})
      @client.multipart_post(path: "/images/variations", parameters: open_files(parameters))
    end

    private

    def open_files(parameters)
      parameters = parameters.merge(image: File.open(parameters[:image]))
      parameters = parameters.merge(mask: File.open(parameters[:mask])) if parameters[:mask]
      parameters
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
ruby-openai-7.3.1 lib/openai/images.rb
ruby-openai-7.3.0 lib/openai/images.rb
ruby-openai-7.2.0 lib/openai/images.rb
ruby-openai-7.1.0 lib/openai/images.rb
ruby-openai-7.0.1 lib/openai/images.rb
ruby-openai-7.0.0 lib/openai/images.rb
ruby-openai-transitory-v2-6.5.3 lib/openai/images.rb
ruby-openai-transitory-v2-6.5.2 lib/openai/images.rb
ruby-openai-transitory-v2-6.5.1 lib/openai/images.rb
ruby-openai-transitory-v2-6.5.0 lib/openai/images.rb
ruby-openai-6.5.0 lib/openai/images.rb
ruby-openai-6.4.0 lib/openai/images.rb
ruby-openai-6.3.1 lib/openai/images.rb
ruby-openai-6.3.0 lib/openai/images.rb
ruby-openai-6.2.0 lib/openai/images.rb
ruby-openai-6.1.0 lib/openai/images.rb
ruby-openai-6.0.1 lib/openai/images.rb
ruby-openai-6.0.0 lib/openai/images.rb
ruby-openai-5.2.0 lib/openai/images.rb
ruby-openai-5.1.0 lib/openai/images.rb