ankush13r commited on
Commit
a7eff47
·
verified ·
1 Parent(s): 7d92a5a

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +72 -12
tools.py CHANGED
@@ -89,13 +89,9 @@ class get_hotel_information(ToolBase):
89
  @classmethod
90
  def invoke(cls, input: Dict) -> str:
91
  return """### **Nou Vall de Núria – Brief Description**
92
-
93
  Nestled in the stunning **Vall de Núria** in the Pyrenees, **Nou Vall de Núria** offers a perfect blend of comfort and adventure. Guests can enjoy breathtaking mountain views, premium accommodations, and excellent facilities, including an outdoor pool, gym, and sauna.
94
-
95
  The hotel features **two dining options**, serving traditional Catalan cuisine and refreshing drinks. Accommodations range from **cozy standard rooms to luxurious suites and fully equipped apartments**, catering to couples, families, and groups.
96
-
97
  For an unforgettable stay, guests can choose from **special packages**, including family-friendly stays, romantic getaways, ski adventures, and relaxation retreats. Outdoor enthusiasts can explore **hiking trails, ski slopes, and fishing spots** in the surrounding natural beauty.
98
-
99
  Whether for relaxation or adventure, **Nou Vall de Núria** promises a unique and memorable experience."""
100
 
101
  @tool_register
@@ -167,8 +163,23 @@ class check_room_availability(ToolBase):
167
  instance = cls(**input)
168
  room_type = instance.room_type
169
  check_in_date = instance.check_in_date
170
- check_in_date = instance.check_in_date
171
  guests = instance.guests
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  rooms = [room for room in json_data["accomodations"] if room_type in room["type"]]
173
  if len(rooms) == 0:
174
  return f"There is no room exists with room type {room_type}"
@@ -197,10 +208,25 @@ class make_reservation(ToolBase):
197
  instance = cls(**input)
198
  room_type = instance.room_type
199
  check_in_date = instance.check_in_date
200
- check_in_date = instance.check_in_date
201
  guests = instance.guests
202
  user_id = instance.user_id
203
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
 
205
  rooms = [room for room in json_data["accomodations"] if room_type in room["type"]]
206
  if len(rooms) == 0:
@@ -222,7 +248,7 @@ class make_reservation(ToolBase):
222
  "room_number": room["room_number"],
223
  "room_type": room_type,
224
  "check_in_date": check_in_date,
225
- "check_in_date": check_in_date,
226
  "guests": guests,
227
  "reservation_id": rand,
228
  "user_id": user_id,
@@ -249,8 +275,18 @@ class cancel_reservation(ToolBase):
249
  reservation_id = instance.reservation_id
250
  user_id = instance.user_id
251
 
 
 
 
 
 
 
 
 
 
 
252
  if reservation_id not in reservations:
253
- return f"The is no reservations with the id: {reservation_id}"
254
 
255
  if reservations["reservation_id"]["user_id"] != user_id:
256
  return "The user id is wrong, please provide same user id that was used make to reservation."
@@ -283,8 +319,22 @@ class modify_reservation(ToolBase):
283
  user_id = instance.user_id
284
  reservation_id = instance.reservation_id
285
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  if reservation_id not in reservations:
287
- return f"The is no reservations with the id: {reservation_id}"
288
 
289
  if reservations["reservation_id"]["user_id"] != user_id:
290
  return "The user id is wrong, please provide same user id that was used make to reservation."
@@ -330,12 +380,22 @@ class get_reservation_details(ToolBase):
330
  user_id = instance.user_id
331
  reservation_id = instance.reservation_id
332
 
 
 
 
 
 
 
 
 
 
 
333
  if reservation_id not in reservations:
334
- return f"The is no reservations with the id: {reservation_id}"
335
 
336
  if reservations["reservation_id"]["user_id"] != user_id:
337
  return "The user id is wrong, please provide same user id that was used make to reservation."
338
 
339
  tmp_data = copy.deepcopy(reservations["reservation_id"])
340
  tmp_data.pop("user_id")
341
- return json.dumps(tmp_data)
 
89
  @classmethod
90
  def invoke(cls, input: Dict) -> str:
91
  return """### **Nou Vall de Núria – Brief Description**
 
92
  Nestled in the stunning **Vall de Núria** in the Pyrenees, **Nou Vall de Núria** offers a perfect blend of comfort and adventure. Guests can enjoy breathtaking mountain views, premium accommodations, and excellent facilities, including an outdoor pool, gym, and sauna.
 
93
  The hotel features **two dining options**, serving traditional Catalan cuisine and refreshing drinks. Accommodations range from **cozy standard rooms to luxurious suites and fully equipped apartments**, catering to couples, families, and groups.
 
94
  For an unforgettable stay, guests can choose from **special packages**, including family-friendly stays, romantic getaways, ski adventures, and relaxation retreats. Outdoor enthusiasts can explore **hiking trails, ski slopes, and fishing spots** in the surrounding natural beauty.
 
95
  Whether for relaxation or adventure, **Nou Vall de Núria** promises a unique and memorable experience."""
