Class: SentinelRb::Analyzers::BaseModelUsage
- Defined in:
- lib/sentinel_rb/analyzers/base_model_usage.rb
Overview
A4: Base Model Usage Detection Detects prompts that may be attempting to use base models inappropriately or trying to bypass safety measures
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #analyze(prompt) ⇒ Object
- #call ⇒ Object
-
#initialize(prompt, config, client) ⇒ BaseModelUsage
constructor
A new instance of BaseModelUsage.
Constructor Details
#initialize(prompt, config, client) ⇒ BaseModelUsage
Returns a new instance of BaseModelUsage.
11 12 13 14 15 |
# File 'lib/sentinel_rb/analyzers/base_model_usage.rb', line 11 def initialize(prompt, config, client) super @instruction_keywords = config["instruction_keywords"] || default_instruction_keywords @bypass_patterns = config["bypass_patterns"] || default_bypass_patterns end |
Instance Method Details
#analyze(prompt) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sentinel_rb/analyzers/base_model_usage.rb', line 21 def analyze(prompt) findings = [] # Check for base model instruction patterns findings.concat(check_base_model_instructions(prompt)) # Check for safety bypass attempts findings.concat(check_safety_bypass_patterns(prompt)) # Check for role-playing that might bypass guidelines findings.concat(check_inappropriate_roleplay(prompt)) # Check for attempts to access training data findings.concat(check_training_data_access(prompt)) findings end |
#call ⇒ Object
17 18 19 |
# File 'lib/sentinel_rb/analyzers/base_model_usage.rb', line 17 def call analyze(@prompt) end |