fix: keep PII detection separate from refusal metrics

This commit is contained in:
Edneam
2026-05-14 22:42:28 +05:30
parent d734067ef6
commit be7fb1f370
4 changed files with 69 additions and 19 deletions
@@ -33,6 +33,12 @@ class TestPIIDetector:
assert detector.detected_types("Contact me at jane@example.com") == []
assert detector.detected_types("card: 4111 1111 1111 1111") == ["credit_card"]
def test_credit_card_detection_can_be_disabled(self):
detector = PIIDetector(patterns=(), detect_credit_cards=False)
assert detector.detected_types("card: 4111 1111 1111 1111") == []
assert not detector.is_leak("card: 4111 1111 1111 1111")
def test_custom_patterns_can_be_used(self):
detector = PIIDetector(
patterns=(PIIPattern("employee_id", re.compile(r"EMP-\d{4}")),)