Class: ActiveGenie::Config::Providers::GoogleConfig

Inherits:
ProviderBase
  • Object
show all
Defined in:
lib/active_genie/configs/providers/google_config.rb

Overview

Configuration class for the Google Generative Language API client. Manages API keys, URLs, model selections, and client instantiation.

Instance Attribute Summary

Attributes inherited from ProviderBase

#organization

Instance Method Summary collapse

Methods inherited from ProviderBase

#initialize, #to_h, #valid?

Constructor Details

This class inherits a constructor from ActiveGenie::Config::Providers::ProviderBase

Instance Method Details

#api_keyString?

Retrieves the API key. Falls back to the GENERATIVE_LANGUAGE_GOOGLE_API_KEY environment variable if not set.

Returns:

  • (String, nil)

    The API key.



14
15
16
# File 'lib/active_genie/configs/providers/google_config.rb', line 14

def api_key
  @api_key || ENV['GENERATIVE_LANGUAGE_GOOGLE_API_KEY'] || ENV.fetch('GEMINI_API_KEY', nil)
end

#api_urlString

Retrieves the base API URL for Google Generative Language API. Defaults to ‘generativelanguage.googleapis.com’.

Returns:

  • (String)

    The API base URL.



21
22
23
24
25
# File 'lib/active_genie/configs/providers/google_config.rb', line 21

def api_url
  # NOTE: Google Generative Language API uses a specific path structure like /v1beta/models/{model}:generateContent
  # The base URL here should be just the domain part.
  @api_url || 'https://generativelanguage.googleapis.com'
end

#default_modelObject



27
28
29
# File 'lib/active_genie/configs/providers/google_config.rb', line 27

def default_model
  @default_model || 'gemini-2.5-flash'
end

#valid_model?(model) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/active_genie/configs/providers/google_config.rb', line 31

def valid_model?(model)
  model.include?('gemini')
end