Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
# --- Dummy Functions (replace with real logic) ---
|
4 |
+
def analyze_city(city_name):
|
5 |
+
if not city_name:
|
6 |
+
return "⚠️ Please enter a city name."
|
7 |
+
# Example dummy response
|
8 |
+
return f"📊 Analysis for {city_name}:\n- Crime Index: Moderate\n- Accident Rate: Low"
|
9 |
+
|
10 |
+
def citizen_services(service_query):
|
11 |
+
if not service_query:
|
12 |
+
return "⚠️ Please enter your request."
|
13 |
+
# Example dummy response
|
14 |
+
return f"✅ Service Request Processed:\n{service_query}"
|
15 |
+
|
16 |
+
# --- Gradio UI ---
|
17 |
+
with gr.Blocks(theme="gradio/soft") as demo:
|
18 |
+
gr.Markdown("# 🌆 City Analysis & Citizen Services AI")
|
19 |
+
|
20 |
+
with gr.Tabs():
|
21 |
+
# --- Tab 1: City Analysis ---
|
22 |
+
with gr.Tab("City Analysis"):
|
23 |
+
with gr.Row():
|
24 |
+
with gr.Column():
|
25 |
+
city_input = gr.Textbox(
|
26 |
+
label="Enter City Name",
|
27 |
+
placeholder="e.g., New York, London, Mumbai..."
|
28 |
+
)
|
29 |
+
analyze_btn = gr.Button("Analyze City")
|
30 |
+
with gr.Column():
|
31 |
+
city_output = gr.Textbox(
|
32 |
+
label="City Analysis (Crime Index & Accidents)",
|
33 |
+
lines=10
|
34 |
+
)
|
35 |
+
analyze_btn.click(analyze_city, inputs=city_input, outputs=city_output)
|
36 |
+
|
37 |
+
# --- Tab 2: Citizen Services ---
|
38 |
+
with gr.Tab("Citizen Services"):
|
39 |
+
with gr.Row():
|
40 |
+
with gr.Column():
|
41 |
+
service_input = gr.Textbox(
|
42 |
+
label="Enter Service Request",
|
43 |
+
placeholder="e.g., Report pothole, Request garbage collection..."
|
44 |
+
)
|
45 |
+
service_btn = gr.Button("Submit Request")
|
46 |
+
with gr.Column():
|
47 |
+
service_output = gr.Textbox(
|
48 |
+
label="Service Response",
|
49 |
+
lines=10
|
50 |
+
)
|
51 |
+
service_btn.click(citizen_services, inputs=service_input, outputs=service_output)
|
52 |
+
|
53 |
+
# --- Launch App ---
|
54 |
+
if __name__ == "__main__":
|
55 |
+
demo.launch()
|