SamanthaStorm commited on
Commit
c3eb637
·
verified ·
1 Parent(s): 3f3d30c

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +12 -51
utils.py CHANGED
@@ -572,57 +572,6 @@ def generate_timeline_chart(df, column='abuse_score'):
572
  layer="below"
573
  )
574
 
575
- fig.add_shape
576
- def generate_timeline_chart(df, column='abuse_score'):
577
- """Generate a timeline chart of abuse scores"""
578
- try:
579
- # Create figure
580
- fig = go.Figure()
581
-
582
- # Add line plot
583
- fig.add_trace(go.Scatter(
584
- x=df['timestamp'],
585
- y=df[column],
586
- mode='lines+markers',
587
- name=column.replace('_', ' ').title(),
588
- line=dict(width=2),
589
- marker=dict(size=8)
590
- ))
591
-
592
- # Add risk level bands
593
- fig.add_shape(
594
- type="rect",
595
- x0=df['timestamp'].min(),
596
- x1=df['timestamp'].max(),
597
- y0=0,
598
- y1=50,
599
- fillcolor="rgba(144, 238, 144, 0.2)",
600
- line_width=0,
601
- layer="below"
602
- )
603
-
604
- fig.add_shape(
605
- type="rect",
606
- x0=df['timestamp'].min(),
607
- x1=df['timestamp'].max(),
608
- y0=50,
609
- y1=70,
610
- fillcolor="rgba(255, 215, 0, 0.2)",
611
- line_width=0,
612
- layer="below"
613
- )
614
-
615
- fig.add_shape(
616
- type="rect",
617
- x0=df['timestamp'].min(),
618
- x1=df['timestamp'].max(),
619
- y0=70,
620
- y1=85,
621
- fillcolor="rgba(255, 165, 0, 0.2)",
622
- line_width=0,
623
- layer="below"
624
- )
625
-
626
  fig.add_shape(
627
  type="rect",
628
  x0=df['timestamp'].min(),
@@ -881,6 +830,18 @@ def detect_escalation_patterns(df):
881
  "cycle_period": None
882
  }
883
 
 
 
 
 
 
 
 
 
 
 
 
 
884
  def generate_safety_plan(risk_level, patterns, escalation_data):
885
  """Generate a personalized safety plan based on analysis"""
886
  plan = "🛡️ **SAFETY PLANNING RECOMMENDATIONS**\n\n"
 
572
  layer="below"
573
  )
574
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
575
  fig.add_shape(
576
  type="rect",
577
  x0=df['timestamp'].min(),
 
830
  "cycle_period": None
831
  }
832
 
833
+ def generate_safety_plan(risk_level, patterns, escalation_data):
834
+ """Generate a personalized safety plan based on analysis"""
835
+ plan = "🛡️ **SAFETY PLANNING RECOMMENDATIONS**\n\n"
836
+
837
+ # Critical risk
838
+ if risk_level == "Critical":
839
+ plan += "🚨 **CRITICAL SAFETY SITUATION**\n\n"
840
+ plan += "**IMMEDIATE ACTIONS:**\n"
841
+ plan += "• Contact domestic violence hotline: **1-800-799-7233** (24/7, free, confidential)\n"
842
+ plan += "• Text START to **88788** for crisis text support\n"
843
+ plan += "• Consider staying with trusted friends/family tonight\n"
844
+
845
  def generate_safety_plan(risk_level, patterns, escalation_data):
846
  """Generate a personalized safety plan based on analysis"""
847
  plan = "🛡️ **SAFETY PLANNING RECOMMENDATIONS**\n\n"