Class: Legion::Extensions::Llm::Configuration
- Inherits:
-
Object
- Object
- Legion::Extensions::Llm::Configuration
- Defined in:
- lib/legion/extensions/llm/configuration.rb
Overview
Global configuration for Legion::Extensions::Llm
Class Method Summary collapse
-
.option(key, default = nil) ⇒ Object
Declare a single configuration option.
- .options ⇒ Object
- .register_provider_options(options) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #instance_variables ⇒ Object
- #log_regexp_timeout=(value) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
58 59 60 61 62 63 |
# File 'lib/legion/extensions/llm/configuration.rb', line 58 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.
10 11 12 13 14 15 16 17 |
# File 'lib/legion/extensions/llm/configuration.rb', line 10 def option(key, default = nil) key = key.to_sym return if .include?(key) send(:attr_accessor, key) option_keys << key defaults[key] = default end |
.options ⇒ Object
23 24 25 |
# File 'lib/legion/extensions/llm/configuration.rb', line 23 def option_keys.dup end |
.register_provider_options(options) ⇒ Object
19 20 21 |
# File 'lib/legion/extensions/llm/configuration.rb', line 19 def () Array().each { |key| option(key, nil) } end |
Instance Method Details
#instance_variables ⇒ Object
65 66 67 |
# File 'lib/legion/extensions/llm/configuration.rb', line 65 def instance_variables super.reject { |ivar| ivar.to_s.match?(/_id|_key|_secret|_token$/) } end |
#log_regexp_timeout=(value) ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/legion/extensions/llm/configuration.rb', line 69 def log_regexp_timeout=(value) if value.nil? @log_regexp_timeout = nil elsif Regexp.respond_to?(:timeout) @log_regexp_timeout = value else Legion::Extensions::Llm.logger.warn("log_regexp_timeout is not supported on Ruby #{RUBY_VERSION}") @log_regexp_timeout = value end end |