SamanthaStorm commited on
Commit
4c68e72
·
verified ·
1 Parent(s): 5dfb1ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -88,13 +88,16 @@ def analyze_messages(input_text):
88
  # Prepare the result summary and detailed scores
89
  result = (
90
  f"Abuse Patterns Detected: {pattern_count} out of {len(PATTERN_LABELS)}\n"
91
- f"Danger Flags Detected: {danger_flag_count} out of {len(DANGER_LABELS)}\n"
92
  f"Abuse Level: {abuse_level}% - {abuse_description}\n"
93
  f"Resources: {resources}"
 
 
 
 
94
  )
95
 
96
  # Return both a text summary and a JSON-like dict of scores per label
97
- return result, {"scores": dict(zip(LABELS, scores))}
98
 
99
  # Updated Gradio Interface using new component syntax
100
  iface = gr.Interface(
@@ -102,7 +105,6 @@ iface = gr.Interface(
102
  inputs=gr.Textbox(lines=10, placeholder="Enter message here..."),
103
  outputs=[
104
  gr.Textbox(label="Analysis Result"),
105
- gr.JSON(label="Scores")
106
  ],
107
  title="Abuse Pattern Detector"
108
  )
 
88
  # Prepare the result summary and detailed scores
89
  result = (
90
  f"Abuse Patterns Detected: {pattern_count} out of {len(PATTERN_LABELS)}\n"
 
91
  f"Abuse Level: {abuse_level}% - {abuse_description}\n"
92
  f"Resources: {resources}"
93
+ "The Danger Assessment is a validated tool used to help identify the level of risk for serious injury or homicide in cases of intimate partner violence.. "
94
+ "It looks for specific abusive patterns that increase the likelihood of severe harm. "
95
+ f"The messages just analyzed contain at least {triggered_flags_count} critical flags."
96
+ )
97
  )
98
 
99
  # Return both a text summary and a JSON-like dict of scores per label
100
+ return result, {"scores": dict(zip(LABELS, scores.tolist))}
101
 
102
  # Updated Gradio Interface using new component syntax
103
  iface = gr.Interface(
 
105
  inputs=gr.Textbox(lines=10, placeholder="Enter message here..."),
106
  outputs=[
107
  gr.Textbox(label="Analysis Result"),
 
108
  ],
109
  title="Abuse Pattern Detector"
110
  )