Spaces:
Sleeping
Sleeping
Commit
·
a897a27
1
Parent(s):
5e0c36d
Some updates
Browse files- endpoints_documentation.py +265 -97
- main.py +8 -17
endpoints_documentation.py
CHANGED
@@ -1,28 +1,231 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
endpoints_documentation = {
|
2 |
-
"
|
3 |
-
"path": "/",
|
4 |
"method": "GET",
|
5 |
-
"description": "
|
6 |
-
"parameters":
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
},
|
10 |
-
"
|
11 |
"path": "/reservations",
|
12 |
"method": "GET",
|
13 |
-
"description": "Get all reservations",
|
14 |
"parameters": None,
|
15 |
-
"request_body": None,
|
16 |
"response": {
|
17 |
-
"description": "List of all reservations",
|
18 |
-
"model": "List[Reservation]"
|
19 |
-
|
20 |
-
|
21 |
},
|
22 |
-
"
|
23 |
"path": "/reservations/",
|
24 |
"method": "GET",
|
25 |
-
"description": "
|
26 |
"parameters": {
|
27 |
"patient_id": {
|
28 |
"type": "str",
|
@@ -32,162 +235,127 @@ endpoints_documentation = {
|
|
32 |
"doctor_name": {
|
33 |
"type": "str",
|
34 |
"required": False,
|
35 |
-
"description": "Filter by doctor name
|
36 |
}
|
37 |
},
|
38 |
-
"request_body": None,
|
39 |
"response": {
|
40 |
"description": "List of matching scheduled reservations",
|
41 |
-
"model": "List[Reservation]"
|
42 |
-
|
43 |
-
|
44 |
},
|
45 |
"create_reservation": {
|
46 |
"path": "/create-reservation",
|
47 |
"method": "POST",
|
48 |
-
"description": "
|
49 |
-
"parameters": None,
|
50 |
"request_body": {
|
51 |
-
"model": "CreateReservation",
|
52 |
"required_fields": {
|
53 |
"patient_id": "str",
|
54 |
"doctor_name": "str",
|
55 |
-
"date_time": "datetime
|
56 |
},
|
57 |
"optional_fields": {
|
58 |
-
"reason": "str
|
59 |
}
|
60 |
},
|
61 |
"response": {
|
62 |
-
"description": "Created reservation
|
63 |
-
"model": "Reservation"
|
64 |
-
|
65 |
-
|
66 |
},
|
67 |
"reschedule_reservation": {
|
68 |
"path": "/reservations/reschedule",
|
69 |
"method": "PUT",
|
70 |
-
"description": "
|
71 |
"parameters": {
|
72 |
"doctor_name": {
|
73 |
"type": "str",
|
74 |
"required": True,
|
75 |
-
"description": "
|
76 |
},
|
77 |
"new_date_time": {
|
78 |
"type": "str",
|
79 |
"required": True,
|
80 |
-
"description": "New date/time
|
81 |
}
|
82 |
},
|
83 |
"response": {
|
84 |
-
"description": "Updated reservation
|
85 |
-
"model": "Reservation"
|
86 |
-
|
87 |
-
|
88 |
},
|
89 |
"cancel_reservation": {
|
90 |
"path": "/reservations/cancel",
|
91 |
"method": "PUT",
|
92 |
-
"description": "Cancel
|
93 |
"parameters": {
|
94 |
"doctor_name": {
|
95 |
"type": "str",
|
96 |
"required": True,
|
97 |
-
"description": "
|
98 |
}
|
99 |
},
|
100 |
-
"request_body": None,
|
101 |
"response": {
|
102 |
-
"description": "Canceled reservation
|
103 |
-
"model": "Reservation"
|
104 |
-
|
105 |
-
|
106 |
},
|
107 |
"get_doctors": {
|
108 |
"path": "/doctors",
|
109 |
"method": "GET",
|
110 |
-
"description": "Get list of
|
111 |
"parameters": None,
|
112 |
-
"request_body": None,
|
113 |
"response": {
|
114 |
-
"description": "List of doctors
|
115 |
-
"model": "List[
|
116 |
-
|
117 |
-
|
118 |
-
]
|
119 |
-
}
|
120 |
},
|
121 |
"get_doctor_availability": {
|
122 |
"path": "/doctors/{doctor_id}/availability",
|
123 |
"method": "GET",
|
124 |
-
"description": "
|
125 |
"parameters": {
|
126 |
"doctor_id": {
|
127 |
"type": "int",
|
128 |
"required": True,
|
129 |
-
"description": "ID
|
130 |
},
|
131 |
"date": {
|
132 |
-
"type": "str
|
133 |
"required": False,
|
134 |
-
"description": "Date
|
135 |
}
|
136 |
},
|
137 |
-
"request_body": None,
|
138 |
"response": {
|
139 |
-
"description": "Doctor's availability slots
|
140 |
-
"model": "
|
141 |
-
|
142 |
-
|
143 |
-
"date": "2023-10-15",
|
144 |
-
"slots": [
|
145 |
-
{
|
146 |
-
"start": "2023-10-15T09:00:00",
|
147 |
-
"end": "2023-10-15T09:30:00",
|
148 |
-
"available": True
|
149 |
-
}
|
150 |
-
]
|
151 |
-
},
|
152 |
-
"error": "404 if doctor not found"
|
153 |
-
}
|
154 |
},
|
155 |
"get_patients": {
|
156 |
"path": "/patients",
|
157 |
"method": "GET",
|
158 |
-
"description": "Get list of all patients",
|
159 |
"parameters": None,
|
160 |
-
"request_body": None,
|
161 |
"response": {
|
162 |
-
"description": "List of patients
|
163 |
-
"model": "List[Patient]"
|
164 |
-
"example": [
|
165 |
-
{"id": "uuid-123", "name": "John Doe", "phone": "555-0101", "email": "john@example.com"}
|
166 |
-
]
|
167 |
-
}
|
168 |
-
},
|
169 |
-
"get_patient_reservations": {
|
170 |
-
"path": "/patients/reservations",
|
171 |
-
"method": "GET",
|
172 |
-
"description": "Get my all reservations",
|
173 |
-
"parameters": {
|
174 |
-
"patient_id": {
|
175 |
-
"type": "str",
|
176 |
-
"required": True,
|
177 |
-
"description": "ID of the patient"
|
178 |
-
}
|
179 |
},
|
180 |
-
"
|
181 |
-
"response": {
|
182 |
-
"description": "List of patient's reservations (all statuses)",
|
183 |
-
"model": "List[Reservation]",
|
184 |
-
"note": "Returns empty list if no reservations found (no 404 error)"
|
185 |
-
}
|
186 |
},
|
187 |
"get_hospitals": {
|
188 |
"path": "/hospitals",
|
189 |
"method": "GET",
|
190 |
-
"description": "Get list of
|
191 |
"parameters": None,
|
|
|
|
|
|
|
|
|
|
|
192 |
}
|
193 |
}
|
|
|
1 |
+
# endpoints_documentation = {
|
2 |
+
# "root": {
|
3 |
+
# "path": "/",
|
4 |
+
# "method": "GET",
|
5 |
+
# "description": "API root endpoint",
|
6 |
+
# "parameters": None,
|
7 |
+
# "request_body": None,
|
8 |
+
# "response": {"message": "Clinic Reservation API - Use /docs for documentation"}
|
9 |
+
# },
|
10 |
+
# "get_reservations": {
|
11 |
+
# "path": "/reservations",
|
12 |
+
# "method": "GET",
|
13 |
+
# "description": "Get all reservations",
|
14 |
+
# "parameters": None,
|
15 |
+
# "request_body": None,
|
16 |
+
# "response": {
|
17 |
+
# "description": "List of all reservations",
|
18 |
+
# "model": "List[Reservation]",
|
19 |
+
# "filters": "Only returns reservations with status 'scheduled'"
|
20 |
+
# }
|
21 |
+
# },
|
22 |
+
# "get_reservations_by_filters": {
|
23 |
+
# "path": "/reservations/",
|
24 |
+
# "method": "GET",
|
25 |
+
# "description": "Get reservations filtered by patient ID and/or doctor name (only scheduled)",
|
26 |
+
# "parameters": {
|
27 |
+
# "patient_id": {
|
28 |
+
# "type": "str",
|
29 |
+
# "required": False,
|
30 |
+
# "description": "Filter by patient ID"
|
31 |
+
# },
|
32 |
+
# "doctor_name": {
|
33 |
+
# "type": "str",
|
34 |
+
# "required": False,
|
35 |
+
# "description": "Filter by doctor name (case-insensitive partial match)"
|
36 |
+
# }
|
37 |
+
# },
|
38 |
+
# "request_body": None,
|
39 |
+
# "response": {
|
40 |
+
# "description": "List of matching scheduled reservations",
|
41 |
+
# "model": "List[Reservation]",
|
42 |
+
# "error": "404 if no scheduled reservations match criteria"
|
43 |
+
# }
|
44 |
+
# },
|
45 |
+
# "create_reservation": {
|
46 |
+
# "path": "/create-reservation",
|
47 |
+
# "method": "POST",
|
48 |
+
# "description": "Create a new reservation",
|
49 |
+
# "parameters": None,
|
50 |
+
# "request_body": {
|
51 |
+
# "model": "CreateReservation",
|
52 |
+
# "required_fields": {
|
53 |
+
# "patient_id": "str",
|
54 |
+
# "doctor_name": "str",
|
55 |
+
# "date_time": "datetime like this 2023-10-16T19:00:00"
|
56 |
+
# },
|
57 |
+
# "optional_fields": {
|
58 |
+
# "reason": "str (optional)"
|
59 |
+
# }
|
60 |
+
# },
|
61 |
+
# "response": {
|
62 |
+
# "description": "Created reservation with status 'scheduled'",
|
63 |
+
# "model": "Reservation",
|
64 |
+
# "error": "404 if doctor not found"
|
65 |
+
# }
|
66 |
+
# },
|
67 |
+
# "reschedule_reservation": {
|
68 |
+
# "path": "/reservations/reschedule",
|
69 |
+
# "method": "PUT",
|
70 |
+
# "description": "Reschedule an existing reservation",
|
71 |
+
# "parameters": {
|
72 |
+
# "doctor_name": {
|
73 |
+
# "type": "str",
|
74 |
+
# "required": True,
|
75 |
+
# "description": "ID of the reservation to reschedule"
|
76 |
+
# },
|
77 |
+
# "new_date_time": {
|
78 |
+
# "type": "str",
|
79 |
+
# "required": True,
|
80 |
+
# "description": "New date/time to reschedule to"
|
81 |
+
# }
|
82 |
+
# },
|
83 |
+
# "response": {
|
84 |
+
# "description": "Updated reservation with new date/time",
|
85 |
+
# "model": "Reservation",
|
86 |
+
# "error": "404 if reservation not found"
|
87 |
+
# }
|
88 |
+
# },
|
89 |
+
# "cancel_reservation": {
|
90 |
+
# "path": "/reservations/cancel",
|
91 |
+
# "method": "PUT",
|
92 |
+
# "description": "Cancel a reservation",
|
93 |
+
# "parameters": {
|
94 |
+
# "doctor_name": {
|
95 |
+
# "type": "str",
|
96 |
+
# "required": True,
|
97 |
+
# "description": "ID of the reservation to cancel"
|
98 |
+
# }
|
99 |
+
# },
|
100 |
+
# "request_body": None,
|
101 |
+
# "response": {
|
102 |
+
# "description": "Canceled reservation (status changed to 'canceled')",
|
103 |
+
# "model": "Reservation",
|
104 |
+
# "error": "404 if reservation not found"
|
105 |
+
# }
|
106 |
+
# },
|
107 |
+
# "get_doctors": {
|
108 |
+
# "path": "/doctors",
|
109 |
+
# "method": "GET",
|
110 |
+
# "description": "Get list of all available doctors",
|
111 |
+
# "parameters": None,
|
112 |
+
# "request_body": None,
|
113 |
+
# "response": {
|
114 |
+
# "description": "List of doctors with their specialties",
|
115 |
+
# "model": "List[dict]",
|
116 |
+
# "example": [
|
117 |
+
# {"id": 1, "name": "Dr. Smith", "specialty": "General Medicine"}
|
118 |
+
# ]
|
119 |
+
# }
|
120 |
+
# },
|
121 |
+
# "get_doctor_availability": {
|
122 |
+
# "path": "/doctors/{doctor_id}/availability",
|
123 |
+
# "method": "GET",
|
124 |
+
# "description": "Get doctor's fake availability slots (30-min intervals from 9am-5pm)",
|
125 |
+
# "parameters": {
|
126 |
+
# "doctor_id": {
|
127 |
+
# "type": "int",
|
128 |
+
# "required": True,
|
129 |
+
# "description": "ID of the doctor"
|
130 |
+
# },
|
131 |
+
# "date": {
|
132 |
+
# "type": "str (YYYY-MM-DD)",
|
133 |
+
# "required": False,
|
134 |
+
# "description": "Date to check availability (default: today)"
|
135 |
+
# }
|
136 |
+
# },
|
137 |
+
# "request_body": None,
|
138 |
+
# "response": {
|
139 |
+
# "description": "Doctor's availability slots with random availability",
|
140 |
+
# "model": "dict",
|
141 |
+
# "example": {
|
142 |
+
# "doctor_id": 1,
|
143 |
+
# "date": "2023-10-15",
|
144 |
+
# "slots": [
|
145 |
+
# {
|
146 |
+
# "start": "2023-10-15T09:00:00",
|
147 |
+
# "end": "2023-10-15T09:30:00",
|
148 |
+
# "available": True
|
149 |
+
# }
|
150 |
+
# ]
|
151 |
+
# },
|
152 |
+
# "error": "404 if doctor not found"
|
153 |
+
# }
|
154 |
+
# },
|
155 |
+
# "get_patients": {
|
156 |
+
# "path": "/patients",
|
157 |
+
# "method": "GET",
|
158 |
+
# "description": "Get list of all patients",
|
159 |
+
# "parameters": None,
|
160 |
+
# "request_body": None,
|
161 |
+
# "response": {
|
162 |
+
# "description": "List of patients with contact information",
|
163 |
+
# "model": "List[Patient]",
|
164 |
+
# "example": [
|
165 |
+
# {"id": "uuid-123", "name": "John Doe", "phone": "555-0101", "email": "john@example.com"}
|
166 |
+
# ]
|
167 |
+
# }
|
168 |
+
# },
|
169 |
+
# "get_patient_reservations": {
|
170 |
+
# "path": "/patients/reservations",
|
171 |
+
# "method": "GET",
|
172 |
+
# "description": "Get my all reservations",
|
173 |
+
# "parameters": {
|
174 |
+
# "patient_id": {
|
175 |
+
# "type": "str",
|
176 |
+
# "required": True,
|
177 |
+
# "description": "ID of the patient"
|
178 |
+
# }
|
179 |
+
# },
|
180 |
+
# "request_body": None,
|
181 |
+
# "response": {
|
182 |
+
# "description": "List of patient's reservations (all statuses)",
|
183 |
+
# "model": "List[Reservation]",
|
184 |
+
# "note": "Returns empty list if no reservations found (no 404 error)"
|
185 |
+
# }
|
186 |
+
# },
|
187 |
+
# "get_hospitals": {
|
188 |
+
# "path": "/hospitals",
|
189 |
+
# "method": "GET",
|
190 |
+
# "description": "Get list of all hospitals and thier working hours (start time and end time) and location",
|
191 |
+
# "parameters": None,
|
192 |
+
# }
|
193 |
+
# }
|
194 |
+
|
195 |
+
|
196 |
endpoints_documentation = {
|
197 |
+
"get_my_reservations": {
|
198 |
+
"path": "/patients/reservations",
|
199 |
"method": "GET",
|
200 |
+
"description": "Get my personal reservations/appointments (all statuses)",
|
201 |
+
"parameters": {
|
202 |
+
"patient_id": {
|
203 |
+
"type": "str",
|
204 |
+
"required": True,
|
205 |
+
"description": "ID of the patient"
|
206 |
+
}
|
207 |
+
},
|
208 |
+
"response": {
|
209 |
+
"description": "List of patient's reservations",
|
210 |
+
"model": "List[Reservation]"
|
211 |
+
},
|
212 |
+
"use_case": "When user asks: Tell me my reservations, Show my appointments, قولي حجوزاتي"
|
213 |
},
|
214 |
+
"get_all_reservations": {
|
215 |
"path": "/reservations",
|
216 |
"method": "GET",
|
217 |
+
"description": "Get all reservations in the system (admin view)",
|
218 |
"parameters": None,
|
|
|
219 |
"response": {
|
220 |
+
"description": "List of all scheduled reservations",
|
221 |
+
"model": "List[Reservation]"
|
222 |
+
},
|
223 |
+
"use_case": "When admin asks: Show all reservations, Get all appointments"
|
224 |
},
|
225 |
+
"filter_reservations": {
|
226 |
"path": "/reservations/",
|
227 |
"method": "GET",
|
228 |
+
"description": "Filter reservations by patient ID or doctor name",
|
229 |
"parameters": {
|
230 |
"patient_id": {
|
231 |
"type": "str",
|
|
|
235 |
"doctor_name": {
|
236 |
"type": "str",
|
237 |
"required": False,
|
238 |
+
"description": "Filter by doctor name"
|
239 |
}
|
240 |
},
|
|
|
241 |
"response": {
|
242 |
"description": "List of matching scheduled reservations",
|
243 |
+
"model": "List[Reservation]"
|
244 |
+
},
|
245 |
+
"use_case": "When user asks: Show reservations with Dr. Smith, Find my reservations with specific doctor"
|
246 |
},
|
247 |
"create_reservation": {
|
248 |
"path": "/create-reservation",
|
249 |
"method": "POST",
|
250 |
+
"description": "Book a new appointment/reservation",
|
|
|
251 |
"request_body": {
|
|
|
252 |
"required_fields": {
|
253 |
"patient_id": "str",
|
254 |
"doctor_name": "str",
|
255 |
+
"date_time": "datetime (2023-10-16T19:00:00)"
|
256 |
},
|
257 |
"optional_fields": {
|
258 |
+
"reason": "str"
|
259 |
}
|
260 |
},
|
261 |
"response": {
|
262 |
+
"description": "Created reservation",
|
263 |
+
"model": "Reservation"
|
264 |
+
},
|
265 |
+
"use_case": "When user asks: Book appointment, Schedule meeting, احجز موعد, I want to book with Dr. Smith"
|
266 |
},
|
267 |
"reschedule_reservation": {
|
268 |
"path": "/reservations/reschedule",
|
269 |
"method": "PUT",
|
270 |
+
"description": "Change appointment date/time",
|
271 |
"parameters": {
|
272 |
"doctor_name": {
|
273 |
"type": "str",
|
274 |
"required": True,
|
275 |
+
"description": "Doctor name for the reservation"
|
276 |
},
|
277 |
"new_date_time": {
|
278 |
"type": "str",
|
279 |
"required": True,
|
280 |
+
"description": "New date/time"
|
281 |
}
|
282 |
},
|
283 |
"response": {
|
284 |
+
"description": "Updated reservation",
|
285 |
+
"model": "Reservation"
|
286 |
+
},
|
287 |
+
"use_case": "When user asks: Reschedule appointment, Change my appointment time, غير موعدي"
|
288 |
},
|
289 |
"cancel_reservation": {
|
290 |
"path": "/reservations/cancel",
|
291 |
"method": "PUT",
|
292 |
+
"description": "Cancel an existing appointment",
|
293 |
"parameters": {
|
294 |
"doctor_name": {
|
295 |
"type": "str",
|
296 |
"required": True,
|
297 |
+
"description": "Doctor name for the reservation to cancel"
|
298 |
}
|
299 |
},
|
|
|
300 |
"response": {
|
301 |
+
"description": "Canceled reservation",
|
302 |
+
"model": "Reservation"
|
303 |
+
},
|
304 |
+
"use_case": "When user asks: Cancel appointment, Cancel my booking, الغي موعدي"
|
305 |
},
|
306 |
"get_doctors": {
|
307 |
"path": "/doctors",
|
308 |
"method": "GET",
|
309 |
+
"description": "Get list of available doctors and their specialties",
|
310 |
"parameters": None,
|
|
|
311 |
"response": {
|
312 |
+
"description": "List of doctors",
|
313 |
+
"model": "List[Doctor]"
|
314 |
+
},
|
315 |
+
"use_case": "When user asks: Show doctors, List available doctors, اظهر الاطباء"
|
|
|
|
|
316 |
},
|
317 |
"get_doctor_availability": {
|
318 |
"path": "/doctors/{doctor_id}/availability",
|
319 |
"method": "GET",
|
320 |
+
"description": "Check doctor's available time slots",
|
321 |
"parameters": {
|
322 |
"doctor_id": {
|
323 |
"type": "int",
|
324 |
"required": True,
|
325 |
+
"description": "Doctor ID"
|
326 |
},
|
327 |
"date": {
|
328 |
+
"type": "str",
|
329 |
"required": False,
|
330 |
+
"description": "Date (YYYY-MM-DD), default today"
|
331 |
}
|
332 |
},
|
|
|
333 |
"response": {
|
334 |
+
"description": "Doctor's availability slots",
|
335 |
+
"model": "AvailabilitySlots"
|
336 |
+
},
|
337 |
+
"use_case": "When user asks: Is Dr. Smith available?, Check doctor availability, متى متاح الدكتور"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
},
|
339 |
"get_patients": {
|
340 |
"path": "/patients",
|
341 |
"method": "GET",
|
342 |
+
"description": "Get list of all patients (admin only)",
|
343 |
"parameters": None,
|
|
|
344 |
"response": {
|
345 |
+
"description": "List of patients",
|
346 |
+
"model": "List[Patient]"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
},
|
348 |
+
"use_case": "When admin asks: Show all patients, List patients"
|
|
|
|
|
|
|
|
|
|
|
349 |
},
|
350 |
"get_hospitals": {
|
351 |
"path": "/hospitals",
|
352 |
"method": "GET",
|
353 |
+
"description": "Get list of hospitals with locations and working hours",
|
354 |
"parameters": None,
|
355 |
+
"response": {
|
356 |
+
"description": "List of hospitals",
|
357 |
+
"model": "List[Hospital]"
|
358 |
+
},
|
359 |
+
"use_case": "When user asks: Show hospitals, Where are the clinics, اظهر المستشفيات"
|
360 |
}
|
361 |
}
|
main.py
CHANGED
@@ -172,21 +172,13 @@ class HealthcareChatbot:
|
|
172 |
|
173 |
**STEP 1: What does the user want?**
|
174 |
- If query is in Arabic, translate it to English first
|
175 |
-
- Identify the
|
176 |
-
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
**STEP 2: Can any endpoint fulfill this want?**
|
183 |
-
- Look at each endpoint in the documentation
|
184 |
-
- Check if the endpoint's purpose matches what the user wants
|
185 |
-
- Match the action type:
|
186 |
-
* User wants to VIEW/GET something → Look for GET endpoints
|
187 |
-
* User wants to CREATE/BOOK → Look for POST endpoints
|
188 |
-
* User wants to UPDATE/CHANGE → Look for PUT/PATCH endpoints
|
189 |
-
* User wants to DELETE/CANCEL → Look for DELETE endpoints
|
190 |
|
191 |
**STEP 3: Decision**
|
192 |
- Found matching endpoint = "API_ACTION"
|
@@ -196,7 +188,7 @@ class HealthcareChatbot:
|
|
196 |
{{
|
197 |
"intent": "CONVERSATION|API_ACTION",
|
198 |
"confidence": 0.8,
|
199 |
-
"reasoning": "User wants: [
|
200 |
"endpoint": "/exact/endpoint/path",
|
201 |
"method": "GET|POST|PUT|DELETE",
|
202 |
"params": {{}},
|
@@ -208,7 +200,6 @@ class HealthcareChatbot:
|
|
208 |
input_variables=["user_query", "detected_language", "extracted_keywords",
|
209 |
"sentiment_analysis", "endpoints_documentation"]
|
210 |
)
|
211 |
-
|
212 |
# CONVERSATION CHAIN - Handles conversational responses
|
213 |
self.conversation_template = PromptTemplate(
|
214 |
template="""
|
|
|
172 |
|
173 |
**STEP 1: What does the user want?**
|
174 |
- If query is in Arabic, translate it to English first
|
175 |
+
- Identify the exact action or information the user is requesting
|
176 |
+
- Focus on understanding their underlying need, not just the words
|
177 |
+
|
178 |
+
**STEP 2: Find matching endpoint**
|
179 |
+
- Read each endpoint description in the documentation
|
180 |
+
- Check if any endpoint's purpose can fulfill what the user wants
|
181 |
+
- Match based on functionality, not keywords
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
|
183 |
**STEP 3: Decision**
|
184 |
- Found matching endpoint = "API_ACTION"
|
|
|
188 |
{{
|
189 |
"intent": "CONVERSATION|API_ACTION",
|
190 |
"confidence": 0.8,
|
191 |
+
"reasoning": "User wants: [what user actually needs]. Found endpoint: [endpoint path and why it matches] OR No endpoint matches this need",
|
192 |
"endpoint": "/exact/endpoint/path",
|
193 |
"method": "GET|POST|PUT|DELETE",
|
194 |
"params": {{}},
|
|
|
200 |
input_variables=["user_query", "detected_language", "extracted_keywords",
|
201 |
"sentiment_analysis", "endpoints_documentation"]
|
202 |
)
|
|
|
203 |
# CONVERSATION CHAIN - Handles conversational responses
|
204 |
self.conversation_template = PromptTemplate(
|
205 |
template="""
|