ankush13r commited on
Commit
6e63547
·
verified ·
1 Parent(s): a7eff47

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +52 -34
tools.py CHANGED
@@ -159,12 +159,11 @@ class check_room_availability(ToolBase):
159
 
160
  @classmethod
161
  def invoke(cls, input: Dict) -> str:
162
-
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:
@@ -179,6 +178,12 @@ class check_room_availability(ToolBase):
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:
@@ -203,15 +208,18 @@ class make_reservation(ToolBase):
203
  user_id: int = Field(description="The identifier for the user making the reservation.")
204
 
205
  @classmethod
206
- def invoke(cls, input: Dict) -> str:
207
 
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")
@@ -224,9 +232,12 @@ class make_reservation(ToolBase):
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:
@@ -267,13 +278,9 @@ class cancel_reservation(ToolBase):
267
 
268
  @classmethod
269
  def invoke(cls, input: Dict) -> str:
270
- """
271
- Play a playlist by its name, starting with the first or a random song.
272
- """
273
 
274
- instance = cls(**input)
275
- reservation_id = instance.reservation_id
276
- user_id = instance.user_id
277
 
278
  missing = []
279
  if not reservation_id:
@@ -284,6 +291,12 @@ class cancel_reservation(ToolBase):
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}"
@@ -310,6 +323,15 @@ class modify_reservation(ToolBase):
310
 
311
  @classmethod
312
  def invoke(cls, input: Dict) -> str:
 
 
 
 
 
 
 
 
 
313
 
314
  instance = cls(**input)
315
  new_room_type = instance.new_room_type
@@ -319,12 +341,6 @@ class modify_reservation(ToolBase):
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}."
@@ -375,11 +391,9 @@ class get_reservation_details(ToolBase):
375
 
376
  @classmethod
377
  def invoke(cls, input: Dict) -> str:
378
-
379
- instance = cls(**input)
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")
@@ -390,6 +404,10 @@ class get_reservation_details(ToolBase):
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
 
 
159
 
160
  @classmethod
161
  def invoke(cls, input: Dict) -> str:
162
+
163
+ room_type = input.get("room_type", None)
164
+ check_in_date = input.get("check_in_date", None)
165
+ check_out_date = input.get("check_out_date", None)
166
+ guests = input.get("guests", None)
 
167
 
168
  missing = []
169
  if not room_type:
 
178
  if len(missing):
179
  value = ", ".join(missing)
180
  return f"Unable to check the room availability. The following required arguments are missing:{value}."
181
+
182
+ instance = cls(**input)
183
+ room_type = instance.room_type
184
+ check_in_date = instance.check_in_date
185
+ check_out_date = instance.check_out_date
186
+ guests = instance.guests
187
 
188
  rooms = [room for room in json_data["accomodations"] if room_type in room["type"]]
189
  if len(rooms) == 0:
 
208
  user_id: int = Field(description="The identifier for the user making the reservation.")
209
 
210
  @classmethod
211
+ def invoke(cls, input: Dict) -> str:
212
 
213
+ room_type = input.get("room_type", None)
214
+ check_in_date = input.get("check_in_date", None)
215
+ check_out_date = input.get("check_out_date", None)
216
+ guests = input.get("guests", None)
217
+ user_id = input.get("user_id", None)
218
+
219
+ if len(missing):
220
+ value = ", ".join(missing)
221
+ return f"Unable to complete the reservation. The following required arguments are missing:{value}."
222
+
223
  missing = []
224
  if not room_type:
225
  missing.append("room_type")
 
232
  if not user_id:
233
  missing.append("user_id")
234
 
235
+ instance = cls(**input)
236
+ room_type = instance.room_type
237
+ check_in_date = instance.check_in_date
238
+ check_out_date = instance.check_out_date
239
+ guests = instance.guests
240
+ user_id = instance.user_id
241
 
242
  rooms = [room for room in json_data["accomodations"] if room_type in room["type"]]
243
  if len(rooms) == 0:
 
278
 
279
  @classmethod
280
  def invoke(cls, input: Dict) -> str:
 
 
 
281
 
282
+ reservation_id = input.get("reservation_id", None)
283
+ user_id = input.get("user_id", None)
 
284
 
285
  missing = []
286
  if not reservation_id:
 
291
  if len(missing):
292
  value = ", ".join(missing)
293
  return f"Unable to cancel the reservation. The following required arguments are missing:{value}."
294
+
295
+ instance = cls(**input)
296
+ reservation_id = instance.reservation_id
297
+ user_id = instance.user_id
298
+
299
+
300
 
301
  if reservation_id not in reservations:
302
  return f"There is no reservations with the id: {reservation_id}"
 
323
 
324
  @classmethod
325
  def invoke(cls, input: Dict) -> str:
326
+
327
+ user_id = input.get("user_id", None)
328
+ reservation_id = input.get("reservation_id", None)
329
+
330
+ missing = []
331
+ if not reservation_id:
332
+ missing.append("reservation_id")
333
+ if not user_id:
334
+ missing.append("user_id")
335
 
336
  instance = cls(**input)
337
  new_room_type = instance.new_room_type
 
341
  user_id = instance.user_id
342
  reservation_id = instance.reservation_id
343
 
 
 
 
 
 
 
344
  if len(missing):
345
  value = ", ".join(missing)
346
  return f"Unable to modify the reservation. The following required arguments are missing:{value}."
 
391
 
392
  @classmethod
393
  def invoke(cls, input: Dict) -> str:
394
+ user_id = input.get("user_id", None)
395
+ reservation_id = input.get("reservation_id", None)
396
+
 
 
397
  missing = []
398
  if not reservation_id:
399
  missing.append("reservation_id")
 
404
  value = ", ".join(missing)
405
  return f"Unable to get the details. The following required arguments are missing:{value}."
406
 
407
+ instance = cls(**input)
408
+ user_id = instance.user_id
409
+ reservation_id = instance.reservation_id
410
+
411
  if reservation_id not in reservations:
412
  return f"There is no reservations with the id: {reservation_id}"
413