Commit ·
d514191
1
Parent(s): a6fa796
updated mail + pipeline
Browse files- core/backend.py +15 -0
- db_view/db.html +12 -2
- services/tts.py +8 -6
core/backend.py
CHANGED
|
@@ -1121,6 +1121,13 @@ APPOINTMENT FLOW:
|
|
| 1121 |
3. Ask only for missing details.
|
| 1122 |
4. Confirm important details before booking or deleting.
|
| 1123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1124 |
TOOL RULES:
|
| 1125 |
- Use `find_doctors` first for doctor search, specialty search, and availability search.
|
| 1126 |
- Use `get_doctors_by_day` or `get_categories_by_day` when the user asks about a day directly.
|
|
@@ -1173,10 +1180,18 @@ Important booking rules:
|
|
| 1173 |
- If the user already gave name, age, phone, doctor name, visit day/date, visit time, and email, do not ask again.
|
| 1174 |
- If the user has already confirmed the details, book immediately.
|
| 1175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1176 |
Important cancellation rules:
|
| 1177 |
- If the user gave only a phone number and there is exactly one matching appointment, cancel it directly.
|
| 1178 |
- If multiple appointments match, ask only for the doctor name.
|
| 1179 |
- Email is REQUIRED to cancel or update. If missing, ask for email.
|
|
|
|
| 1180 |
|
| 1181 |
Do not give a normal conversational answer before the tool call.
|
| 1182 |
"""
|
|
|
|
| 1121 |
3. Ask only for missing details.
|
| 1122 |
4. Confirm important details before booking or deleting.
|
| 1123 |
|
| 1124 |
+
UPDATE / CANCEL FLOW (important):
|
| 1125 |
+
1. If the user wants to update/cancel, first ask: “কোন তথ্যটা বদলাতে চান?” (date / doctor / time / phone / email).
|
| 1126 |
+
2. Then ask: “আগের অ্যাপয়েন্টমেন্টের বাকি তথ্যগুলো আগের মতোই রাখবো?” (yes/no).
|
| 1127 |
+
3. If yes: reuse existing appointment data from DB; ask only for the new values.
|
| 1128 |
+
4. If no: collect the full updated set of details, then proceed.
|
| 1129 |
+
5. Only after confirmation, call `update_appointment` or `delete_appointment`.
|
| 1130 |
+
|
| 1131 |
TOOL RULES:
|
| 1132 |
- Use `find_doctors` first for doctor search, specialty search, and availability search.
|
| 1133 |
- Use `get_doctors_by_day` or `get_categories_by_day` when the user asks about a day directly.
|
|
|
|
| 1180 |
- If the user already gave name, age, phone, doctor name, visit day/date, visit time, and email, do not ask again.
|
| 1181 |
- If the user has already confirmed the details, book immediately.
|
| 1182 |
|
| 1183 |
+
Important update rules:
|
| 1184 |
+
- First ask what the user wants to change (date/doctor/time/phone/email).
|
| 1185 |
+
- Ask whether to keep the rest of the existing appointment unchanged.
|
| 1186 |
+
- If multiple appointments exist for a phone number, ask for the doctor name to select the correct one.
|
| 1187 |
+
- Email is REQUIRED to update. If the existing record has no email, ask for it.
|
| 1188 |
+
- Only call `update_appointment` after the user confirms the change(s).
|
| 1189 |
+
|
| 1190 |
Important cancellation rules:
|
| 1191 |
- If the user gave only a phone number and there is exactly one matching appointment, cancel it directly.
|
| 1192 |
- If multiple appointments match, ask only for the doctor name.
|
| 1193 |
- Email is REQUIRED to cancel or update. If missing, ask for email.
|
| 1194 |
+
- Only call `delete_appointment` after the user confirms cancellation.
|
| 1195 |
|
| 1196 |
Do not give a normal conversational answer before the tool call.
|
| 1197 |
"""
|
db_view/db.html
CHANGED
|
@@ -76,12 +76,12 @@
|
|
| 76 |
<h1>Doctor & Patient Management System</h1>
|
| 77 |
|
| 78 |
<div class="tabs">
|
| 79 |
-
<button class="tab-button
|
| 80 |
<button class="tab-button" onclick="showTab(1)">Patients</button>
|
| 81 |
</div>
|
| 82 |
|
| 83 |
<!-- Doctors Tab -->
|
| 84 |
-
<div id="doctors-tab" class="table-container">
|
| 85 |
<h2>Doctors List</h2>
|
| 86 |
<div id="doctors-loading" class="loading">Loading doctors...</div>
|
| 87 |
<table id="doctors-table" style="display:none;">
|
|
@@ -136,6 +136,9 @@
|
|
| 136 |
|
| 137 |
doctorsTab.style.display = tabIndex === 0 ? 'block' : 'none';
|
| 138 |
patientsTab.style.display = tabIndex === 1 ? 'block' : 'none';
|
|
|
|
|
|
|
|
|
|
| 139 |
}
|
| 140 |
|
| 141 |
async function fetchDoctors() {
|
|
@@ -204,6 +207,13 @@
|
|
| 204 |
window.onload = () => {
|
| 205 |
fetchDoctors();
|
| 206 |
fetchPatients(); // Preload both for better UX
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
};
|
| 208 |
</script>
|
| 209 |
</body>
|
|
|
|
| 76 |
<h1>Doctor & Patient Management System</h1>
|
| 77 |
|
| 78 |
<div class="tabs">
|
| 79 |
+
<button class="tab-button" onclick="showTab(0)">Doctors</button>
|
| 80 |
<button class="tab-button" onclick="showTab(1)">Patients</button>
|
| 81 |
</div>
|
| 82 |
|
| 83 |
<!-- Doctors Tab -->
|
| 84 |
+
<div id="doctors-tab" class="table-container" style="display:none;">
|
| 85 |
<h2>Doctors List</h2>
|
| 86 |
<div id="doctors-loading" class="loading">Loading doctors...</div>
|
| 87 |
<table id="doctors-table" style="display:none;">
|
|
|
|
| 136 |
|
| 137 |
doctorsTab.style.display = tabIndex === 0 ? 'block' : 'none';
|
| 138 |
patientsTab.style.display = tabIndex === 1 ? 'block' : 'none';
|
| 139 |
+
|
| 140 |
+
// Remember last selected tab (0=Doctors, 1=Patients)
|
| 141 |
+
try { localStorage.setItem('db_view_tab', String(tabIndex)); } catch {}
|
| 142 |
}
|
| 143 |
|
| 144 |
async function fetchDoctors() {
|
|
|
|
| 207 |
window.onload = () => {
|
| 208 |
fetchDoctors();
|
| 209 |
fetchPatients(); // Preload both for better UX
|
| 210 |
+
// Default to Patients tab on load, but allow user preference
|
| 211 |
+
let tab = 1;
|
| 212 |
+
try {
|
| 213 |
+
const saved = Number(localStorage.getItem('db_view_tab'));
|
| 214 |
+
if (saved === 0 || saved === 1) tab = saved;
|
| 215 |
+
} catch {}
|
| 216 |
+
showTab(tab);
|
| 217 |
};
|
| 218 |
</script>
|
| 219 |
</body>
|
services/tts.py
CHANGED
|
@@ -40,13 +40,15 @@ def _parse_pct(text: str) -> float:
|
|
| 40 |
return 0.0
|
| 41 |
|
| 42 |
# ElevenLabs speed configuration:
|
| 43 |
-
# - `ELEVENLABS_SPEED` is the base speed (
|
| 44 |
-
# - `ELEVENLABS_SPEED_PCT` is an optional relative adjustment like "+10%"
|
| 45 |
-
#
|
| 46 |
-
# -
|
| 47 |
-
|
|
|
|
| 48 |
_ELEVEN_SPEED_PCT = _parse_pct(os.getenv("ELEVENLABS_SPEED_PCT", "0%"))
|
| 49 |
-
|
|
|
|
| 50 |
ELEVENLABS_OUTPUT_FORMAT = "mp3_22050_32"
|
| 51 |
ELEVENLABS_STABILITY = 0.45
|
| 52 |
ELEVENLABS_SIMILARITY = 0.80
|
|
|
|
| 40 |
return 0.0
|
| 41 |
|
| 42 |
# ElevenLabs speed configuration:
|
| 43 |
+
# - `ELEVENLABS_SPEED` is the base speed (1.0 ≈ normal, >1.0 = faster).
|
| 44 |
+
# - `ELEVENLABS_SPEED_PCT` is an optional relative adjustment like "+10%" / "-5%".
|
| 45 |
+
# Effective speed = base * (1 + pct).
|
| 46 |
+
# - `ELEVENLABS_SPEED_MAX` sets the upper clamp (default 3.0). If your ElevenLabs
|
| 47 |
+
# model/voice rejects high values, lower this (e.g. 2.5).
|
| 48 |
+
_ELEVEN_BASE_SPEED = float(os.getenv("ELEVENLABS_SPEED", "2.5"))
|
| 49 |
_ELEVEN_SPEED_PCT = _parse_pct(os.getenv("ELEVENLABS_SPEED_PCT", "0%"))
|
| 50 |
+
_ELEVEN_SPEED_MAX = float(os.getenv("ELEVENLABS_SPEED_MAX", "3.0"))
|
| 51 |
+
ELEVENLABS_SPEED = _clamp(_ELEVEN_BASE_SPEED * (1.0 + _ELEVEN_SPEED_PCT), 0.5, _ELEVEN_SPEED_MAX)
|
| 52 |
ELEVENLABS_OUTPUT_FORMAT = "mp3_22050_32"
|
| 53 |
ELEVENLABS_STABILITY = 0.45
|
| 54 |
ELEVENLABS_SIMILARITY = 0.80
|