omniai-google 1.2.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/omniai/google/chat.rb +0 -14
- data/lib/omniai/google/client.rb +6 -8
- data/lib/omniai/google/config.rb +21 -8
- data/lib/omniai/google/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1dc0ec04a882a2e35a5d7ff7b613bde89641e57a67ed4a68cdb84ab72d04a982
         | 
| 4 | 
            +
              data.tar.gz: a72573e3a57e13b6bf56e33c4133ea4a9ae0c4c3d79688979a8f166345508a6f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 3cd82fccac3f31b37f9505569ff411d91c9c2a9429fde7308c7b5b34abe922bd4734613f355ed616ff27ff49502c17714d380d0676a2f6f63493fa4baf65c0bc
         | 
| 7 | 
            +
              data.tar.gz: c1ac419641eebf177c72a425ac695e5fad10d09cd943998c5952d29ace751234a135eeb009e3000db47869de07db675bbadcddec6cd225ce851641635ffc2550
         | 
    
        data/lib/omniai/google/chat.rb
    CHANGED
    
    | @@ -36,20 +36,6 @@ module OmniAI | |
| 36 36 | 
             
                      }.compact, json: payload)
         | 
| 37 37 | 
             
                  end
         | 
| 38 38 |  | 
| 39 | 
            -
                  # @param response [HTTP::Response]
         | 
| 40 | 
            -
                  # @return [OmniAI::Google::Chat::Stream]
         | 
| 41 | 
            -
                  def stream!(response:)
         | 
| 42 | 
            -
                    raise Error, "#{self.class.name}#stream! unstreamable" unless @stream
         | 
| 43 | 
            -
             | 
| 44 | 
            -
                    Stream.new(response:).stream! { |chunk| @stream.call(chunk) }
         | 
| 45 | 
            -
                  end
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                  # @param response [HTTP::Response]
         | 
| 48 | 
            -
                  # @param response [OmniAI::Google::Chat::Completion]
         | 
| 49 | 
            -
                  def complete!(response:)
         | 
| 50 | 
            -
                    Completion.new(data: response.parse)
         | 
| 51 | 
            -
                  end
         | 
| 52 | 
            -
             | 
| 53 39 | 
             
                  # @return [Hash]
         | 
| 54 40 | 
             
                  def payload
         | 
