Class: Nanobot::Config::ProvidersConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/nanobot/config/schema.rb

Overview

Collection of LLM provider configurations, keyed by provider name. Accepts any provider name so new RubyLLM backends work without code changes.

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ ProvidersConfig

Returns a new instance of ProvidersConfig.

Parameters:

  • kwargs (Hash) —

    provider name => settings hash pairs



21
22
23
24
25
26
# File 'lib/nanobot/config/schema.rb', line 21

def initialize(**kwargs)
  @providers = {}
  kwargs.each do |key, value|
    @providers[key.to_sym] = value.is_a?(ProviderConfig) ? value : ProviderConfig.new(**value)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



44
45
46
47
48
# File 'lib/nanobot/config/schema.rb', line 44

def method_missing(name, *args)
  return super if name.end_with?('=') || !args.empty?

  @providers[name.to_sym]
end

Instance Method Details

#each {|key, config| ... } ⇒ Object

Iterate over all configured providers

Yield Parameters:

  • key (Symbol) —

    provider name

  • config (ProviderConfig) —

    provider configuration



31
32
33
# File 'lib/nanobot/config/schema.rb', line 31

def each(&)
  @providers.each(&)
end

#empty? ⇒ Boolean

Returns true when no providers are configured.

Returns:

  • (Boolean) —

    true when no providers are configured



36
37
38
# File 'lib/nanobot/config/schema.rb', line 36

def empty?
  @providers.empty?
end

#respond_to_missing?(_name, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/nanobot/config/schema.rb', line 40

def respond_to_missing?(_name, _include_private = false)
  true
end