SamanthaStorm commited on
Commit
21421a3
Β·
verified Β·
1 Parent(s): e4d31a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -249,10 +249,14 @@ def analyze_composite(msg1, msg2, msg3, *answers_and_none):
249
  top_scores = [r[2][0][1] for r in results]
250
  sentiments = [r[3]['label'] for r in results]
251
  stages = [r[4] for r in results]
 
252
 
253
  most_common_stage = max(set(stages), key=stages.count)
254
  stage_text = RISK_STAGE_LABELS[most_common_stage]
255
-
 
 
 
256
  top_label = f"{top_labels[0]} – {int(round(top_scores[0] * 100))}%"
257
  composite_abuse = int(round(sum(abuse_scores) / len(abuse_scores)))
258
 
@@ -262,7 +266,13 @@ def analyze_composite(msg1, msg2, msg3, *answers_and_none):
262
  out += "🚨 This indicates how many serious risk factors are present based on your answers to the safety checklist.\n\n"
263
  out += generate_risk_snippet(composite_abuse, top_label, escalation_score)
264
  out += f"\n\n{stage_text}"
265
- return out
 
 
 
 
 
 
266
 
267
  textbox_inputs = [gr.Textbox(label=f"Message {i+1}") for i in range(3)]
268
  quiz_boxes = [gr.Checkbox(label=q) for q, _ in ESCALATION_QUESTIONS]
 
249
  top_scores = [r[2][0][1] for r in results]
250
  sentiments = [r[3]['label'] for r in results]
251
  stages = [r[4] for r in results]
252
+ darvo_scores = [r[5] for r in results]
253
 
254
  most_common_stage = max(set(stages), key=stages.count)
255
  stage_text = RISK_STAGE_LABELS[most_common_stage]
256
+ avg_darvo = round(sum(darvo_scores) / len(darvo_scores), 3)
257
+ if avg_darvo > 0.25:
258
+ level = "moderate" if avg_darvo < 0.65 else "high"
259
+ out += f"\n\n🎭 **DARVO Score: {avg_darvo}** β†’ This indicates a **{level} likelihood** of narrative reversal (DARVO), where the speaker may be denying, attacking, or reversing blame."
260
  top_label = f"{top_labels[0]} – {int(round(top_scores[0] * 100))}%"
261
  composite_abuse = int(round(sum(abuse_scores) / len(abuse_scores)))
262
 
 
266
  out += "🚨 This indicates how many serious risk factors are present based on your answers to the safety checklist.\n\n"
267
  out += generate_risk_snippet(composite_abuse, top_label, escalation_score)
268
  out += f"\n\n{stage_text}"
269
+
270
+ avg_darvo = round(sum(darvo_scores) / len(darvo_scores), 3)
271
+ if avg_darvo > 0.25:
272
+ level = "moderate" if avg_darvo < 0.65 else "high"
273
+ out += f"\n\n🎭 **DARVO Score: {avg_darvo}** β†’ This indicates a **{level} likelihood** of narrative reversal (DARVO), where the speaker may be denying, attacking, or reversing blame."
274
+
275
+ return out
276
 
277
  textbox_inputs = [gr.Textbox(label=f"Message {i+1}") for i in range(3)]
278
  quiz_boxes = [gr.Checkbox(label=q) for q, _ in ESCALATION_QUESTIONS]