SamanthaStorm commited on
Commit
d895eef
Β·
verified Β·
1 Parent(s): 898be48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -12
app.py CHANGED
@@ -533,9 +533,18 @@ def analyze_composite(msg1, msg2, msg3, *answers_and_none):
533
  responses_checked = any(answers_and_none[:-1])
534
  none_selected = not responses_checked and none_selected_checked
535
 
536
- escalation_score = None
537
- if not none_selected:
 
 
 
538
  escalation_score = sum(w for (_, w), a in zip(ESCALATION_QUESTIONS, answers_and_none[:-1]) if a)
 
 
 
 
 
 
539
 
540
  messages = [msg1, msg2, msg3]
541
  active = [(m, f"Message {i+1}") for i, m in enumerate(messages) if m.strip()]
@@ -622,17 +631,48 @@ def analyze_composite(msg1, msg2, msg3, *answers_and_none):
622
  "Low"
623
  )
624
 
625
- if escalation_score is None:
626
- escalation_text = "🚫 **Escalation Potential: Unknown** (Checklist not completed)\n⚠️ This section was not completed. Escalation potential is estimated using message data only.\n"
627
- hybrid_score = 0
628
- else:
629
- hybrid_score = escalation_score + escalation_bump
630
- escalation_text = f"πŸ“ˆ **Escalation Potential: {escalation_risk} ({hybrid_score}/29)**\n"
631
- escalation_text += "πŸ“‹ This score combines your safety checklist answers *and* detected high-risk behavior.\n"
632
- escalation_text += f"β€’ Pattern Risk: {pattern_escalation_risk}\n"
633
- escalation_text += f"β€’ Checklist Risk: {checklist_escalation_risk}\n"
634
- escalation_text += f"β€’ Escalation Bump: +{escalation_bump} (from DARVO, tone, intensity, etc.)"
 
 
 
 
 
 
635
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
636
  # Composite Abuse Score
637
  composite_abuse_scores = []
638
  for result, _ in results:
 
533
  responses_checked = any(answers_and_none[:-1])
534
  none_selected = not responses_checked and none_selected_checked
535
 
536
+ if none_selected:
537
+ escalation_score = 0
538
+ escalation_note = "Checklist completed: no danger items reported."
539
+ escalation_completed = True
540
+ elif responses_checked:
541
  escalation_score = sum(w for (_, w), a in zip(ESCALATION_QUESTIONS, answers_and_none[:-1]) if a)
542
+ escalation_note = "Checklist completed."
543
+ escalation_completed = True
544
+ else:
545
+ escalation_score = None
546
+ escalation_note = "Checklist not completed."
547
+ escalation_completed = False
548
 
549
  messages = [msg1, msg2, msg3]
550
  active = [(m, f"Message {i+1}") for i, m in enumerate(messages) if m.strip()]
 
631
  "Low"
632
  )
633
 
634
+ none_selected_checked = answers_and_none[-1]
635
+ responses_checked = any(answers_and_none[:-1])
636
+ none_selected = not responses_checked and none_selected_checked
637
+
638
+ # Determine escalation_score
639
+ if none_selected:
640
+ escalation_score = 0
641
+ escalation_completed = True
642
+ elif responses_checked:
643
+ escalation_score = sum(
644
+ w for (_, w), a in zip(ESCALATION_QUESTIONS, answers_and_none[:-1]) if a
645
+ )
646
+ escalation_completed = True
647
+ else:
648
+ escalation_score = None
649
+ escalation_completed = False
650
 
651
+ # Build escalation_text and hybrid_score
652
+ if escalation_score is None:
653
+ escalation_text = (
654
+ "🚫 **Escalation Potential: Unknown** (Checklist not completed)\n"
655
+ "⚠️ This section was not completed. Escalation potential is estimated using message data only.\n"
656
+ )
657
+ hybrid_score = 0
658
+ elif escalation_score == 0:
659
+ escalation_text = (
660
+ "βœ… **Escalation Checklist Completed:** No danger items reported.\n"
661
+ "🧭 **Escalation potential estimated from detected message patterns only.**\n"
662
+ f"β€’ Pattern Risk: {pattern_escalation_risk}\n"
663
+ f"β€’ Checklist Risk: None reported\n"
664
+ f"β€’ Escalation Bump: +{escalation_bump} (from DARVO, tone, intensity, etc.)"
665
+ )
666
+ hybrid_score = escalation_bump
667
+ else:
668
+ hybrid_score = escalation_score + escalation_bump
669
+ escalation_text = (
670
+ f"πŸ“ˆ **Escalation Potential: {escalation_risk} ({hybrid_score}/29)**\n"
671
+ "πŸ“‹ This score combines your safety checklist answers *and* detected high-risk behavior.\n"
672
+ f"β€’ Pattern Risk: {pattern_escalation_risk}\n"
673
+ f"β€’ Checklist Risk: {checklist_escalation_risk}\n"
674
+ f"β€’ Escalation Bump: +{escalation_bump} (from DARVO, tone, intensity, etc.)"
675
+ )
676
  # Composite Abuse Score
677
  composite_abuse_scores = []
678
  for result, _ in results: