Sha256: e6bf1230b51865a543986aa579ebc3a14b6de0927cb0e223965b04d265647a11
Contents?: true
Size: 920 Bytes
Versions: 6
Compression:
Stored size: 920 Bytes
Contents
# frozen_string_literal: true module GenAI class Image def initialize(provider, token, options: {}) build_client(provider, token, options) end def generate(prompt, options = {}) client.generate(prompt, options) end def variations(image, options = {}) client.variations(image, options) end def edit(image, prompt, options = {}) client.edit(image, prompt, options) end def upscale(image, options = {}) client.upscale(image, options) end private attr_reader :client def build_client(provider, token, options) klass = GenAI::Image.constants.find do |const| const.to_s.downcase == provider.to_s.downcase.gsub('_', '') end raise UnsupportedProvider, "Unsupported Image provider '#{provider}'" unless klass @client = GenAI::Image.const_get(klass).new(token: token, options: options) end end end
Version data entries
6 entries across 6 versions & 1 rubygems