Update app.py
Browse files
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 |
-
"
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 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 |
-
"
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 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 |
-
"
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 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 |
-
|
| 698 |
-
|
| 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)
|