Sha256: 6a99b75455577f4cbef4af8dd1f6d1a10b799fefbfb88e94f0b2c33f91454596

Contents?: true

Size: 622 Bytes

Versions: 5

Compression:

Stored size: 622 Bytes

Contents

# frozen_string_literal: true

module GenAI
  class Chat
    extend Forwardable

    def_delegators :@chat, :start, :message

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

    private

    def build_chat(provider, token, options)
      klass = GenAI::Chat.constants.find do |const|
        const.to_s.downcase == provider.to_s.downcase.gsub('_', '')
      end

      raise UnsupportedProvider, "Unsupported Chat provider '#{provider}'" unless klass

      @chat = GenAI::Chat.const_get(klass).new(provider: provider, token: token, options: options)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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