Spaces:
Sleeping
Sleeping
File size: 1,374 Bytes
cec6950 d50f7e6 de3eda3 d50f7e6 de3eda3 d50f7e6 de3eda3 d50f7e6 de3eda3 d50f7e6 cec6950 e1ac721 d14765b de3eda3 cec6950 d14765b cec6950 d50f7e6 de3eda3 d50f7e6 de3eda3 d50f7e6 d14765b d50f7e6 de3eda3 d14765b e1ac721 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import gradio as gr
import pandas as pd
import os
# Load survey dataset from CSV
survey_data = None
try:
if os.path.exists("survey.csv"):
survey_data = pd.read_csv("survey.csv")
else:
# fallback fake dataset
survey_data = pd.DataFrame({
"employee": ["Aiman", "Ali", "Sara"],
"mood": ["Positive", "Negative", "Neutral"],
"recommendation": [
"Keep up the good work!",
"Take a short break to reduce stress.",
"Encourage more collaboration."
]
})
except Exception as e:
print("Error loading CSV:", str(e))
def chatbot(query):
try:
if not query or query.strip() == "":
return "⚠️ Please type a valid question."
query_lower = query.lower()
# Match employee name
for i, row in survey_data.iterrows():
if row["employee"].lower() in query_lower:
return f"✅ {row['employee']} is feeling **{row['mood']}**.\n💡 Recommendation: {row['recommendation']}"
# No match found
return "ℹ️ I don’t have data for that person. Try asking about Aiman, Ali, or Sara."
except Exception as e:
return f"🚨 Error: {str(e)}"
# Gradio Chat Interface
iface = gr.ChatInterface(fn=chatbot, title="Pulse Survey Chatbot")
iface.launch()
|