Sha256: f73d54472998ee31f9f5ecb388da3b70a706694ed2c8de8e98cdba056f927a2e

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

# frozen_string_literal: true

require 'faraday'
require 'pry'
module GenAI
  class Language
    class Gemini < Base
      include GenAI::Api::Format::Gemini

      BASE_API_URL = 'https://generativelanguage.googleapis.com'

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

      def complete(prompt, options = {}); end

      def chat(messages, options = {})
        response = client.post "/v1beta/models/gemini-pro:generateContent?key=#{@token}", {
          contents: messages.map(&:deep_symbolize_keys!),
          generationConfig: options
        }

        build_result(model: 'gemini-pro', raw: response, parsed: extract_completions(response))
      end

      private

      def build_client(token)
        @client = GenAI::Api::Client.new(url: BASE_API_URL, token: nil)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gen-ai-0.4.0.alpha.1 lib/gen_ai/language/gemini.rb