Spaces:
Sleeping
Sleeping
OnlyBiggg commited on
Commit ·
0eb84a9
1
Parent(s): 4009c8b
fix time
Browse files
app/dialogflow/api/v1/dialogflow.py
CHANGED
|
@@ -65,9 +65,7 @@ async def confirm(request: Request):
|
|
| 65 |
parameters = {}
|
| 66 |
|
| 67 |
if isinstance(time, list):
|
| 68 |
-
|
| 69 |
-
parameters["is_time_ambiguous"] = True
|
| 70 |
-
return DialogFlowResponseAPI(parameters=parameters)
|
| 71 |
|
| 72 |
ticket_number = int(raw_ticket_number) if raw_ticket_number else 1
|
| 73 |
date = dialog_service.to_datetime_from_Dialogflow(raw_date)
|
|
@@ -397,7 +395,7 @@ async def is_valid_select_trip(request: Request) -> Response:
|
|
| 397 |
}
|
| 398 |
return DialogFlowResponseAPI(parameters=parameters)
|
| 399 |
|
| 400 |
-
@router.post('/trip/check-
|
| 401 |
async def check_time_ambiguous(request: Request) -> Response:
|
| 402 |
try:
|
| 403 |
body = await request.json()
|
|
@@ -405,14 +403,52 @@ async def check_time_ambiguous(request: Request) -> Response:
|
|
| 405 |
parameters = session_info.get("parameters")
|
| 406 |
time = parameters.get("time-select")
|
| 407 |
|
| 408 |
-
text = []
|
| 409 |
-
payload = {}
|
| 410 |
parameters = {}
|
| 411 |
|
| 412 |
time = extra_time_dialogflow(time)
|
| 413 |
-
|
| 414 |
-
|
|
|
|
| 415 |
parameters["is_time_ambiguous"] = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 416 |
text = [f"Quý khách dự định đi vào lúc"]
|
| 417 |
payload={
|
| 418 |
"richContent": [
|
|
@@ -429,7 +465,7 @@ async def check_time_ambiguous(request: Request) -> Response:
|
|
| 429 |
else:
|
| 430 |
parameters["is_time_ambiguous"] = None
|
| 431 |
|
| 432 |
-
return DialogFlowResponseAPI(text=text,
|
| 433 |
|
| 434 |
except Exception as e:
|
| 435 |
print(e)
|
|
|
|
| 65 |
parameters = {}
|
| 66 |
|
| 67 |
if isinstance(time, list):
|
| 68 |
+
return DialogFlowResponseAPI()
|
|
|
|
|
|
|
| 69 |
|
| 70 |
ticket_number = int(raw_ticket_number) if raw_ticket_number else 1
|
| 71 |
date = dialog_service.to_datetime_from_Dialogflow(raw_date)
|
|
|
|
| 395 |
}
|
| 396 |
return DialogFlowResponseAPI(parameters=parameters)
|
| 397 |
|
| 398 |
+
@router.post('/trip/check-time-ambiguous')
|
| 399 |
async def check_time_ambiguous(request: Request) -> Response:
|
| 400 |
try:
|
| 401 |
body = await request.json()
|
|
|
|
| 403 |
parameters = session_info.get("parameters")
|
| 404 |
time = parameters.get("time-select")
|
| 405 |
|
|
|
|
|
|
|
| 406 |
parameters = {}
|
| 407 |
|
| 408 |
time = extra_time_dialogflow(time)
|
| 409 |
+
|
| 410 |
+
|
| 411 |
+
if isinstance(time, list) or time is None:
|
| 412 |
parameters["is_time_ambiguous"] = True
|
| 413 |
+
# text = [f"Quý khách dự định đi vào lúc"]
|
| 414 |
+
# payload={
|
| 415 |
+
# "richContent": [
|
| 416 |
+
# [
|
| 417 |
+
# {
|
| 418 |
+
# "type": "chips",
|
| 419 |
+
# "options": [
|
| 420 |
+
# {"text": item} for item in (time)
|
| 421 |
+
# ]
|
| 422 |
+
# }
|
| 423 |
+
# ]
|
| 424 |
+
# ]
|
| 425 |
+
# }
|
| 426 |
+
else:
|
| 427 |
+
parameters["is_time_ambiguous"] = None
|
| 428 |
+
|
| 429 |
+
return DialogFlowResponseAPI(parameters=parameters)
|
| 430 |
+
|
| 431 |
+
except Exception as e:
|
| 432 |
+
print(e)
|
| 433 |
+
return DialogFlowResponseAPI(text=["Hệ thống xảy ra lỗi. Quý khách vui lòng thử lại sau hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."])
|
| 434 |
+
@router.post('/trip/select-time-ambiguous')
|
| 435 |
+
async def select_time(request: Request) -> Response:
|
| 436 |
+
try:
|
| 437 |
+
body = await request.json()
|
| 438 |
+
session_info = body.get("sessionInfo", {})
|
| 439 |
+
parameters = session_info.get("parameters")
|
| 440 |
+
time = parameters.get("time-select")
|
| 441 |
+
|
| 442 |
+
parameters = {}
|
| 443 |
+
|
| 444 |
+
time = extra_time_dialogflow(time)
|
| 445 |
+
|
| 446 |
+
text = []
|
| 447 |
+
|
| 448 |
+
if time is None:
|
| 449 |
+
text = ["Quý khách vui lòng chỉ định thời gian đi cụ thể trong ngày?"]
|
| 450 |
+
|
| 451 |
+
elif isinstance(time, list):
|
| 452 |
text = [f"Quý khách dự định đi vào lúc"]
|
| 453 |
payload={
|
| 454 |
"richContent": [
|
|
|
|
| 465 |
else:
|
| 466 |
parameters["is_time_ambiguous"] = None
|
| 467 |
|
| 468 |
+
return DialogFlowResponseAPI(text=text,payload=payload,parameters=parameters)
|
| 469 |
|
| 470 |
except Exception as e:
|
| 471 |
print(e)
|