SamanthaStorm commited on
Commit
8240c34
·
verified ·
1 Parent(s): 8a5406e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -112,8 +112,30 @@ def generate_risk_snippet(abuse_score, top_label, escalation_score):
112
  risk_level = "moderate"
113
  else:
114
  risk_level = "low"
115
- title, summary, advice = RISK_SNIPPETS[risk_level]
116
- return f"\n\n{title}\n{summary} (Pattern: **{str(top_label)}**)\n💡 {advice}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
  def analyze_single_message(text, thresholds, motif_flags):
119
  motif_hits, matched_phrases = detect_motifs(text)
 
112
  risk_level = "moderate"
113
  else:
114
  risk_level = "low"
115
+
116
+ pattern_label = top_label.split(" ")[0]
117
+ pattern_score = top_label.split(" – ")[1] if " – " in top_label else ""
118
+
119
+ base = f"\n\n🛑 Risk Level: {risk_level.capitalize()}\n"
120
+ base += f"This message shows strong indicators of **{pattern_label}**. "
121
+
122
+ if risk_level == "high":
123
+ base += "The language may reflect patterns of emotional control, even when expressed in soft or caring terms.\n"
124
+ elif risk_level == "moderate":
125
+ base += "There are signs of emotional pressure or indirect control that may escalate if repeated.\n"
126
+ else:
127
+ base += "The message does not strongly indicate abuse, but it's important to monitor for patterns.\n"
128
+
129
+ base += "\n💡 *Why this might be flagged:*\n"
130
+ base += (
131
+ "This message may seem supportive, but language like “Do you need me to come home?” can sometimes carry implied pressure, especially if declining leads to guilt, tension, or emotional withdrawal. "
132
+ "The model looks for patterns that reflect subtle coercion, obligation, or reversal dynamics—even when not overtly aggressive.\n"
133
+ )
134
+
135
+ base += f"\nDetected Pattern: **{pattern_label} ({pattern_score})**\n"
136
+ base += "🧠 You can review the pattern in context. This tool highlights possible dynamics—not judgments."
137
+
138
+ return base
139
 
140
  def analyze_single_message(text, thresholds, motif_flags):
141
  motif_hits, matched_phrases = detect_motifs(text)