Spaces:
Sleeping
Sleeping
OnlyBiggg
commited on
Commit
·
b24ccd7
1
Parent(s):
027c2c7
fix
Browse files- app/api/routes.py +12 -11
- app/services/api.py +1 -1
- app/types/Respone.py +0 -3
app/api/routes.py
CHANGED
@@ -224,17 +224,18 @@ async def booking_trip(request: Request) -> Response:
|
|
224 |
trips = []
|
225 |
routes_name = []
|
226 |
for trip in data:
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
|
|
238 |
text = ["Quý khách vui lòng lựa chọn chuyến xe\n" + "\n".join(f"{i+1}. {name}" for i, name in enumerate(routes_name))]
|
239 |
payload={
|
240 |
"richContent": [
|
|
|
224 |
trips = []
|
225 |
routes_name = []
|
226 |
for trip in data:
|
227 |
+
if ticket_count <= trip["empty_seat_quantity"]:
|
228 |
+
route = f"{trip['route']['origin_hub_name']} => {trip['route']['dest_hub_name']}"
|
229 |
+
if trip["route"] and route not in routes_name:
|
230 |
+
routes_name.append(f"{trip['route']['origin_hub_name']} => {trip['route']['dest_hub_name']}")
|
231 |
+
trips.append({
|
232 |
+
"route_name": f"{trip['route']['origin_hub_name']} => {trip['route']['dest_hub_name']}",
|
233 |
+
"route_id": trip["route_id"],
|
234 |
+
"id": trip["id"],
|
235 |
+
"departure_date": trip["raw_departure_date"],
|
236 |
+
"departure_time": trip["raw_departure_time"],
|
237 |
+
"kind": trip["seat_type_name"]
|
238 |
+
})
|
239 |
text = ["Quý khách vui lòng lựa chọn chuyến xe\n" + "\n".join(f"{i+1}. {name}" for i, name in enumerate(routes_name))]
|
240 |
payload={
|
241 |
"richContent": [
|
app/services/api.py
CHANGED
@@ -2,7 +2,7 @@ import httpx
|
|
2 |
from app.core.config import settings
|
3 |
from typing import Optional, Dict, Any
|
4 |
|
5 |
-
API_BASE_URL = settings.API_BASE_URL
|
6 |
|
7 |
async def get(endpoint: str, params: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, str]] = None):
|
8 |
"""Gọi API GET"""
|
|
|
2 |
from app.core.config import settings
|
3 |
from typing import Optional, Dict, Any
|
4 |
|
5 |
+
API_BASE_URL = settings.API_BASE_URL
|
6 |
|
7 |
async def get(endpoint: str, params: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, str]] = None):
|
8 |
"""Gọi API GET"""
|
app/types/Respone.py
CHANGED
@@ -24,9 +24,6 @@ class DialogflowResponse(BaseModel):
|
|
24 |
sessionInfo: Optional[SessionInfo] = None
|
25 |
|
26 |
def DialogFlowResponseAPI(text: List[str] = None, payload: Optional[Dict[str, Any]] = None, parameters: Optional[Dict[str, Any]] = None):
|
27 |
-
"""
|
28 |
-
Hàm tạo JSON response cho Dialogflow CX, hỗ trợ payload tùy chỉnh.
|
29 |
-
"""
|
30 |
|
31 |
messages = []
|
32 |
if text:
|
|
|
24 |
sessionInfo: Optional[SessionInfo] = None
|
25 |
|
26 |
def DialogFlowResponseAPI(text: List[str] = None, payload: Optional[Dict[str, Any]] = None, parameters: Optional[Dict[str, Any]] = None):
|
|
|
|
|
|
|
27 |
|
28 |
messages = []
|
29 |
if text:
|