SamanthaStorm commited on
Commit
eb8fc53
Β·
verified Β·
1 Parent(s): f8715b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -248,9 +248,16 @@ def analyze_composite(msg1, msg2, msg3, *answers_and_none):
248
  responses_checked = any(answers_and_none[:-1])
249
  none_selected = not responses_checked and none_selected_checked
250
 
251
- escalation_score = None if none_selected else sum(
252
- w for (response, (q, w)) in zip(answers_and_none[:-1], ESCALATION_QUESTIONS) if response
253
- )
 
 
 
 
 
 
 
254
 
255
  messages = [msg1, msg2, msg3]
256
  active = [m for m in messages if m.strip()]
@@ -267,6 +274,7 @@ def analyze_composite(msg1, msg2, msg3, *answers_and_none):
267
 
268
  composite_abuse = int(round(sum(abuse_scores) / len(abuse_scores)))
269
  top_label = f"{top_labels[0]} – {int(round(top_scores[0] * 100))}%"
 
270
  most_common_stage = max(set(stages), key=stages.count)
271
  stage_text = RISK_STAGE_LABELS[most_common_stage]
272
 
@@ -280,19 +288,13 @@ def analyze_composite(msg1, msg2, msg3, *answers_and_none):
280
  out += "πŸ“Š This reflects the strength and severity of detected abuse patterns in the message(s).\n\n"
281
 
282
  if escalation_score is None:
283
- risk_level = "unknown"
284
  out += "Escalation Potential: Unknown (Checklist not completed)\n"
285
  out += "πŸ” *This section was not completed. Escalation potential is unknown.*\n\n"
286
  else:
287
- risk_level = (
288
- "High" if escalation_score >= 16 else
289
- "Moderate" if escalation_score >= 8 else
290
- "Low"
291
- )
292
  out += f"Escalation Potential: {risk_level} ({escalation_score}/{sum(w for _, w in ESCALATION_QUESTIONS)})\n"
293
  out += "🚨 This indicates how many serious risk factors are present based on your answers to the safety checklist.\n\n"
294
 
295
- out += generate_risk_snippet(composite_abuse, top_label, escalation_score or 0, most_common_stage)
296
  out += f"\n\n{stage_text}"
297
  out += darvo_blurb
298
 
 
248
  responses_checked = any(answers_and_none[:-1])
249
  none_selected = not responses_checked and none_selected_checked
250
 
251
+ if none_selected:
252
+ escalation_score = None
253
+ risk_level = "unknown"
254
+ else:
255
+ escalation_score = sum(w for (_, w), a in zip(ESCALATION_QUESTIONS, answers_and_none[:-1]) if a)
256
+ risk_level = (
257
+ "High" if escalation_score >= 16 else
258
+ "Moderate" if escalation_score >= 8 else
259
+ "Low"
260
+ )
261
 
262
  messages = [msg1, msg2, msg3]
263
  active = [m for m in messages if m.strip()]
 
274
 
275
  composite_abuse = int(round(sum(abuse_scores) / len(abuse_scores)))
276
  top_label = f"{top_labels[0]} – {int(round(top_scores[0] * 100))}%"
277
+
278
  most_common_stage = max(set(stages), key=stages.count)
279
  stage_text = RISK_STAGE_LABELS[most_common_stage]
280
 
 
288
  out += "πŸ“Š This reflects the strength and severity of detected abuse patterns in the message(s).\n\n"
289
 
290
  if escalation_score is None:
 
291
  out += "Escalation Potential: Unknown (Checklist not completed)\n"
292
  out += "πŸ” *This section was not completed. Escalation potential is unknown.*\n\n"
293
  else:
 
 
 
 
 
294
  out += f"Escalation Potential: {risk_level} ({escalation_score}/{sum(w for _, w in ESCALATION_QUESTIONS)})\n"
295
  out += "🚨 This indicates how many serious risk factors are present based on your answers to the safety checklist.\n\n"
296
 
297
+ out += generate_risk_snippet(composite_abuse, top_label, escalation_score if escalation_score is not None else 0, most_common_stage)
298
  out += f"\n\n{stage_text}"
299
  out += darvo_blurb
300