SamanthaStorm commited on
Commit
512a56e
Β·
verified Β·
1 Parent(s): d895eef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -39
app.py CHANGED
@@ -631,48 +631,48 @@ def analyze_composite(msg1, msg2, msg3, *answers_and_none):
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:
@@ -712,7 +712,6 @@ else:
712
  pattern_labels = [r[0][2][0][0] for r in results]
713
  timeline_image = generate_abuse_score_chart(dates_used, abuse_scores, pattern_labels)
714
  out += "\n\n" + escalation_text
715
-
716
  return out, timeline_image
717
 
718
  textbox_inputs = [gr.Textbox(label=f"Message {i+1}") for i in range(3)]
 
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:
 
712
  pattern_labels = [r[0][2][0][0] for r in results]
713
  timeline_image = generate_abuse_score_chart(dates_used, abuse_scores, pattern_labels)
714
  out += "\n\n" + escalation_text
 
715
  return out, timeline_image
716
 
717
  textbox_inputs = [gr.Textbox(label=f"Message {i+1}") for i in range(3)]