Spaces:
Sleeping
Sleeping
Ankush Rana
commited on
Commit
·
16a7a52
1
Parent(s):
7326506
fix bug tools
Browse files
tools.py
CHANGED
@@ -131,7 +131,7 @@ Whether for relaxation or adventure, **Nou Vall de Núria** promises a unique an
|
|
131 |
|
132 |
|
133 |
@tool_register
|
134 |
-
class
|
135 |
"""
|
136 |
Retrieves general information about a region, its cities, activities, tourism, or surrounding areas based on query.
|
137 |
"""
|
@@ -220,7 +220,7 @@ class check_room_availability(ToolBase):
|
|
220 |
|
221 |
@classmethod
|
222 |
def invoke(cls, input: Dict) -> str:
|
223 |
-
|
224 |
room_type = input.get("room_type", None)
|
225 |
reservation_start_date = input.get("reservation_start_date", None)
|
226 |
reservation_end_date = input.get("reservation_end_date", None)
|
@@ -274,7 +274,7 @@ class make_reservation(ToolBase):
|
|
274 |
|
275 |
@classmethod
|
276 |
def invoke(cls, input: Dict) -> str:
|
277 |
-
|
278 |
room_type = input.get("room_type", None)
|
279 |
reservation_start_date = input.get("reservation_start_date", None)
|
280 |
reservation_end_date = input.get("reservation_end_date", None)
|
@@ -369,18 +369,18 @@ class cancel_reservation(ToolBase):
|
|
369 |
class modify_reservation(ToolBase):
|
370 |
"""
|
371 |
Allows a user to modify an existing reservation by updating the check-in/check-out dates or changing the room type, subject to availability.
|
|
|
372 |
"""
|
373 |
|
374 |
-
|
375 |
new_room_type: str | None = Field(default=list(json_data["room_types"].keys()), description=f"The type of new room to be modified, if {None} same room will be modified.")
|
376 |
new_reservation_start_date: str = Field(default=None, description="New check out date in format DD/MM/YYYY")
|
377 |
new_reservation_end_date: str = Field(default=None, description="New check out date in format DD/MM/YYYY")
|
378 |
-
|
379 |
-
reservation_id: int = Field(description="The unique identifier of the reservation to be modified.")
|
380 |
|
381 |
@classmethod
|
382 |
def invoke(cls, input: Dict) -> str:
|
383 |
-
|
384 |
reservation_id = input.get("reservation_id", None)
|
385 |
|
386 |
missing = []
|
@@ -391,26 +391,26 @@ class modify_reservation(ToolBase):
|
|
391 |
new_room_type = instance.new_room_type
|
392 |
new_reservation_start_date = instance.new_reservation_start_date
|
393 |
new_reservation_end_date = instance.new_reservation_end_date
|
394 |
-
|
395 |
reservation_id = instance.reservation_id
|
396 |
|
397 |
if len(missing):
|
398 |
value = ", ".join(missing)
|
399 |
return f"Unable to modify the reservation. The following required arguments are missing:{value}."
|
400 |
-
|
401 |
-
if not (new_room_type or new_reservation_start_date or new_reservation_end_date or
|
402 |
-
return "Unable to modify the reservation. One of the following arguments must be passed: new_room_type, new_reservation_start_date, new_reservation_end_date,
|
403 |
|
404 |
|
405 |
if reservation_id not in reservations:
|
406 |
return f"There is no reservations with the id: {reservation_id}"
|
407 |
|
408 |
-
if new_room_type or
|
409 |
-
rooms = [room for room in json_data["
|
410 |
if len(rooms) == 0:
|
411 |
return f"There is no room exists with room type {new_room_type}"
|
412 |
|
413 |
-
rooms = [room for room in rooms if
|
414 |
if len(rooms) == 0:
|
415 |
max_guests = json_data["room_types"][new_room_type]["number_of_guests"]
|
416 |
return f"The number of guest is superior then the availibilty, maximum is {max_guests}"
|
@@ -421,7 +421,7 @@ class modify_reservation(ToolBase):
|
|
421 |
room_number = reservations[reservation_id]["room_number"]
|
422 |
|
423 |
|
424 |
-
reservations[reservation_id]["guests"] =
|
425 |
reservations[reservation_id]["reservation_start_date"] = new_reservation_start_date if new_reservation_start_date else reservations[reservation_id]["reservation_start_date"]
|
426 |
reservations[reservation_id]["reservation_end_date"] = new_reservation_end_date if new_reservation_end_date else reservations[reservation_id]["reservation_end_date"]
|
427 |
reservations[reservation_id]["room_type"] = new_room_type if new_room_type else reservations[reservation_id]["room_type"]
|
@@ -430,8 +430,8 @@ class modify_reservation(ToolBase):
|
|
430 |
return f"The reservation {reservation_id} is modified correctly: {json.dumps(tmp_data)}"
|
431 |
|
432 |
@tool_register
|
433 |
-
class
|
434 |
-
"""
|
435 |
|
436 |
reservation_id: int = Field(description="Id of the reservation")
|
437 |
|
|
|
131 |
|
132 |
|
133 |
@tool_register
|
134 |
+
class get_hotal_general_information(ToolBase):
|
135 |
"""
|
136 |
Retrieves general information about a region, its cities, activities, tourism, or surrounding areas based on query.
|
137 |
"""
|
|
|
220 |
|
221 |
@classmethod
|
222 |
def invoke(cls, input: Dict) -> str:
|
223 |
+
input["room_type"] = input.get("room_type", None)
|
224 |
room_type = input.get("room_type", None)
|
225 |
reservation_start_date = input.get("reservation_start_date", None)
|
226 |
reservation_end_date = input.get("reservation_end_date", None)
|
|
|
274 |
|
275 |
@classmethod
|
276 |
def invoke(cls, input: Dict) -> str:
|
277 |
+
input["room_type"] = input.get("room_type", None)
|
278 |
room_type = input.get("room_type", None)
|
279 |
reservation_start_date = input.get("reservation_start_date", None)
|
280 |
reservation_end_date = input.get("reservation_end_date", None)
|
|
|
369 |
class modify_reservation(ToolBase):
|
370 |
"""
|
371 |
Allows a user to modify an existing reservation by updating the check-in/check-out dates or changing the room type, subject to availability.
|
372 |
+
One of these parameter is mandatory: new_room_type, new_reservation_start_date, new_reservation_end_date, guests.
|
373 |
"""
|
374 |
|
375 |
+
reservation_id: int = Field(description="The unique identifier of the reservation to be modified.")
|
376 |
new_room_type: str | None = Field(default=list(json_data["room_types"].keys()), description=f"The type of new room to be modified, if {None} same room will be modified.")
|
377 |
new_reservation_start_date: str = Field(default=None, description="New check out date in format DD/MM/YYYY")
|
378 |
new_reservation_end_date: str = Field(default=None, description="New check out date in format DD/MM/YYYY")
|
379 |
+
new_guests: int = Field(default=None, description="New number of guests for the reservation.")
|
|
|
380 |
|
381 |
@classmethod
|
382 |
def invoke(cls, input: Dict) -> str:
|
383 |
+
input["new_room_type"] = input.get("new_room_type", None)
|
384 |
reservation_id = input.get("reservation_id", None)
|
385 |
|
386 |
missing = []
|
|
|
391 |
new_room_type = instance.new_room_type
|
392 |
new_reservation_start_date = instance.new_reservation_start_date
|
393 |
new_reservation_end_date = instance.new_reservation_end_date
|
394 |
+
new_guests = instance.new_guests
|
395 |
reservation_id = instance.reservation_id
|
396 |
|
397 |
if len(missing):
|
398 |
value = ", ".join(missing)
|
399 |
return f"Unable to modify the reservation. The following required arguments are missing:{value}."
|
400 |
+
|
401 |
+
if not (new_room_type or new_reservation_start_date or new_reservation_end_date or new_guests):
|
402 |
+
return "Unable to modify the reservation. One of the following arguments must be passed: new_room_type, new_reservation_start_date, new_reservation_end_date, new_guests."
|
403 |
|
404 |
|
405 |
if reservation_id not in reservations:
|
406 |
return f"There is no reservations with the id: {reservation_id}"
|
407 |
|
408 |
+
if new_room_type or new_guests:
|
409 |
+
rooms = [room for room in json_data["accomodations"]["rooms"] if new_room_type in room["type"]]
|
410 |
if len(rooms) == 0:
|
411 |
return f"There is no room exists with room type {new_room_type}"
|
412 |
|
413 |
+
rooms = [room for room in rooms if new_guests <= room["number_of_guests"]]
|
414 |
if len(rooms) == 0:
|
415 |
max_guests = json_data["room_types"][new_room_type]["number_of_guests"]
|
416 |
return f"The number of guest is superior then the availibilty, maximum is {max_guests}"
|
|
|
421 |
room_number = reservations[reservation_id]["room_number"]
|
422 |
|
423 |
|
424 |
+
reservations[reservation_id]["guests"] = new_guests if new_guests else reservations[reservation_id]["guests"]
|
425 |
reservations[reservation_id]["reservation_start_date"] = new_reservation_start_date if new_reservation_start_date else reservations[reservation_id]["reservation_start_date"]
|
426 |
reservations[reservation_id]["reservation_end_date"] = new_reservation_end_date if new_reservation_end_date else reservations[reservation_id]["reservation_end_date"]
|
427 |
reservations[reservation_id]["room_type"] = new_room_type if new_room_type else reservations[reservation_id]["room_type"]
|
|
|
430 |
return f"The reservation {reservation_id} is modified correctly: {json.dumps(tmp_data)}"
|
431 |
|
432 |
@tool_register
|
433 |
+
class get_reservation_detail(ToolBase):
|
434 |
+
"""Retrieve comprehensive details of a specific room reservation by providing its unique reservation ID."""
|
435 |
|
436 |
reservation_id: int = Field(description="Id of the reservation")
|
437 |
|