Class: Ace::LLM::Models::RoleConfig
- Inherits:
-
Object
- Object
- Ace::LLM::Models::RoleConfig
- Defined in:
- lib/ace/llm/models/role_config.rb
Overview
RoleConfig represents llm.roles configuration with validation.
Instance Attribute Summary collapse
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
Class Method Summary collapse
Instance Method Summary collapse
- #candidates_for(role_name) ⇒ Object
-
#initialize(roles: {}) ⇒ RoleConfig
constructor
A new instance of RoleConfig.
- #role_names ⇒ Object
Constructor Details
#initialize(roles: {}) ⇒ RoleConfig
Returns a new instance of RoleConfig.
10 11 12 13 |
# File 'lib/ace/llm/models/role_config.rb', line 10 def initialize(roles: {}) @roles = normalize_roles(roles).freeze validate! end |
Instance Attribute Details
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
8 9 10 |
# File 'lib/ace/llm/models/role_config.rb', line 8 def roles @roles end |
Class Method Details
.from_hash(hash) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ace/llm/models/role_config.rb', line 15 def self.from_hash(hash) return new unless hash unless hash.is_a?(Hash) raise Ace::LLM::ConfigurationError, "llm.roles config must be a Hash, got: #{hash.class}" end roles = hash.fetch(:roles, hash.fetch("roles", hash)) new(roles: roles) end |
Instance Method Details
#candidates_for(role_name) ⇒ Object
30 31 32 33 |
# File 'lib/ace/llm/models/role_config.rb', line 30 def candidates_for(role_name) normalized = normalize_role_name(role_name) @roles[normalized] end |
#role_names ⇒ Object
26 27 28 |
# File 'lib/ace/llm/models/role_config.rb', line 26 def role_names @roles.keys.sort end |