archivartaunik commited on
Commit
e565d1e
Β·
verified Β·
1 Parent(s): e828937

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -51
app.py CHANGED
@@ -67,55 +67,41 @@ def fetch_mp3_by_unique_id(unique_id: str) -> Tuple[str, str]:
67
  # ─────────────────────────────────────────────────────────────────────────────
68
  PROMPT_TEMPLATES = {
69
  "simple": (
70
- "You are a call-center conversation analyst for a medical clinic. From the call recording, provide a brief summary:
71
- "
72
- "- Purpose of the call (appointment / results / complaint / billing / other).
73
- "
74
- "- Patient intent and expectations.
75
- "
76
- "- Outcome (booked / call-back / routed / unresolved).
77
- "
78
- "- Next steps (owner and when).
79
- "
80
- "- Patient emotion (1–5) and agent tone (1–5).
81
- "
82
- "- Alerts: urgency/risks/privacy.
83
-
84
- "
85
- "Keep it short (6–8 lines). End with a line: β€˜Service quality rating: X/5’ and one sentence explaining the rating."
86
  ),
87
  "medium": (
88
- "Act as a senior service analyst. Analyze the call using this structure:
89
- "
90
- "1) Quick overview: reason for the call, intent, key facts, urgency (low/medium/high).
91
- "
92
- "2) Call flow (2–4 bullets): what was asked/answered, where friction occurred.
93
- "
94
- "3) Outcomes & tasks: concrete next actions for clinic/patient with timeframes.
95
- "
96
- "4) Emotions & empathy: patient mood; agent empathy (0–5).
97
- "
98
- "5) Procedural compliance: identity verification, disclosure of recording (if stated), no off-protocol medical advice, data accuracy.
99
- "
100
- "6) Quality rating (0–100) using rubric: greeting, verification, accuracy, empathy, issue resolution (each 0–20)."
101
  ),
102
  "detailed": (
103
- "You are a quality & operations analyst. Provide an in-depth analysis:
104
- "
105
- "A) Segmentation: split the call into stages with approximate timestamps (if available) and roles (Patient/Agent).
106
- "
107
- "B) Structured data for booking: full name (if stated), date of birth, phone, symptoms/complaints (list), onset/duration, possible pain level 0–10 (if mentioned), required specialist/service, preferred time windows, constraints.
108
- "
109
- "C) Triage & risks: class (routine/urgent/emergency), red flags, whether immediate escalation is needed.
110
- "
111
- "D) Compliance audit: identity/privacy checks, recording disclosure, consent to data processing, booking policies.
112
- "
113
- "E) Conversation metrics: talk ratio (agent/patient), interruptions, long pauses, notable keywords.
114
- "
115
- "F) Coaching for the agent: 3–5 concrete improvements with sample phrasing.
116
-
117
- "
118
- "Deliver: (1) A short patient-chart summary (2–3 sentences). (2) A task table with columns: priority, owner, due."
119
  ),
120
  }
121
 
@@ -594,9 +580,9 @@ def ui_analyze_calls_by_date(
594
  # Upload + generate
595
  try:
596
  uploaded_file = client.files.upload(file=mp3_path)
597
- merged = f"[SYSTEM INSTRUCTION: {sys_inst}]
598
 
599
- {prompt}"
600
  resp = client.models.generate_content(
601
  model=model_name,
602
  contents=[uploaded_file, merged],
@@ -694,10 +680,9 @@ def ui_fetch_or_auth(date_str: str, authed: bool):
694
  with gr.Blocks(title="Vochi CRM Call Logs (Gradio)") as demo:
695
  gr.Markdown(
696
  """
697
- # Vochi CRM β†’ MP3 β†’ AI analysis
698
- *Fetch daily calls, play/download MP3, and analyze the call with an AI model.*
699
-
700
- """
701
  )
702
 
703
  # Auth state (False by default)
 
67
  # ─────────────────────────────────────────────────────────────────────────────
68
  PROMPT_TEMPLATES = {
69
  "simple": (
70
+ """
71
+ You are a call-center conversation analyst for a medical clinic. From the call recording, provide a brief summary:
72
+ - Purpose of the call (appointment / results / complaint / billing / other).
73
+ - Patient intent and expectations.
74
+ - Outcome (booked / call-back / routed / unresolved).
75
+ - Next steps (owner and when).
76
+ - Patient emotion (1–5) and agent tone (1–5).
77
+ - Alerts: urgency/risks/privacy.
78
+
79
+ Keep it short (6–8 lines). End with a line: β€˜Service quality rating: X/5’ and one sentence explaining the rating.
80
+ """
 
 
 
 
 
81
  ),
82
  "medium": (
83
+ """
84
+ Act as a senior service analyst. Analyze the call using this structure:
85
+ 1) Quick overview: reason for the call, intent, key facts, urgency (low/medium/high).
86
+ 2) Call flow (2–4 bullets): what was asked/answered, where friction occurred.
87
+ 3) Outcomes & tasks: concrete next actions for clinic/patient with timeframes.
88
+ 4) Emotions & empathy: patient mood; agent empathy (0–5).
89
+ 5) Procedural compliance: identity verification, disclosure of recording (if stated), no off-protocol medical advice, data accuracy.
90
+ 6) Quality rating (0–100) using rubric: greeting, verification, accuracy, empathy, issue resolution (each 0–20).
91
+ """
 
 
 
 
92
  ),
93
  "detailed": (
94
+ """
95
+ You are a quality & operations analyst. Provide an in-depth analysis:
96
+ A) Segmentation: split the call into stages with approximate timestamps (if available) and roles (Patient/Agent).
97
+ B) Structured data for booking: full name (if stated), date of birth, phone, symptoms/complaints (list), onset/duration, possible pain level 0–10 (if mentioned), required specialist/service, preferred time windows, constraints.
98
+ C) Triage & risks: class (routine/urgent/emergency), red flags, whether immediate escalation is needed.
99
+ D) Compliance audit: identity/privacy checks, recording disclosure, consent to data processing, booking policies.
100
+ E) Conversation metrics: talk ratio (agent/patient), interruptions, long pauses, notable keywords.
101
+ F) Coaching for the agent: 3–5 concrete improvements with sample phrasing.
102
+
103
+ Deliver: (1) A short patient-chart summary (2–3 sentences). (2) A task table with columns: priority, owner, due.
104
+ """
 
 
 
 
 
105
  ),
106
  }
107
 
 
580
  # Upload + generate
581
  try:
582
  uploaded_file = client.files.upload(file=mp3_path)
583
+ merged = f"""[SYSTEM INSTRUCTION: {sys_inst}]
584
 
585
+ {prompt}"""
586
  resp = client.models.generate_content(
587
  model=model_name,
588
  contents=[uploaded_file, merged],
 
680
  with gr.Blocks(title="Vochi CRM Call Logs (Gradio)") as demo:
681
  gr.Markdown(
682
  """
683
+ # Vochi CRM β†’ MP3 β†’ AI analysis
684
+ *Fetch daily calls, play/download MP3, and analyze the call with an AI model.*
685
+ """
 
686
  )
687
 
688
  # Auth state (False by default)