Class: CompletionKit::Checks::NoRefusal

Inherits:
Object
  • Object
show all
Defined in:
app/services/completion_kit/checks/no_refusal.rb

Constant Summary collapse

PATTERNS =
[
  /\bi'?m sorry\b/i,
  /\bi can'?t (?:help|assist|comply|do that|provide)/i,
  /\bi (?:cannot|can'?t) (?:help|assist|fulfill|comply|provide)/i,
  /\bi'?m (?:unable|not able) to\b/i,
  /\bi (?:won'?t|will not) (?:be able|help|assist)\b/i,
  /\bas an ai\b/i
].freeze

Instance Method Summary collapse

Instance Method Details

#call(target, _config) ⇒ Object



13
14
15
16
17
18
19
20
# File 'app/services/completion_kit/checks/no_refusal.rb', line 13

def call(target, _config)
  text = target.to_s
  if PATTERNS.any? { |pattern| pattern.match?(text) }
    Result.new(passed: false, detail: "refusal detected")
  else
    Result.new(passed: true, detail: "no refusal detected")
  end
end