Spaces:
Sleeping
Sleeping
OnlyBiggg
commited on
Commit
·
b7a31e3
1
Parent(s):
a247954
fix
Browse files
app/dialogflow/api/v1/dialogflow.py
CHANGED
|
@@ -393,7 +393,7 @@ async def time_trip(request: Request) -> Response:
|
|
| 393 |
body = await request.json()
|
| 394 |
session_info = body.get("sessionInfo", {})
|
| 395 |
parameters = session_info.get("parameters")
|
| 396 |
-
trip_list:
|
| 397 |
raw_route_id = parameters.get("route_id")
|
| 398 |
route_name = parameters.get("route_name", "")
|
| 399 |
raw_time = parameters.get("time-select")
|
|
@@ -411,15 +411,16 @@ async def time_trip(request: Request) -> Response:
|
|
| 411 |
|
| 412 |
if raw_time:
|
| 413 |
time = extra_time_dialogflow(raw_time)
|
|
|
|
|
|
|
| 414 |
if isinstance(time, list):
|
| 415 |
-
quick_time_reply = time
|
| 416 |
parameters["time_select"] = None
|
| 417 |
parameters["is_time_ambiguous"] = True
|
| 418 |
text = [f"Quý khách dự định đi vào lúc"]
|
| 419 |
else:
|
| 420 |
text = []
|
| 421 |
if is_has_time:
|
| 422 |
-
text = [f"Quý khách lựa chọn thời gian chuyến {route_name}\n" + " | ".join([item["time"] for item in
|
| 423 |
parameters["is_has_time"] = None
|
| 424 |
else:
|
| 425 |
parameters["is_has_time"] = True
|
|
@@ -429,7 +430,7 @@ async def time_trip(request: Request) -> Response:
|
|
| 429 |
if (trip["route_id"]) == route_id:
|
| 430 |
time_list.append({"time": trip["departure_time"], "trip_id": trip["id"]})
|
| 431 |
quick_time_reply = time_list
|
| 432 |
-
text = [f"Quý khách lựa chọn thời gian chuyến {route_name}\n" + " | ".join([item["time"] for item in
|
| 433 |
|
| 434 |
parameters["time_list"] = time_list
|
| 435 |
payload={
|
|
|
|
| 393 |
body = await request.json()
|
| 394 |
session_info = body.get("sessionInfo", {})
|
| 395 |
parameters = session_info.get("parameters")
|
| 396 |
+
trip_list: list[Dict[str, any]] = parameters.get("trip_list", [])
|
| 397 |
raw_route_id = parameters.get("route_id")
|
| 398 |
route_name = parameters.get("route_name", "")
|
| 399 |
raw_time = parameters.get("time-select")
|
|
|
|
| 411 |
|
| 412 |
if raw_time:
|
| 413 |
time = extra_time_dialogflow(raw_time)
|
| 414 |
+
quick_time_reply = time_list
|
| 415 |
+
|
| 416 |
if isinstance(time, list):
|
|
|
|
| 417 |
parameters["time_select"] = None
|
| 418 |
parameters["is_time_ambiguous"] = True
|
| 419 |
text = [f"Quý khách dự định đi vào lúc"]
|
| 420 |
else:
|
| 421 |
text = []
|
| 422 |
if is_has_time:
|
| 423 |
+
text = [f"Quý khách lựa chọn thời gian chuyến {route_name}\n" + " | ".join([item["time"] for item in quick_time_reply])]
|
| 424 |
parameters["is_has_time"] = None
|
| 425 |
else:
|
| 426 |
parameters["is_has_time"] = True
|
|
|
|
| 430 |
if (trip["route_id"]) == route_id:
|
| 431 |
time_list.append({"time": trip["departure_time"], "trip_id": trip["id"]})
|
| 432 |
quick_time_reply = time_list
|
| 433 |
+
text = [f"Quý khách lựa chọn thời gian chuyến {route_name}\n" + " | ".join([item["time"] for item in quick_time_reply])]
|
| 434 |
|
| 435 |
parameters["time_list"] = time_list
|
| 436 |
payload={
|
utils/format_data_dialog.py
CHANGED
|
@@ -11,7 +11,9 @@ def find_surrounding_times(time_list: list, time: str) -> list:
|
|
| 11 |
:param time: Time string to find the surrounding times for.
|
| 12 |
:return: List of surrounding times in "HH:mm" format.
|
| 13 |
"""
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
|
| 16 |
start = max(0, index - 2)
|
| 17 |
end = min(len(time_list), index + 2)
|
|
|
|
| 11 |
:param time: Time string to find the surrounding times for.
|
| 12 |
:return: List of surrounding times in "HH:mm" format.
|
| 13 |
"""
|
| 14 |
+
times = [item["time"] for item in time_list]
|
| 15 |
+
|
| 16 |
+
index = bisect_left(times, time)
|
| 17 |
|
| 18 |
start = max(0, index - 2)
|
| 19 |
end = min(len(time_list), index + 2)
|