Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Jan 18, 2024
2 parents 629548d + 631021e commit 4bc2b94
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 132 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ Extract of the data stored during the call:
- [ ] Call back the user when needed
- [ ] Simulate a IVR workflow

### User report after the call

A report is available at `https://[your_domain]/call/report/[call_id]`. It shows the conversation history, claim data and reminders.

![User report](./docs/user_report.jpg)

### High level architecture

```mermaid
Expand Down
2 changes: 1 addition & 1 deletion bicep/main.bicep
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
param config string
param imageVersion string = 'feat-bicep-deploy'
param imageVersion string = 'main'
param instance string = deployment().name
param location string = 'westeurope'
param openaiLocation string = 'swedencentral'
Expand Down
Binary file added docs/user_report.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions helpers/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class LLM(str, Enum):
Assistant:
- Answers in {CONFIG.workflow.conversation_lang}, even if the customer speaks in English
- Ask the customer to repeat or rephrase their question if it is not clear
- Be proactive in the reminders you create, customer assistance is your priority
- Cannot talk about any topic other than insurance claims
- Do not ask the customer more than 2 questions in a row
- Explain the tools (called actions for the customer) you used
Expand All @@ -25,6 +26,7 @@ class LLM(str, Enum):
- Keep the sentences short and simple
- Refer customers to emergency services or the police if necessary, but cannot give advice under any circumstances
- Rephrase the customer's questions as statements and answer them
- When the customer says a word and then spells out letters, this means that the word is written in the way the customer spelled it, example 'I live in Paris, P-A-R-I-S', 'My name is John, J-O-H-N'
Assistant requires data from the customer to fill the claim. Latest claim data will be given. Assistant role is not over until all the relevant data is gathered.
Expand Down
295 changes: 165 additions & 130 deletions main.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion models/claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ class ClaimModel(BaseModel):
medical_records: Optional[str] = None
police_report_number: Optional[str] = None
policy_number: Optional[str] = None
policyholder_contact_info: Optional[str] = None
policyholder_email: Optional[str] = None
policyholder_name: Optional[str] = None
policyholder_phone: Optional[str] = None
pre_existing_damage_description: Optional[str] = None
property_damage_description: Optional[str] = None
repair_replacement_estimates: Optional[str] = None
Expand Down
2 changes: 2 additions & 0 deletions models/reminder.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field


class ReminderModel(BaseModel):
created_at: datetime = Field(default_factory=datetime.utcnow, frozen=True)
description: str
due_date_time: str
owner: Optional[str] = None # Optional for backwards compatibility
title: str
121 changes: 121 additions & 0 deletions public_website/report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.tailwindcss.com"></script>
<title>Claim report {{ call.claim.id }}</title>
</head>
<body class="container mx-auto px-4 bg-white text-sm">
<div class="grid grid-cols-6 gap-4 m-4">
<!-- Top introduction -->
<div class="col-span-full px-4 py-8">
<h2 class="text-2xl">Hello {{ call.claim.policyholder_name }} 👋🏻</h2>
<p>Your claim <span class="font-mono">#{{ call.claim.id }}</span> of the {{ call.claim.created_at.strftime('%d %b %Y') }} is being processed.</p>
</div>

<!-- Claim details -->
<div class="col-span-full">
<div class="rounded-md ring-1 ring-gray-200">
<h2 class="text-lg px-4 pt-4">🔎 Claim details</h2>

<table class="table-auto w-full">
<tbody>
<tr class="border-b border-slate-100">
<td class="p-4 text-gray-500">We understood</td>
<td class="p-4">{{ call.claim.incident_description }}</td>
</tr>
<tr class="border-b border-slate-100">
<td class="p-4 text-gray-500">Incident date</td>
<!-- TODO: Try to parse the date and display it in a human readable format -->
<td class="p-4">{{ call.claim.incident_date_time }}</td>
</tr>
<tr class="border-b border-slate-100">
<td class="p-4 text-gray-500">Extra details</td>
<td class="p-4">{{ call.claim.extra_details }}</td>
</tr>
<tr class="border-b border-slate-100">
<td class="p-4 text-gray-500">Policy number</td>
<td class="p-4">{{ call.claim.policy_number }}</td>
</tr>
<tr class="border-b border-slate-100">
<td class="p-4 text-gray-500">Contact info</td>
<td class="p-4">{{ call.claim.policyholder_email }}, {{ call.claim.policyholder_phone }}</td>
</tr>
</tbody>
</table>
</div>
</div>

<!-- Conversation -->
<div class="col-start-1 col-end-5">
<div class="p-4 space-y-4 rounded-md ring-1 ring-gray-200">
<h2 class="text-lg">💬 Conversation</h2>

<!-- Agent and customer -->
<div class="overflow-hidden space-y-6">
{% for message in call.messages | reverse %}
{% set name = bot_name if message.persona == 'assistant' else call.claim.policyholder_name %}
<div class="flex flex-row">
<div class="basis-6 relative self-stretch">
<div class="absolute top-0 left-0 w-full h-full -z-10">
<div class="h-screen mx-auto w-0.5 bg-gray-100"></div>
</div>
<div class="py-1.5 bg-white">
{% if message.persona == 'assistant' %}
<div
class="rounded-full h-2 w-2 mx-auto bg-gray-100 ring-1 ring-gray-300"
></div>
{% else %}
<div
class="rounded-full h-2 w-2 mx-auto bg-blue-200 ring-1 ring-blue-400"
></div>
{% endif %}
</div>
</div>
<div class="basis-full space-y-2 px-4 py-0.5">
<div class="flex flex-row justify-between content-center text-xs">
<div>
{{ name }}&nbsp;<span class="text-gray-500">commented</span>
</div>
<div class="text-gray-500">
{{ message.created_at.strftime('%d %b %Y') }}
</div>
</div>
<p class="text-gray-500">{{ message.content }}</p>
</div>
</div>
{% else %}
<p class="text-gray-500">No messages yet.</p>
{% endfor %}
</div>

<!-- TODO: Add a action for a new phone call -->
</div>
</div>

<!-- Reminders -->
<div class="col-start-5 col-end-7">
<div class="rounded-md ring-1 ring-gray-200 p-4">
<h2 class="text-lg pb-4">⏰ Reminders</h2>

{% if not call.reminders %}
<p class="p-4 text-gray-500">No reminders yet.</p>
{% else %}
<div class="space-y-6">
<!-- TODO: Sort reminders by due date -->
{% for reminder in call.reminders %}
<div>
<div class="text-xs">
{{ reminder.owner }}&nbsp;<span class="text-gray-500">({{ reminder.due_date_time }})</span>
</div>
<p class="text-gray-500">{{ reminder.title }}</p>
</div>
{% endfor %}
</div>
{% endif %}
</div>
</div>
</div>
</body>
</html>
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ azure-communication-sms==1.0.1
azure-eventgrid==4.16.0
azure-identity==1.15.0
fastapi==0.108.0
jinja2==3.1.3
openai==1.7.1
phonenumbers==8.13.27
pydantic-extra-types==2.4.0
Expand Down

0 comments on commit 4bc2b94

Please sign in to comment.