Class: Ace::LLM::Configuration
- Inherits:
-
Object
- Object
- Ace::LLM::Configuration
- Defined in:
- lib/ace/llm/configuration.rb
Overview
Central configuration management for ace-llm
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#active_provider_names ⇒ Object
Normalized names of active providers after filtering.
-
#all_providers ⇒ Object
Get all configured provider configurations before allow-list filtering.
-
#configured? ⇒ Boolean
Check if configuration exists.
-
#configured_provider_names ⇒ Object
Normalized names of all configured providers.
-
#get(path) ⇒ Object
Get configuration value by path.
-
#inactive_provider_names ⇒ Object
Normalized names that are configured but inactive under active filter.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#provider(name) ⇒ Object
Get provider config by name.
-
#provider?(name) ⇒ Boolean
Check if provider exists.
-
#provider_filter_applied? ⇒ Boolean
Returns true when allow-list filtering is active.
-
#provider_inactive?(name) ⇒ Boolean
Returns true when provider exists in config but is excluded by allow-list.
-
#provider_names ⇒ Object
Get all provider names.
-
#providers ⇒ Object
Get all provider configurations from the cascade Uses ProviderConfigReader which handles project → home → gem discovery.
-
#reload! ⇒ Object
Reload configuration.
-
#roles ⇒ Object
Get configured role map (llm.roles) from config cascade.
Constructor Details
#initialize ⇒ Configuration
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
#config ⇒ Object (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_names ⇒ Object
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_providers ⇒ Object
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
68 69 70 |
# File 'lib/ace/llm/configuration.rb', line 68 def configured? !config.empty? end |
#configured_provider_names ⇒ Object
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_names ⇒ Object
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
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.
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.
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_names ⇒ Object
Get all provider names
45 46 47 |
# File 'lib/ace/llm/configuration.rb', line 45 def provider_names providers.keys end |
#providers ⇒ Object
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 |
#roles ⇒ Object
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 |