SamanthaStorm commited on
Commit
ec9c4b2
Β·
verified Β·
1 Parent(s): 19f891a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -1
app.py CHANGED
@@ -241,7 +241,49 @@ def analyze_input(text, role):
241
  if not results:
242
  return "No clear abuse pattern detected. Continue listening for contradictions, self-blame, or fear-based justifications."
243
  return "\n\n".join(results)
 
 
 
 
 
244
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  # Gradio UI
246
  gr.Interface(
247
  fn=analyze_input,
@@ -252,4 +294,5 @@ gr.Interface(
252
  outputs="text",
253
  title="DV Pattern Recognition Tool (Prototype)",
254
  description="Enter a client or witness quote. The tool flags DV-related behavioral cues and suggests follow-up questions based on your role."
255
- ).launch()
 
 
241
  if not results:
242
  return "No clear abuse pattern detected. Continue listening for contradictions, self-blame, or fear-based justifications."
243
  return "\n\n".join(results)
244
+ # β€”β€”β€” Gradio Danger Assessment Wizard β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
245
+ def danger_assessment_wizard():
246
+ with gr.Blocks() as demo:
247
+ gr.Markdown("## πŸ” Danger Assessment Interview")
248
+ gr.Markdown("Answer each question honestly. Follow-up questions will appear if you answer 'Yes'.")
249
 
250
+ yes_responses = []
251
+ followup_textboxes = []
252
+
253
+ for dq in danger_questions:
254
+ gr.Markdown(f"**{dq['question']}**")
255
+ answer = gr.Radio(["Yes", "No"], label="Your Answer", value=None)
256
+ yes_responses.append(answer)
257
+
258
+ fups = []
259
+ for fup in dq["follow_ups"]:
260
+ box = gr.Textbox(label=f"Follow-up: {fup}", visible=False)
261
+ fups.append(box)
262
+ followup_textboxes.append(box)
263
+
264
+ def toggle_visibility(ans, *args):
265
+ return [gr.update(visible=(ans == "Yes")) for _ in args]
266
+
267
+ answer.change(
268
+ toggle_visibility,
269
+ inputs=[answer] + fups,
270
+ outputs=fups
271
+ )
272
+
273
+ submit = gr.Button("Submit Responses")
274
+ output = gr.Textbox(label="Summary / Next Step", lines=5)
275
+
276
+ def summarize(*args):
277
+ yes_count = sum([1 for a in args[:len(yes_responses)] if a == "Yes"])
278
+ return f"βœ… You answered 'Yes' to {yes_count} danger indicators. Follow-up responses captured for risk review."
279
+
280
+ submit.click(fn=summarize, inputs=yes_responses + followup_textboxes, outputs=output)
281
+
282
+ return demo
283
+
284
+ # β€”β€”β€” Launch the Danger Wizard β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
285
+ if __name__ == "__main__":
286
+ danger_assessment_wizard().launch()
287
  # Gradio UI
288
  gr.Interface(
289
  fn=analyze_input,
 
294
  outputs="text",
295
  title="DV Pattern Recognition Tool (Prototype)",
296
  description="Enter a client or witness quote. The tool flags DV-related behavioral cues and suggests follow-up questions based on your role."
297
+ if __name__ == "__main__":
298
+ danger_assessment_wizard().launch()