Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
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 |
-
|
537 |
-
|
|
|
|
|
|
|
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 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|