SamanthaStorm commited on
Commit
68c555d
Β·
verified Β·
1 Parent(s): 7c5f796

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -525,12 +525,11 @@ def analyze_composite(msg1, date1, msg2, date2, msg3, date3, *answers_and_none):
525
  escalation_score = None
526
  risk_level = "unknown"
527
  else:
528
- escalation_score = sum(w for (_, w), a in zip(ESCALATION_QUESTIONS, answers_and_none[:-1]) if a)
529
- escalation_bump = 0 # Will be computed later
530
- hybrid_score = escalation_score # Start with raw
531
-
532
  # We'll finalize `risk_level` after computing bump below
533
- risk_level = "Low"
534
  messages = [msg1, msg2, msg3]
535
  dates = [date1, date2, date3]
536
  active = [(m, d) for m, d in zip(messages, dates) if m.strip()]
@@ -551,6 +550,12 @@ def analyze_composite(msg1, date1, msg2, date2, msg3, date3, *answers_and_none):
551
  escalation_bump += 2
552
  if stage == 2:
553
  escalation_bump += 3
 
 
 
 
 
 
554
  for result, date in results:
555
  assert len(result) == 7, "Unexpected output from analyze_single_message"
556
  abuse_scores = [r[0][0] for r in results]
@@ -618,7 +623,7 @@ def analyze_composite(msg1, date1, msg2, date2, msg3, date3, *answers_and_none):
618
  top_label = f"{sorted_patterns[0][0]} – {int(round(sorted_patterns[0][1] * 100))}%"
619
  if top_label is None:
620
  top_label = "Unknown – 0%"
621
- out += generate_risk_snippet(composite_abuse, top_label, escalation_score if escalation_score is not None else 0, most_common_stage)
622
  out += f"\n\n{stage_text}"
623
  out += darvo_blurb
624
  out += "\n\n🎭 **Emotional Tones Detected:**\n"
 
525
  escalation_score = None
526
  risk_level = "unknown"
527
  else:
528
+ escalation_score = sum(w for (_, w), a in zip(ESCALATION_QUESTIONS, answers_and_none[:-1]) if a)
529
+ escalation_bump = 0 # Will be computed later
530
+ hybrid_score = escalation_score # Start with raw
 
531
  # We'll finalize `risk_level` after computing bump below
532
+ risk_level = "Low"
533
  messages = [msg1, msg2, msg3]
534
  dates = [date1, date2, date3]
535
  active = [(m, d) for m, d in zip(messages, dates) if m.strip()]
 
550
  escalation_bump += 2
551
  if stage == 2:
552
  escalation_bump += 3
553
+ hybrid_score = escalation_score + escalation_bump
554
+ risk_level = (
555
+ "High" if hybrid_score >= 16 else
556
+ "Moderate" if hybrid_score >= 8 else
557
+ "Low"
558
+ )
559
  for result, date in results:
560
  assert len(result) == 7, "Unexpected output from analyze_single_message"
561
  abuse_scores = [r[0][0] for r in results]
 
623
  top_label = f"{sorted_patterns[0][0]} – {int(round(sorted_patterns[0][1] * 100))}%"
624
  if top_label is None:
625
  top_label = "Unknown – 0%"
626
+ out += generate_risk_snippet(composite_abuse, top_label, hybrid_score if escalation_score is not None else 0, most_common_stage)
627
  out += f"\n\n{stage_text}"
628
  out += darvo_blurb
629
  out += "\n\n🎭 **Emotional Tones Detected:**\n"