SamanthaStorm commited on
Commit
65d0b2c
·
verified ·
1 Parent(s): 933d668

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -346,7 +346,9 @@ def get_risk_stage(patterns, sentiment):
346
  elif sentiment == "supportive" and any(p in patterns for p in ["projection", "dismissiveness"]):
347
  return 4
348
  return 1
349
-
 
 
350
  def generate_risk_snippet(abuse_score, top_label, escalation_score, stage, pattern_scores):
351
  aggression_score = pattern_scores.get("aggression", 0)
352
 
@@ -666,7 +668,13 @@ def analyze_composite(msg1, date1, msg2, date2, msg3, date3, *answers_and_none):
666
  if top_label is None:
667
  top_label = "Unknown – 0%"
668
 
669
- out += generate_risk_snippet(composite_abuse, top_label, hybrid_score if escalation_score is not None else 0, most_common_stage)
 
 
 
 
 
 
670
  out += f"\n\n{stage_text}"
671
  out += darvo_blurb
672
  out += "\n\n🎭 **Emotional Tones Detected:**\n"
 
346
  elif sentiment == "supportive" and any(p in patterns for p in ["projection", "dismissiveness"]):
347
  return 4
348
  return 1
349
+ # Use pattern scores from the top-scoring message for risk snippet
350
+ index_top_msg = abuse_scores.index(max(abuse_scores))
351
+ pattern_scores_for_snippet = {label: score for label, score in results[index_top_msg][0][2]}
352
  def generate_risk_snippet(abuse_score, top_label, escalation_score, stage, pattern_scores):
353
  aggression_score = pattern_scores.get("aggression", 0)
354
 
 
668
  if top_label is None:
669
  top_label = "Unknown – 0%"
670
 
671
+ out += generate_risk_snippet(
672
+ composite_abuse,
673
+ top_label,
674
+ hybrid_score if escalation_score is not None else 0,
675
+ most_common_stage,
676
+ pattern_scores_for_snippet
677
+ )
678
  out += f"\n\n{stage_text}"
679
  out += darvo_blurb
680
  out += "\n\n🎭 **Emotional Tones Detected:**\n"