Spaces:
Runtime error
Runtime error
File size: 1,015 Bytes
5f2a085 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | from app.core.config import Settings
from app.ml.heuristic_model import HeuristicScorer
from app.severity import calculate_severity
def test_heuristic_flags_direct_threat_as_high() -> None:
scorer = HeuristicScorer()
scores = scorer.predict("I will kill you and destroy you tonight.")
severity = calculate_severity(scores, prior_incident_count=0, settings=Settings())
assert scores.threat >= 0.8
assert scores.severe_toxicity >= 0.7
assert severity.severity_level == "high"
def test_heuristic_boosts_identity_attack_context() -> None:
scorer = HeuristicScorer()
scores = scorer.predict("You useless yoruba idiot.")
assert scores.identity_attack >= 0.7
def test_heuristic_keeps_benign_text_low() -> None:
scorer = HeuristicScorer()
scores = scorer.predict("Thanks for helping me with this project.")
severity = calculate_severity(scores, prior_incident_count=0, settings=Settings())
assert scores.toxic < 0.25
assert severity.severity_level == "low"
|