SamanthaStorm commited on
Commit
cb8a766
·
verified ·
1 Parent(s): 15966ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -533,10 +533,18 @@ def analyze_composite(msg1, date1, msg2, date2, msg3, date3, *answers_and_none):
533
  else:
534
  escalation_score = sum(w for (_, w), a in zip(ESCALATION_QUESTIONS, answers_and_none[:-1]) if a)
535
  escalation_bump = 0 # Will be computed later
536
- hybrid_score = escalation_score # Start with raw
537
- # We'll finalize `risk_level` after computing bump below
538
- risk_level = "Low"
539
- # Escalation override for high-risk spike or escalation stage
 
 
 
 
 
 
 
 
540
  if any(score > 70 for score in abuse_scores) or any(stage == 2 for stage in stages):
541
  if risk_level == "Low":
542
  risk_level = "Moderate"
 
533
  else:
534
  escalation_score = sum(w for (_, w), a in zip(ESCALATION_QUESTIONS, answers_and_none[:-1]) if a)
535
  escalation_bump = 0 # Will be computed later
536
+ hybrid_score = escalation_score + escalation_bump
537
+ risk_level = (
538
+ "High" if hybrid_score >= 16 else
539
+ "Moderate" if hybrid_score >= 8 else
540
+ "Low"
541
+ )
542
+
543
+ # Now it's safe to assign these:
544
+ abuse_scores = [r[0][0] for r in results]
545
+ stages = [r[0][4] for r in results]
546
+
547
+ # Post-check override to catch hidden risks
548
  if any(score > 70 for score in abuse_scores) or any(stage == 2 for stage in stages):
549
  if risk_level == "Low":
550
  risk_level = "Moderate"