Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -50,6 +50,12 @@ def detect_anomaly(csv_file):
|
|
50 |
return "β
No significant anomalies detected."
|
51 |
return "β οΈ Anomalies found:\\n" + anomalies.to_string(index=False)
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
# Gradio Interface
|
55 |
app = gr.TabbedInterface(
|
@@ -58,9 +64,10 @@ app = gr.TabbedInterface(
|
|
58 |
gr.Interface(fn=citizen_feedback, inputs=gr.Textbox(lines=2, label="Describe the Issue"), outputs="text", title="π£ Citizen Feedback"),
|
59 |
gr.Interface(fn=kpi_forecasting, inputs=gr.File(label="Upload CSV with Year and Value columns"), outputs="text", title="π KPI Forecasting"),
|
60 |
gr.Interface(fn=eco_tips, inputs=gr.Textbox(lines=2, label="Keyword (e.g. Plastic, Solar)"), outputs="text", title="π± Eco Tips Generator"),
|
61 |
-
gr.Interface(fn=detect_anomaly, inputs=gr.File(label="Upload CSV with 'value' column"), outputs="text", title="π¨ Anomaly Detection")
|
|
|
62 |
],
|
63 |
-
tab_names=["Summarize", "Feedback", "Forecast", "Eco Tips", "Anomalies"],
|
64 |
title="π Sustainable Smart City Assistant"
|
65 |
)
|
66 |
|
|
|
50 |
return "β
No significant anomalies detected."
|
51 |
return "β οΈ Anomalies found:\\n" + anomalies.to_string(index=False)
|
52 |
|
53 |
+
# module 6: chat assistant
|
54 |
+
def chat_assistant(question):
|
55 |
+
prompt = f"Answer this smart city sustainability question:\n\nQ: {question}\nA:"
|
56 |
+
result = llm(prompt, max_new_tokens=200, temperature=0.7)[0]["generated_text"]
|
57 |
+
return result.replace(prompt, "").strip()
|
58 |
+
|
59 |
|
60 |
# Gradio Interface
|
61 |
app = gr.TabbedInterface(
|
|
|
64 |
gr.Interface(fn=citizen_feedback, inputs=gr.Textbox(lines=2, label="Describe the Issue"), outputs="text", title="π£ Citizen Feedback"),
|
65 |
gr.Interface(fn=kpi_forecasting, inputs=gr.File(label="Upload CSV with Year and Value columns"), outputs="text", title="π KPI Forecasting"),
|
66 |
gr.Interface(fn=eco_tips, inputs=gr.Textbox(lines=2, label="Keyword (e.g. Plastic, Solar)"), outputs="text", title="π± Eco Tips Generator"),
|
67 |
+
gr.Interface(fn=detect_anomaly, inputs=gr.File(label="Upload CSV with 'value' column"), outputs="text", title="π¨ Anomaly Detection"),
|
68 |
+
gr.Interface(fn=chat_assistant, inputs=gr.Textbox(lines=2, label="Ask your question"), outputs="text", title="π¬ Smart City Chat")
|
69 |
],
|
70 |
+
tab_names=["Summarize", "Feedback", "Forecast", "Eco Tips", "Anomalies", "Chat"],
|
71 |
title="π Sustainable Smart City Assistant"
|
72 |
)
|
73 |
|