96
 
97
  @tool_register
 
163
  instance = cls(**input)
164
  room_type = instance.room_type
165
  check_in_date = instance.check_in_date
166
+ check_out_date = instance.check_out_date
167
  guests = instance.guests
168
+
169
+ missing = []
170
+ if not room_type:
171
+ missing.append("room_type")
172
+ if not check_in_date:
173
+ missing.append("check_in_date")
174
+ if not check_out_date:
175
+ missing.append("check_out_date")
176
+ if not guests:
177
+ missing.append("guests")
178
+
179
+ if len(missing):
180
+ value = ", ".join(missing)
181
+ return f"Unable to check the room availability. The following required arguments are missing:{value}."
182
+
183
  rooms = [room for room in json_data["accomodations"] if room_type in room["type"]]
184
  if len(rooms) == 0:
185
  return f"There is no room exists with room type {room_type}"
 
208
  instance = cls(**input)
209
  room_type = instance.room_type
210
  check_in_date = instance.check_in_date
211
+ check_out_date = instance.check_out_date
212
  guests = instance.guests
213
  user_id = instance.user_id
214
+
215
+ missing = []
216
+ if not room_type:
217
+ missing.append("room_type")
218
+ if not check_in_date:
219
+ missing.append("check_in_date")
220
+ if not check_out_date:
221
+ missing.append("check_out_date")
222
+ if not guests:
223
+ missing.append("guests")
224
+ if not user_id:
225
+ missing.append("user_id")
226
+
227
+ if len(missing):
228
+ value = ", ".join(missing)
229
+ return f"Unable to complete the reservation. The following required arguments are missing:{value}."
230
 
231
  rooms = [room for room in json_data["accomodations"] if room_type in room["type"]]
232
  if len(rooms) == 0:
 
248
  "room_number": room["room_number"],
249
  "room_type": room_type,
250
  "check_in_date": check_in_date,
251
+ "check_out_date": check_out_date,
252
  "guests": guests,
253
  "reservation_id": rand,
254
  "user_id": user_id,
 
275
  reservation_id = instance.reservation_id
276
  user_id = instance.user_id
277
 
278
+ missing = []
279
+ if not reservation_id:
280
+ missing.append("reservation_id")
281
+ if not user_id:
282
+ missing.append("user_id")
283
+
284
+ if len(missing):
285
+ value = ", ".join(missing)
286
+ return f"Unable to cancel the reservation. The following required arguments are missing:{value}."
287
+
288
  if reservation_id not in reservations:
289
+ return f"There is no reservations with the id: {reservation_id}"
290
 
291
  if reservations["reservation_id"]["user_id"] != user_id:
292
  return "The user id is wrong, please provide same user id that was used make to reservation."
 
319
  user_id = instance.user_id
320
  reservation_id = instance.reservation_id
321
 
322
+ missing = []
323
+ if not reservation_id:
324
+ missing.append("reservation_id")
325
+ if not user_id:
326
+ missing.append("user_id")
327
+
328
+ if len(missing):
329
+ value = ", ".join(missing)
330
+ return f"Unable to modify the reservation. The following required arguments are missing:{value}."
331
+
332
+ if not (new_room_type or new_check_in_date or new_check_out_date or guests):
333
+ return "Unable to modify the reservation. One of the following arguments must be passed: new_room_type, new_check_in_date, new_check_out_date, guests."
334
+
335
+
336
  if reservation_id not in reservations:
337
+ return f"There is no reservations with the id: {reservation_id}"
338
 
339
  if reservations["reservation_id"]["user_id"] != user_id:
340
  return "The user id is wrong, please provide same user id that was used make to reservation."
 
380
  user_id = instance.user_id
381
  reservation_id = instance.reservation_id
382
 
383
+ missing = []
384
+ if not reservation_id:
385
+ missing.append("reservation_id")
386
+ if not user_id:
387
+ missing.append("user_id")
388
+
389
+ if len(missing):
390
+ value = ", ".join(missing)
391
+ return f"Unable to get the details. The following required arguments are missing:{value}."
392
+
393
  if reservation_id not in reservations:
394
+ return f"There is no reservations with the id: {reservation_id}"
395
 
396
  if reservations["reservation_id"]["user_id"] != user_id:
397
  return "The user id is wrong, please provide same user id that was used make to reservation."
398
 
399
  tmp_data = copy.deepcopy(reservations["reservation_id"])
400
  tmp_data.pop("user_id")
401
+ return json.dumps(tmp_data)