module GeekDict::Config
Constants
- ALLOWED_PROVIDERS
- CONFIG_PATH
- DEFAULT_MODEL
- DEFAULT_PROVIDER
Public Instance Methods
Source
# File lib/geekdict/config.rb, line 13 def load_config config = {} if File.exist?(CONFIG_PATH) begin loaded_config = YAML.load_file(CONFIG_PATH) config = loaded_config if loaded_config.is_a?(Hash) rescue Psych::SyntaxError => e warn "Warning: Error parsing config file #{CONFIG_PATH}: #{e.message}. Using defaults." rescue => e warn "Warning: Could not load config file #{CONFIG_PATH}: #{e.message}. Using defaults." end end # Ensure keys are symbols for easier access, handle potential nil values config = config.transform_keys { |k| k.to_s.downcase.to_sym rescue k } # Make keys symbols & lowercase { provider: config[:provider], model: config[:model] } end
Method to load configuration from ~/.geekdict.config