| 55 41 | 
             
                    OmniAI::Google.config.chat_options.merge({
         | 
    
        data/lib/omniai/google/client.rb
    CHANGED
    
    | @@ -20,31 +20,29 @@ module OmniAI | |
| 20 20 | 
             
                #
         | 
| 21 21 | 
             
                #   client = OmniAI::Google::Client.new
         | 
| 22 22 | 
             
                class Client < OmniAI::Client
         | 
| 23 | 
            +
                  # @!attribute [rw] version
         | 
| 24 | 
            +
                  #   @return [String, nil]
         | 
| 23 25 | 
             
                  attr_accessor :version
         | 
| 24 26 |  | 
| 25 27 | 
             
                  # @param api_key [String] optional - defaults to `OmniAI::Google.config.api_key`
         | 
| 26 28 | 
             
                  # @param host [String] optional - defaults to `OmniAI::Google.config.host`
         | 
| 27 29 | 
             
                  # @param version [String] optional - defaults to `OmniAI::Google.config.version`
         | 
| 28 30 | 
             
                  # @param logger [Logger] optional - defaults to `OmniAI::Google.config.logger`
         | 
| 31 | 
            +
                  # @param timeout [Integer] optional - defaults to `OmniAI::Google.config.timeout`
         | 
| 29 32 | 
             
                  def initialize(
         | 
| 30 33 | 
             
                    api_key: OmniAI::Google.config.api_key,
         | 
| 31 34 | 
             
                    logger: OmniAI::Google.config.logger,
         | 
| 32 35 | 
             
                    host: OmniAI::Google.config.host,
         | 
| 33 | 
            -
                    version: OmniAI::Google.config.version
         | 
| 36 | 
            +
                    version: OmniAI::Google.config.version,
         | 
| 37 | 
            +
                    timeout: OmniAI::Google.config.timeout
         | 
| 34 38 | 
             
                  )
         | 
| 35 39 | 
             
                    raise(ArgumentError, %(ENV['GOOGLE_API_KEY'] must be defined or `api_key` must be passed)) if api_key.nil?
         | 
| 36 40 |  | 
| 37 | 
            -
                    super(api_key:, logger:)
         | 
| 41 | 
            +
                    super(api_key:, host:, logger:, timeout:)
         | 
| 38 42 |  | 
| 39 | 
            -
                    @host = host
         | 
| 40 43 | 
             
                    @version = version
         | 
| 41 44 | 
             
                  end
         | 
| 42 45 |  | 
| 43 | 
            -
                  # @return [HTTP::Client]
         | 
| 44 | 
            -
                  def connection
         | 
| 45 | 
            -
                    HTTP.persistent(@host)
         | 
| 46 | 
            -
                  end
         | 
| 47 | 
            -
             | 
| 48 46 | 
             
                  # @raise [OmniAI::Error]
         | 
| 49 47 | 
             
                  #
         | 
| 50 48 | 
             
                  # @param messages [String, Array, Hash]
         | 
    
        data/lib/omniai/google/config.rb
    CHANGED
    
    | @@ -2,16 +2,29 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            module OmniAI
         | 
| 4 4 | 
             
              module Google
         | 
| 5 | 
            -
                #  | 
| 5 | 
            +
                # Configuration for Google.
         | 
| 6 6 | 
             
                class Config < OmniAI::Config
         | 
| 7 | 
            -
                   | 
| 7 | 
            +
                  DEFAULT_HOST = 'https://generativelanguage.googleapis.com'
         | 
| 8 | 
            +
                  DEFAULT_VERSION = 'v1'
         | 
| 8 9 |  | 
| 9 | 
            -
                   | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 10 | 
            +
                  # @!attribute [rw] version
         | 
| 11 | 
            +
                  #   @return [String, nil]
         | 
| 12 | 
            +
                  attr_accessor :version
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  # @param api_key [String, nil] optional - defaults to `ENV['GOOGLE_API_KEY']`
         | 
| 15 | 
            +
                  # @param host [String, nil] optional - defaults to `ENV['GOOGLE_HOST'] w/ fallback to `DEFAULT_HOST`
         | 
| 16 | 
            +
                  # @param version [String, nil] optional - defaults to `ENV['GOOGLE_VERSION'] w/ fallback to `DEFAULT_VERSION`
         | 
| 17 | 
            +
                  # @param logger [Logger, nil] optional - defaults to
         | 
| 18 | 
            +
                  # @param timeout [Integer, Hash, nil] optional
         | 
| 19 | 
            +
                  def initialize(
         | 
| 20 | 
            +
                    api_key: ENV.fetch('GOOGLE_API_KEY', nil),
         | 
| 21 | 
            +
                    host: ENV.fetch('GOOGLE_HOST', DEFAULT_HOST),
         | 
| 22 | 
            +
                    version: ENV.fetch('GOOGLE_VERSION', DEFAULT_VERSION),
         | 
| 23 | 
            +
                    logger: nil,
         | 
| 24 | 
            +
                    timeout: nil
         | 
| 25 | 
            +
                  )
         | 
| 26 | 
            +
                    super(api_key:, host:, logger:, timeout:)
         | 
| 27 | 
            +
                    @version = version
         | 
| 15 28 | 
             
                  end
         | 
| 16 29 | 
             
                end
         | 
| 17 30 | 
             
              end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: omniai-google
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.4.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Kevin Sylvestre
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024- | 
| 11 | 
            +
            date: 2024-07-04 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: event_stream_parser
         |