Class: Legion::Extensions::Llm::Configuration

Inherits:
Object
  • Object
show all
Includes:
Logging::Helper
Defined in:
lib/legion/extensions/llm/configuration.rb

Overview

Global configuration for Legion::Extensions::Llm

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



56
57
58
59
60
61
# File 'lib/legion/extensions/llm/configuration.rb', line 56

def initialize
  self.class.send(:defaults).each do |key, default|
    value = default.respond_to?(:call) ? instance_exec(&default) : default
    public_send("#{key}=", value)
  end
end

Class Method Details

.option(key, default = nil) ⇒ Object

Declare a single configuration option.



12
13
14
15
16
17
18
19
# File 'lib/legion/extensions/llm/configuration.rb', line 12

def option(key, default = nil)
  key = key.to_sym
  return if options.include?(key)

  send(:attr_accessor, key)
  option_keys << key
  defaults[key] = default
end

.optionsObject



21
22
23
# File 'lib/legion/extensions/llm/configuration.rb', line 21

def options
  option_keys.dup
end

Instance Method Details

#instance_variablesObject



63
64
65
# File 'lib/legion/extensions/llm/configuration.rb', line 63

def instance_variables
  super.reject { |ivar| ivar.to_s.match?(/_id|_key|_secret|_token$/) }
end

#log_regexp_timeout=(value) ⇒ Object



67
68
69
70
71
72
73
74
75
76
# File 'lib/legion/extensions/llm/configuration.rb', line 67

def log_regexp_timeout=(value)
  if value.nil?
    @log_regexp_timeout = nil
  elsif Regexp.respond_to?(:timeout)
    @log_regexp_timeout = value
  else
    log.warn { "log_regexp_timeout is not supported on Ruby #{RUBY_VERSION}" }
    @log_regexp_timeout = value
  end
end