SamanthaStorm commited on
Commit
408ccbb
Β·
verified Β·
1 Parent(s): 94d8660

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -246,7 +246,7 @@ def analyze_single_message(text, thresholds):
246
  def analyze_composite(msg1, msg2, msg3, *answers_and_none):
247
  responses = answers_and_none[:len(ESCALATION_QUESTIONS)]
248
  none_selected = answers_and_none[-1]
249
- escalation_score = 0 if none_selected else sum(w for (_, w), a in zip(ESCALATION_QUESTIONS, responses) if a)
250
  messages = [msg1, msg2, msg3]
251
  active = [m for m in messages if m.strip()]
252
  if not active:
@@ -268,8 +268,12 @@ def analyze_composite(msg1, msg2, msg3, *answers_and_none):
268
 
269
  out = f"Abuse Intensity: {composite_abuse}%\n"
270
  out += "πŸ“Š This reflects the strength and severity of detected abuse patterns in the message(s).\n\n"
271
- 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"
272
- out += "🚨 This indicates how many serious risk factors are present based on your answers to the safety checklist.\n\n"
 
 
 
 
273
  out += generate_risk_snippet(composite_abuse, top_label, escalation_score, most_common_stage)
274
  out += f"\n\n{stage_text}"
275
 
 
246
  def analyze_composite(msg1, msg2, msg3, *answers_and_none):
247
  responses = answers_and_none[:len(ESCALATION_QUESTIONS)]
248
  none_selected = answers_and_none[-1]
249
+ escalation_score = None if none_selected else sum(w for (_, w), a in zip(ESCALATION_QUESTIONS, responses) if a)
250
  messages = [msg1, msg2, msg3]
251
  active = [m for m in messages if m.strip()]
252
  if not active:
 
268
 
269
  out = f"Abuse Intensity: {composite_abuse}%\n"
270
  out += "πŸ“Š This reflects the strength and severity of detected abuse patterns in the message(s).\n\n"
271
+ if escalation_score is None:
272
+ out += "Escalation Potential: Unknown (Checklist not completed)\n"
273
+ out += "πŸ” *This section was not completed. Escalation potential is unknown.*\n\n"
274
+ else:
275
+ 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"
276
+ out += "🚨 This indicates how many serious risk factors are present based on your answers to the safety checklist.\n\n"
277
  out += generate_risk_snippet(composite_abuse, top_label, escalation_score, most_common_stage)
278
  out += f"\n\n{stage_text}"
279