Sha256: b1270411ecd30a63a398dd90fa586202cfeb1850e2adafbe6de85aef57f29aa5

Contents?: true

Size: 637 Bytes

Versions: 7

Compression:

Stored size: 637 Bytes

Contents

# frozen_string_literal: true

module GenAI
  class Image
    extend Forwardable

    def_delegators :@client, :generate, :variations, :edit, :upscale

    def initialize(provider, token, options: {})
      build_client(provider, token, options)
    end

    private

    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

7 entries across 7 versions & 1 rubygems

Version Path
gen-ai-0.4.3 lib/gen_ai/image.rb
gen-ai-0.4.2 lib/gen_ai/image.rb
gen-ai-0.4.1 lib/gen_ai/image.rb
gen-ai-0.4.0 lib/gen_ai/image.rb
gen-ai-0.4.0.alpha.3 lib/gen_ai/image.rb
gen-ai-0.4.0.alpha.2 lib/gen_ai/image.rb
gen-ai-0.4.0.alpha.1 lib/gen_ai/image.rb