Class: Ace::LLM::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/llm/configuration.rb

Overview

Central configuration management for ace-llm

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
# File 'lib/ace/llm/configuration.rb', line 11

def initialize
  @config = Molecules::ConfigLoader.load
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/ace/llm/configuration.rb', line 9

def config
  @config
end

Instance Method Details

#active_provider_namesObject

Normalized names of active providers after filtering.



85
86
87
88
89
# File 'lib/ace/llm/configuration.rb', line 85

def active_provider_names
  providers.map do |provider_name, provider_config|
    normalize_provider_name(provider_config["name"] || provider_name)
  end.uniq.sort
end

#all_providersObject

Get all configured provider configurations before allow-list filtering



22
23
24
25
26
27
# File 'lib/ace/llm/configuration.rb', line 22

def all_providers
  @all_providers ||= begin
    require "ace/support/models"
    Ace::Support::Models::Atoms::ProviderConfigReader.read_all
  end
end

#configured?Boolean

Check if configuration exists

Returns:

  • (Boolean)


68
69
70
# File 'lib/ace/llm/configuration.rb', line 68

def configured?
  !config.empty?
end

#configured_provider_namesObject

Normalized names of all configured providers.



78
79
80
81
82
# File 'lib/ace/llm/configuration.rb', line 78

def configured_provider_names
  all_providers.map do |provider_name, provider_config|
    normalize_provider_name(provider_config["name"] || provider_name)
  end.uniq.sort
end

#get(path) ⇒ Object

Get configuration value by path



58
59
60
# File 'lib/ace/llm/configuration.rb', line 58

def get(path)
  Molecules::ConfigLoader.get(path)
end

#inactive_provider_namesObject

Normalized names that are configured but inactive under active filter.



92
93
94
95
96
# File 'lib/ace/llm/configuration.rb', line 92

def inactive_provider_names
  return [] unless provider_filter_applied?

  configured_provider_names - active_provider_names
end

#provider(name) ⇒ Object

Get provider config by name



30
31
32
33
34
35
36
37
# File 'lib/ace/llm/configuration.rb', line 30

def provider(name)
  normalized = normalize_provider_name(name)
  _name, config = providers.find do |provider_name, provider_config|
    normalize_provider_name(provider_name) == normalized ||
      normalize_provider_name(provider_config["name"]) == normalized
  end
  config
end

#provider?(name) ⇒ Boolean

Check if provider exists

Returns:

  • (Boolean)


40
41
42
# File 'lib/ace/llm/configuration.rb', line 40

def provider?(name)
  !provider(name).nil?
end

#provider_filter_applied?Boolean

Returns true when allow-list filtering is active.

Returns:

  • (Boolean)


73
74
75
# File 'lib/ace/llm/configuration.rb', line 73

def provider_filter_applied?
  !active_provider_allow_list.nil?
end

#provider_inactive?(name) ⇒ Boolean

Returns true when provider exists in config but is excluded by allow-list.

Returns:

  • (Boolean)


99
100
101
102
103
104
105
# File 'lib/ace/llm/configuration.rb', line 99

def provider_inactive?(name)
  normalized = normalize_provider_name(name)
  return false if normalized.empty?
  return false unless provider_filter_applied?

  configured_provider_names.include?(normalized) && !active_provider_names.include?(normalized)
end

#provider_namesObject

Get all provider names



45
46
47
# File 'lib/ace/llm/configuration.rb', line 45

def provider_names
  providers.keys
end

#providersObject

Get all provider configurations from the cascade Uses ProviderConfigReader which handles project → home → gem discovery



17
18
19
# File 'lib/ace/llm/configuration.rb', line 17

def providers
  @providers ||= filter_active_providers(all_providers)
end

#reload!Object

Reload configuration



50
51
52
53
54
55
# File 'lib/ace/llm/configuration.rb', line 50

def reload!
  @config = Molecules::ConfigLoader.load
  @all_providers = nil
  @providers = nil
  self
end

#rolesObject

Get configured role map (llm.roles) from config cascade.



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

def roles
  get("llm.roles") || {}
end