Spaces:
Sleeping
Sleeping
Update app.py
Browse files66 unmodified lines676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121472 unmodified lines59459559659759859960060160291 unmodified lines69469569669769869970070170270366 unmodified lines# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββPROMPT_TEMPLATES = {"simple": ("You are a call-center conversation analyst for a medical clinic. From the call recording, provide a brief summary:""- Purpose of the call (appointment / results / complaint / billing / other).""- Patient intent and expectations.""- Outcome (booked / call-back / routed / unresolved).""- Next steps (owner and when).""- Patient emotion (1β5) and agent tone (1β5).""- Alerts: urgency/risks/privacy.""Keep it short (6β8 lines). End with a line: βService quality rating: X/5β and one sentence explaining the rating."),"medium": ("Act as a senior service analyst. Analyze the call using this structure:""1) Quick overview: reason for the call, intent, key facts, urgency (low/medium/high).""2) Call flow (2β4 bullets): what was asked/answered, where friction occurred.""3) Outcomes & tasks: concrete next actions for clinic/patient with timeframes.""4) Emotions & empathy: patient mood; agent empathy (0β5).""5) Procedural compliance: identity verification, disclosure of recording (if stated), no off-protocol medical advice, data accuracy.""6) Quality rating (0β100) using rubric: greeting, verification, accuracy, empathy, issue resolution (each 0β20)."),"detailed": ("You are a quality & operations analyst. Provide an in-depth analysis:""A) Segmentation: split the call into stages with approximate timestamps (if available) and roles (Patient/Agent).""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.""C) Triage & risks: class (routine/urgent/emergency), red flags, whether immediate escalation is needed.""D) Compliance audit: identity/privacy checks, recording disclosure, consent to data processing, booking policies.""E) Conversation metrics: talk ratio (agent/patient), interruptions, long pauses, notable keywords.""F) Coaching for the agent: 3β5 concrete improvements with sample phrasing.""Deliver: (1) A short patient-chart summary (2β3 sentences). (2) A task table with columns: priority, owner, due."),}472 unmodified lines# Upload + generatetry:uploaded_file = client.files.upload(file=mp3_path)merged = f"[SYSTEM INSTRUCTION: {sys_inst}]{prompt}"resp = client.models.generate_content(model=model_name,contents=[uploaded_file, merged],91 unmodified lineswith gr.Blocks(title="Vochi CRM Call Logs (Gradio)") as demo:gr.Markdown("""# Vochi CRM β MP3 β AI analysis*Fetch daily calls, play/download MP3, and analyze the call with an AI model.*""")# Auth state (False by default)66 unmodified lines676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107472 unmodified lines58058158258358458558658758891 unmodified lines68068168268368468568668768866 unmodified lines# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββPROMPT_TEMPLATES = {"simple": ("""You are a call-center conversation analyst for a medical clinic. From the call recording, provide a brief summary:- Purpose of the call (appointment / results / complaint / billing / other).- Patient intent and expectations.- Outcome (booked / call-back / routed / unresolved).- Next steps (owner and when).- Patient emotion (1β5) and agent tone (1β5).- Alerts: urgency/risks/privacy.Keep it short (6β8 lines). End with a line: βService quality rating: X/5β and one sentence explaining the rating."""),"medium": ("""Act as a senior service analyst. Analyze the call using this structure:1) Quick overview: reason for the call, intent, key facts, urgency (low/medium/high).2) Call flow (2β4 bullets): what was asked/answered, where friction occurred.3) Outcomes & tasks: concrete next actions for clinic/patient with timeframes.4) Emotions & empathy: patient mood; agent empathy (0β5).5) Procedural compliance: identity verification, disclosure of recording (if stated), no off-protocol medical advice, data accuracy.6) Quality rating (0β100) using rubric: greeting, verification, accuracy, empathy, issue resolution (each 0β20)."""),"detailed": ("""You are a quality & operations analyst. Provide an in-depth analysis:A) Segmentation: split the call into stages with approximate timestamps (if available) and roles (Patient/Agent).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.C) Triage & risks: class (routine/urgent/emergency), red flags, whether immediate escalation is needed.D) Compliance audit: identity/privacy checks, recording disclosure, consent to data processing, booking policies.E) Conversation metrics: talk ratio (agent/patient), interruptions, long pauses, notable keywords.F) Coaching for the agent: 3β5 concrete improvements with sample phrasing.Deliver: (1) A short patient-chart summary (2β3 sentences). (2) A task table with columns: priority, owner, due."""),}472 unmodified lines# Upload + generatetry:uploaded_file = client.files.upload(file=mp3_path)merged = f"""[SYSTEM INSTRUCTION: {sys_inst}]{prompt}"""resp = client.models.generate_content(model=model_name,contents=[uploaded_file, merged],91 unmodified lineswith gr.Blocks(title="Vochi CRM Call Logs (Gradio)") as demo:gr.Markdown("""# Vochi CRM β MP3 β AI analysis*Fetch daily calls, play/download MP3, and analyze the call with an AI model.*""")# Auth state (False by default)
app.py+36-51