Class: Commiti::ConfigLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/services/helpers/config_loader.rb

Constant Summary collapse

DEFAULT_CONFIG =
{
  google_api_key: nil,
  model: Commiti::GoogleClient::DEFAULT_MODEL,
  candidates: 1,
  base_branch: 'main',
  no_copy: false,
  auto_split: false,
  temperature: Commiti::GoogleClient::DEFAULT_TEMPERATURE,
  timeout_seconds: Commiti::GoogleClient::DEFAULT_TIMEOUT_SECONDS,
  open_timeout_seconds: Commiti::GoogleClient::DEFAULT_OPEN_TIMEOUT_SECONDS
}.freeze

Class Method Summary collapse

Class Method Details

.load(env: ENV) ⇒ Object

Loads configuration from environment variables. Keys are returned as symbols with parsed values.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/services/helpers/config_loader.rb', line 19

def self.load(env: ENV)
  {
    google_api_key: google_api_key_from_env(env),
    model: present_or_default(env.fetch('COMMITI_MODEL', nil), DEFAULT_CONFIG[:model]),
    candidates: integer_or_default(env.fetch('COMMITI_CANDIDATES', nil), DEFAULT_CONFIG[:candidates]),
    base_branch: present_or_default(env.fetch('COMMITI_BASE_BRANCH', nil), DEFAULT_CONFIG[:base_branch]),
    no_copy: boolean_or_default(env.fetch('COMMITI_NO_COPY', nil), DEFAULT_CONFIG[:no_copy]),
    auto_split: boolean_or_default(env.fetch('COMMITI_AUTO_SPLIT', nil), DEFAULT_CONFIG[:auto_split]),
    temperature: float_or_default(env.fetch('COMMITI_MODEL_TEMPERATURE', nil), DEFAULT_CONFIG[:temperature]),
    timeout_seconds: integer_or_default(env.fetch('COMMITI_MODEL_TIMEOUT_SECONDS', nil), DEFAULT_CONFIG[:timeout_seconds]),
    open_timeout_seconds: integer_or_default(env.fetch('COMMITI_MODEL_OPEN_TIMEOUT_SECONDS', nil),
                                             DEFAULT_CONFIG[:open_timeout_seconds])
  }
end