Class: Artificial::Validators::RoleValidator
- Inherits:
-
Object
- Object
- Artificial::Validators::RoleValidator
- Defined in:
- lib/artificial/validators/role_validator.rb
Constant Summary collapse
- VALID_SYSTEM_ROLES =
%w[ expert assistant helper instructor teacher guide analyst specialist consultant advisor reviewer critic evaluator researcher scientist engineer developer programmer writer editor translator interpreter ].freeze
- ROLE_PATTERNS =
{ domain_expert: /^you are (?:a|an) (.+) expert/i, professional: /^you are (?:a|an) (.+) professional/i, specialist: /^you are (?:a|an) (.+) specialist/i, assistant: /^you are (?:a|an) (?:helpful|knowledgeable|.+) assistant/i }.freeze
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#role_type ⇒ Object
readonly
Returns the value of attribute role_type.
-
#suggestions ⇒ Object
readonly
Returns the value of attribute suggestions.
-
#system_prompt ⇒ Object
readonly
Returns the value of attribute system_prompt.
Instance Method Summary collapse
- #effective? ⇒ Boolean
- #error_messages ⇒ Object
-
#initialize(system_prompt) ⇒ RoleValidator
constructor
A new instance of RoleValidator.
- #optimization_suggestions ⇒ Object
- #valid? ⇒ Boolean
- #validate ⇒ Object
Constructor Details
#initialize(system_prompt) ⇒ RoleValidator
22 23 24 25 26 27 |
# File 'lib/artificial/validators/role_validator.rb', line 22 def initialize(system_prompt) @system_prompt = system_prompt @role_type = nil @errors = [] @suggestions = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
20 21 22 |
# File 'lib/artificial/validators/role_validator.rb', line 20 def errors @errors end |
#role_type ⇒ Object (readonly)
Returns the value of attribute role_type.
20 21 22 |
# File 'lib/artificial/validators/role_validator.rb', line 20 def role_type @role_type end |
#suggestions ⇒ Object (readonly)
Returns the value of attribute suggestions.
20 21 22 |
# File 'lib/artificial/validators/role_validator.rb', line 20 def suggestions @suggestions end |
#system_prompt ⇒ Object (readonly)
Returns the value of attribute system_prompt.
20 21 22 |
# File 'lib/artificial/validators/role_validator.rb', line 20 def system_prompt @system_prompt end |
Instance Method Details
#effective? ⇒ Boolean
47 48 49 50 |
# File 'lib/artificial/validators/role_validator.rb', line 47 def effective? validate unless @role_type @role_type != :generic end |
#error_messages ⇒ Object
52 53 54 |
# File 'lib/artificial/validators/role_validator.rb', line 52 def @errors end |
#optimization_suggestions ⇒ Object
56 57 58 |
# File 'lib/artificial/validators/role_validator.rb', line 56 def optimization_suggestions @suggestions end |
#valid? ⇒ Boolean
42 43 44 45 |
# File 'lib/artificial/validators/role_validator.rb', line 42 def valid? validate if @errors.empty? @errors.empty? end |
#validate ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/artificial/validators/role_validator.rb', line 29 def validate @errors.clear @suggestions.clear return add_error('System prompt cannot be empty') if @system_prompt.nil? || @system_prompt.strip.empty? analyze_role_effectiveness check_role_clarity provide_optimization_suggestions self end |