SamanthaStorm commited on
Commit
ea50b1d
Β·
verified Β·
1 Parent(s): 687104b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -244,9 +244,10 @@ def analyze_single_message(text, thresholds):
244
  return abuse_score, threshold_labels, top_patterns, result, stage, darvo_score
245
 
246
  def analyze_composite(msg1, msg2, msg3, *answers_and_none):
247
- responses = answers_and_none[:len(ESCALATION_QUESTIONS)]
248
- none_selected = bool(answers_and_none[-1])
249
-
 
250
  messages = [msg1, msg2, msg3]
251
  active = [m for m in messages if m.strip()]
252
  if not active:
@@ -273,15 +274,11 @@ def analyze_composite(msg1, msg2, msg3, *answers_and_none):
273
  darvo_blurb = f"\n\n🎭 **DARVO Score: {avg_darvo}** β†’ This indicates a **{level} likelihood** of narrative reversal (DARVO), where the speaker may be denying, attacking, or reversing blame."
274
 
275
  if none_selected:
276
- escalation_score = 0
277
- escalation_potential = "Unknown (Checklist not completed)"
278
- escalation_note = "πŸ” *This section was not completed. Escalation potential is unknown.*"
279
  else:
280
- escalation_score = sum(w for (_, w), a in zip(ESCALATION_QUESTIONS, responses) if a)
281
- escalation_total = sum(w for _, w in ESCALATION_QUESTIONS)
282
- level = "High" if escalation_score >= 16 else "Moderate" if escalation_score >= 8 else "Low"
283
- escalation_potential = f"{level} ({escalation_score}/{escalation_total})"
284
- escalation_note = "🚨 This indicates how many serious risk factors are present based on your answers to the safety checklist."
285
 
286
  out = f"Abuse Intensity: {composite_abuse}%\n"
287
  out += "πŸ“Š This reflects the strength and severity of detected abuse patterns in the message(s).\n\n"
 
244
  return abuse_score, threshold_labels, top_patterns, result, stage, darvo_score
245
 
246
  def analyze_composite(msg1, msg2, msg3, *answers_and_none):
247
+ none_selected_checked = answers_and_none[-1]
248
+ responses_checked = any(answers_and_none[:-1])
249
+ none_selected = not responses_checked and none_selected_checked
250
+
251
  messages = [msg1, msg2, msg3]
252
  active = [m for m in messages if m.strip()]
253
  if not active:
 
274
  darvo_blurb = f"\n\n🎭 **DARVO Score: {avg_darvo}** β†’ This indicates a **{level} likelihood** of narrative reversal (DARVO), where the speaker may be denying, attacking, or reversing blame."
275
 
276
  if none_selected:
277
+ out += "Escalation Potential: Unknown (Checklist not completed)\n"
278
+ out += "πŸ” *This section was not completed. Escalation potential is unknown.*\n\n"
 
279
  else:
280
+ out += f"Escalation Potential: {('High' if escalation_score >= 16 else 'Moderate' if escalation_score >= 8 else 'Low')} ({escalation_score}/{sum(w for _, w in ESCALATION_QUESTIONS)})\n"
281
+ out += "🚨 This indicates how many serious risk factors are present based on your answers to the safety checklist.\n\n"
 
 
 
282
 
283
  out = f"Abuse Intensity: {composite_abuse}%\n"
284
  out += "πŸ“Š This reflects the strength and severity of detected abuse patterns in the message(s).\n\n"