Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
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 |
-
|
641 |
-
|
642 |
-
elif responses_checked:
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
else:
|
648 |
-
|
649 |
-
|
650 |
|
651 |
# Build escalation_text and hybrid_score
|
652 |
-
if escalation_score is None:
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
elif escalation_score == 0:
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
else:
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
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)]
|