Spaces:
Running
Running
OnlyBiggg
commited on
Commit
·
b24aee4
1
Parent(s):
70a8c17
fix: check time ambiguity
Browse files- app/api/v1/time.py +5 -5
- app/services/time_service.py +5 -0
app/api/v1/time.py
CHANGED
@@ -24,12 +24,12 @@ async def check_time_ambiguity(
|
|
24 |
body = await request.json()
|
25 |
body = DialogflowWebhookRequest(**body)
|
26 |
params = body.get_parameters()
|
27 |
-
|
28 |
-
if not
|
29 |
-
logger.error("Time
|
30 |
-
raise HTTPException(status_code=400, detail="Time
|
31 |
|
32 |
-
is_ambiguous = service.check_time_ambiguity(time=
|
33 |
|
34 |
return (
|
35 |
DialogflowResponseBuilder()
|
|
|
24 |
body = await request.json()
|
25 |
body = DialogflowWebhookRequest(**body)
|
26 |
params = body.get_parameters()
|
27 |
+
data = TimeRequest(**params)
|
28 |
+
if not data.time_select:
|
29 |
+
logger.error("Time is empty")
|
30 |
+
raise HTTPException(status_code=400, detail="Time is required")
|
31 |
|
32 |
+
is_ambiguous = service.check_time_ambiguity(time=data.time_select)
|
33 |
|
34 |
return (
|
35 |
DialogflowResponseBuilder()
|
app/services/time_service.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
from app.dto.response import DialogServiceResult
|
2 |
from app.services.helper import extra_time_dialogflow
|
3 |
|
@@ -15,6 +16,10 @@ class TimeService:
|
|
15 |
Returns:
|
16 |
bool: True nếu thời gian là mơ hồ, False nếu rõ ràng.
|
17 |
"""
|
|
|
|
|
|
|
|
|
18 |
time = extra_time_dialogflow(time)
|
19 |
return isinstance(time, list)
|
20 |
|
|
|
1 |
+
from loguru import logger
|
2 |
from app.dto.response import DialogServiceResult
|
3 |
from app.services.helper import extra_time_dialogflow
|
4 |
|
|
|
16 |
Returns:
|
17 |
bool: True nếu thời gian là mơ hồ, False nếu rõ ràng.
|
18 |
"""
|
19 |
+
if not time:
|
20 |
+
logger.error("Time is empty")
|
21 |
+
raise ValueError("Time is required")
|
22 |
+
|
23 |
time = extra_time_dialogflow(time)
|
24 |
return isinstance(time, list)
|
25 |
|