Class: Qualspec::ModelRegistry
- Inherits:
-
Object
- Object
- Qualspec::ModelRegistry
- Defined in:
- lib/qualspec/model_registry.rb
Overview
Loads a curated list of named models from a YAML config file and resolves names to their full provider slugs. Unknown/blank names fall back to the configured default (ultimately Configuration::DEFAULT_MODEL, openrouter/auto), so model lookups always return something usable.
Constant Summary collapse
- DEFAULT_CONFIG_PATH =
'config/models.yml'
Instance Method Summary collapse
-
#all ⇒ Hash{String=>String}
All configured name => slug pairs.
-
#default ⇒ String
The universal fallback model.
-
#initialize(path: nil, default: nil) ⇒ ModelRegistry
constructor
A new instance of ModelRegistry.
-
#resolve(name = nil) ⇒ String
Resolve a model name to its slug, falling back to the default.
Constructor Details
#initialize(path: nil, default: nil) ⇒ ModelRegistry
Returns a new instance of ModelRegistry.
23 24 25 26 27 |
# File 'lib/qualspec/model_registry.rb', line 23 def initialize(path: nil, default: nil) @models = {} @default = default load_file(path || ENV['QUALSPEC_MODELS_FILE'] || DEFAULT_CONFIG_PATH) end |
Instance Method Details
#all ⇒ Hash{String=>String}
Returns all configured name => slug pairs.
40 41 42 |
# File 'lib/qualspec/model_registry.rb', line 40 def all @models.dup end |
#default ⇒ String
Returns the universal fallback model.
45 46 47 |
# File 'lib/qualspec/model_registry.rb', line 45 def default @default || Configuration::DEFAULT_MODEL end |
#resolve(name = nil) ⇒ String
Resolve a model name to its slug, falling back to the default.
33 34 35 36 37 |
# File 'lib/qualspec/model_registry.rb', line 33 def resolve(name = nil) return default if name.nil? || name.to_s.empty? @models.fetch(name.to_s, default) end |