Update app.py
Browse files
app.py
CHANGED
|
@@ -1105,7 +1105,7 @@ def traffic_ai_agent(user_query):
|
|
| 1105 |
|
| 1106 |
response = (
|
| 1107 |
|
| 1108 |
-
"
|
| 1109 |
|
| 1110 |
f"EV vehicles detected: {ev}\n\n"
|
| 1111 |
|
|
@@ -1135,7 +1135,7 @@ def traffic_ai_agent(user_query):
|
|
| 1135 |
|
| 1136 |
response = (
|
| 1137 |
|
| 1138 |
-
"
|
| 1139 |
|
| 1140 |
f"Non-EV vehicles detected: "
|
| 1141 |
f"{non_ev}\n\n"
|
|
@@ -1166,7 +1166,7 @@ def traffic_ai_agent(user_query):
|
|
| 1166 |
|
| 1167 |
response = (
|
| 1168 |
|
| 1169 |
-
"
|
| 1170 |
|
| 1171 |
f"Total vehicles: {total}\n\n"
|
| 1172 |
|
|
@@ -1199,7 +1199,7 @@ def traffic_ai_agent(user_query):
|
|
| 1199 |
|
| 1200 |
response = (
|
| 1201 |
|
| 1202 |
-
"
|
| 1203 |
|
| 1204 |
f"EV vehicles: {ev}\n\n"
|
| 1205 |
|
|
@@ -1235,7 +1235,7 @@ def traffic_ai_agent(user_query):
|
|
| 1235 |
if daily.empty:
|
| 1236 |
|
| 1237 |
response = (
|
| 1238 |
-
"
|
| 1239 |
"is currently available."
|
| 1240 |
)
|
| 1241 |
|
|
@@ -1248,7 +1248,7 @@ def traffic_ai_agent(user_query):
|
|
| 1248 |
|
| 1249 |
response = (
|
| 1250 |
|
| 1251 |
-
"
|
| 1252 |
|
| 1253 |
f"Number of recorded days: "
|
| 1254 |
f"{len(daily)}\n\n"
|
|
@@ -1280,7 +1280,7 @@ def traffic_ai_agent(user_query):
|
|
| 1280 |
|
| 1281 |
response = (
|
| 1282 |
|
| 1283 |
-
"
|
| 1284 |
|
| 1285 |
f"Total EV vehicles: {ev}\n\n"
|
| 1286 |
|
|
@@ -1309,7 +1309,7 @@ def traffic_ai_agent(user_query):
|
|
| 1309 |
|
| 1310 |
response = (
|
| 1311 |
|
| 1312 |
-
"
|
| 1313 |
|
| 1314 |
f"Total vehicles detected: {total}\n\n"
|
| 1315 |
|
|
@@ -1346,7 +1346,7 @@ def traffic_ai_agent(user_query):
|
|
| 1346 |
|
| 1347 |
response = (
|
| 1348 |
|
| 1349 |
-
"
|
| 1350 |
|
| 1351 |
f"EV vehicles detected: {ev}\n\n"
|
| 1352 |
|
|
@@ -1381,18 +1381,18 @@ def traffic_ai_agent(user_query):
|
|
| 1381 |
|
| 1382 |
response = (
|
| 1383 |
|
| 1384 |
-
"
|
| 1385 |
|
| 1386 |
-
f"
|
| 1387 |
|
| 1388 |
-
f"
|
| 1389 |
|
| 1390 |
-
f"
|
| 1391 |
|
| 1392 |
-
f"
|
| 1393 |
-
f"{ev_percentage:.2f}%\n
|
| 1394 |
|
| 1395 |
-
f"
|
| 1396 |
|
| 1397 |
)
|
| 1398 |
|
|
@@ -1409,10 +1409,10 @@ def traffic_ai_agent(user_query):
|
|
| 1409 |
|
| 1410 |
response = (
|
| 1411 |
|
| 1412 |
-
"
|
| 1413 |
|
| 1414 |
"I can analyse the vehicle database. "
|
| 1415 |
-
"Try asking:\n
|
| 1416 |
|
| 1417 |
"โข How many EV vehicles were detected?\n"
|
| 1418 |
|
|
@@ -2056,17 +2056,17 @@ with gr.Blocks(
|
|
| 2056 |
|
| 2057 |
|
| 2058 |
ev_box = gr.Textbox(
|
| 2059 |
-
label="
|
| 2060 |
)
|
| 2061 |
|
| 2062 |
|
| 2063 |
non_ev_box = gr.Textbox(
|
| 2064 |
-
label="
|
| 2065 |
)
|
| 2066 |
|
| 2067 |
|
| 2068 |
discount_box = gr.Textbox(
|
| 2069 |
-
label="
|
| 2070 |
)
|
| 2071 |
|
| 2072 |
|
|
@@ -2075,7 +2075,7 @@ with gr.Blocks(
|
|
| 2075 |
# ====================================================
|
| 2076 |
|
| 2077 |
gr.Markdown(
|
| 2078 |
-
"##
|
| 2079 |
)
|
| 2080 |
|
| 2081 |
|
|
@@ -2114,12 +2114,12 @@ with gr.Blocks(
|
|
| 2114 |
# ========================================================
|
| 2115 |
|
| 2116 |
with gr.Tab(
|
| 2117 |
-
"
|
| 2118 |
):
|
| 2119 |
|
| 2120 |
|
| 2121 |
gr.Markdown(
|
| 2122 |
-
"##
|
| 2123 |
)
|
| 2124 |
|
| 2125 |
|
|
@@ -2158,7 +2158,7 @@ analytics operation.
|
|
| 2158 |
|
| 2159 |
ask_button = gr.Button(
|
| 2160 |
|
| 2161 |
-
"
|
| 2162 |
|
| 2163 |
variant="primary",
|
| 2164 |
|
|
@@ -2239,13 +2239,12 @@ analytics operation.
|
|
| 2239 |
|
| 2240 |
gr.Markdown(
|
| 2241 |
"""
|
| 2242 |
-
###
|
| 2243 |
|
| 2244 |
**Traffic**
|
| 2245 |
- How many vehicles were detected?
|
| 2246 |
- What is the total traffic?
|
| 2247 |
- Show daily traffic trend.
|
| 2248 |
-
|
| 2249 |
**EV Analysis**
|
| 2250 |
- How many EV vehicles were detected?
|
| 2251 |
- How many Non-EV vehicles are there?
|
|
@@ -2264,7 +2263,6 @@ analytics operation.
|
|
| 2264 |
"""
|
| 2265 |
)
|
| 2266 |
|
| 2267 |
-
|
| 2268 |
# ========================================================
|
| 2269 |
# TAB 3 - ADMIN / DATABASE
|
| 2270 |
# ========================================================
|
|
@@ -2292,12 +2290,12 @@ analytics operation.
|
|
| 2292 |
|
| 2293 |
|
| 2294 |
refresh_button = gr.Button(
|
| 2295 |
-
"
|
| 2296 |
)
|
| 2297 |
|
| 2298 |
|
| 2299 |
refresh_graph_button = gr.Button(
|
| 2300 |
-
"
|
| 2301 |
)
|
| 2302 |
|
| 2303 |
|
|
|
|
| 1105 |
|
| 1106 |
response = (
|
| 1107 |
|
| 1108 |
+
"AI TRAFFIC ANALYSIS\n\n"
|
| 1109 |
|
| 1110 |
f"EV vehicles detected: {ev}\n\n"
|
| 1111 |
|
|
|
|
| 1135 |
|
| 1136 |
response = (
|
| 1137 |
|
| 1138 |
+
"AI TRAFFIC ANALYSIS\n\n"
|
| 1139 |
|
| 1140 |
f"Non-EV vehicles detected: "
|
| 1141 |
f"{non_ev}\n\n"
|
|
|
|
| 1166 |
|
| 1167 |
response = (
|
| 1168 |
|
| 1169 |
+
" AI EV ANALYSIS\n\n"
|
| 1170 |
|
| 1171 |
f"Total vehicles: {total}\n\n"
|
| 1172 |
|
|
|
|
| 1199 |
|
| 1200 |
response = (
|
| 1201 |
|
| 1202 |
+
" AI INCENTIVE ANALYSIS\n\n"
|
| 1203 |
|
| 1204 |
f"EV vehicles: {ev}\n\n"
|
| 1205 |
|
|
|
|
| 1235 |
if daily.empty:
|
| 1236 |
|
| 1237 |
response = (
|
| 1238 |
+
" No daily traffic data "
|
| 1239 |
"is currently available."
|
| 1240 |
)
|
| 1241 |
|
|
|
|
| 1248 |
|
| 1249 |
response = (
|
| 1250 |
|
| 1251 |
+
" DAILY TRAFFIC ANALYSIS\n\n"
|
| 1252 |
|
| 1253 |
f"Number of recorded days: "
|
| 1254 |
f"{len(daily)}\n\n"
|
|
|
|
| 1280 |
|
| 1281 |
response = (
|
| 1282 |
|
| 1283 |
+
" EV TRAFFIC TREND\n\n"
|
| 1284 |
|
| 1285 |
f"Total EV vehicles: {ev}\n\n"
|
| 1286 |
|
|
|
|
| 1309 |
|
| 1310 |
response = (
|
| 1311 |
|
| 1312 |
+
" TRAFFIC ANALYSIS\n\n"
|
| 1313 |
|
| 1314 |
f"Total vehicles detected: {total}\n\n"
|
| 1315 |
|
|
|
|
| 1346 |
|
| 1347 |
response = (
|
| 1348 |
|
| 1349 |
+
" AI ENVIRONMENTAL ANALYSIS\n\n"
|
| 1350 |
|
| 1351 |
f"EV vehicles detected: {ev}\n\n"
|
| 1352 |
|
|
|
|
| 1381 |
|
| 1382 |
response = (
|
| 1383 |
|
| 1384 |
+
"SMART TRAFFIC AI SUMMARY\n"
|
| 1385 |
|
| 1386 |
+
f"Total Vehicles: {total}\n"
|
| 1387 |
|
| 1388 |
+
f" EV Vehicles: {ev}\n"
|
| 1389 |
|
| 1390 |
+
f"Non-EV Vehicles: {non_ev}\n"
|
| 1391 |
|
| 1392 |
+
f" EV Percentage: "
|
| 1393 |
+
f"{ev_percentage:.2f}%\n"
|
| 1394 |
|
| 1395 |
+
f"Total Discount: โน{discount}"
|
| 1396 |
|
| 1397 |
)
|
| 1398 |
|
|
|
|
| 1409 |
|
| 1410 |
response = (
|
| 1411 |
|
| 1412 |
+
"Smart Traffic AI Assistant\n\n"
|
| 1413 |
|
| 1414 |
"I can analyse the vehicle database. "
|
| 1415 |
+
"Try asking:\n"
|
| 1416 |
|
| 1417 |
"โข How many EV vehicles were detected?\n"
|
| 1418 |
|
|
|
|
| 2056 |
|
| 2057 |
|
| 2058 |
ev_box = gr.Textbox(
|
| 2059 |
+
label="EV Vehicles"
|
| 2060 |
)
|
| 2061 |
|
| 2062 |
|
| 2063 |
non_ev_box = gr.Textbox(
|
| 2064 |
+
label="Non-EV Vehicles"
|
| 2065 |
)
|
| 2066 |
|
| 2067 |
|
| 2068 |
discount_box = gr.Textbox(
|
| 2069 |
+
label="Total Discount"
|
| 2070 |
)
|
| 2071 |
|
| 2072 |
|
|
|
|
| 2075 |
# ====================================================
|
| 2076 |
|
| 2077 |
gr.Markdown(
|
| 2078 |
+
"## Traffic Analytics Dashboard"
|
| 2079 |
)
|
| 2080 |
|
| 2081 |
|
|
|
|
| 2114 |
# ========================================================
|
| 2115 |
|
| 2116 |
with gr.Tab(
|
| 2117 |
+
"Agentic AI Dashboard"
|
| 2118 |
):
|
| 2119 |
|
| 2120 |
|
| 2121 |
gr.Markdown(
|
| 2122 |
+
"## Agentic AI Traffic Analytics Assistant"
|
| 2123 |
)
|
| 2124 |
|
| 2125 |
|
|
|
|
| 2158 |
|
| 2159 |
ask_button = gr.Button(
|
| 2160 |
|
| 2161 |
+
"Ask AI",
|
| 2162 |
|
| 2163 |
variant="primary",
|
| 2164 |
|
|
|
|
| 2239 |
|
| 2240 |
gr.Markdown(
|
| 2241 |
"""
|
| 2242 |
+
### Suggested Questions
|
| 2243 |
|
| 2244 |
**Traffic**
|
| 2245 |
- How many vehicles were detected?
|
| 2246 |
- What is the total traffic?
|
| 2247 |
- Show daily traffic trend.
|
|
|
|
| 2248 |
**EV Analysis**
|
| 2249 |
- How many EV vehicles were detected?
|
| 2250 |
- How many Non-EV vehicles are there?
|
|
|
|
| 2263 |
"""
|
| 2264 |
)
|
| 2265 |
|
|
|
|
| 2266 |
# ========================================================
|
| 2267 |
# TAB 3 - ADMIN / DATABASE
|
| 2268 |
# ========================================================
|
|
|
|
| 2290 |
|
| 2291 |
|
| 2292 |
refresh_button = gr.Button(
|
| 2293 |
+
"Refresh Database"
|
| 2294 |
)
|
| 2295 |
|
| 2296 |
|
| 2297 |
refresh_graph_button = gr.Button(
|
| 2298 |
+
"Refresh Dashboard"
|
| 2299 |
)
|
| 2300 |
|
| 2301 |
|