tarrasyed19472007 commited on
Commit
bc67c53
Β·
verified Β·
1 Parent(s): 1fda220

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -40,7 +40,7 @@ suggestion_database = {
40
  }
41
  }
42
 
43
- # Function to fetch relevant resources
44
  def get_relevant_resources(emotion):
45
  resources = suggestion_database.get(emotion, {})
46
  return resources.get("suggestions", []), resources.get("articles", []), resources.get("videos", [])
@@ -63,7 +63,7 @@ def predict_emotion_single(response, emotion_analyzer):
63
  if emotion_analyzer is None:
64
  st.error("Model not loaded. Please try reloading the app.")
65
  return {"Error": "Emotion analyzer model not initialized. Please check model loading."}
66
-
67
  try:
68
  result = emotion_analyzer([response])
69
  return {res["label"]: round(res["score"], 4) for res in result}
@@ -72,12 +72,8 @@ def predict_emotion_single(response, emotion_analyzer):
72
  return {"Error": f"Prediction failed: {e}"}
73
 
74
  # Streamlit App Layout
75
- st.title("Emotion Prediction App: Your Personal Wellness Assistant")
76
-
77
- st.write("**How it works:**")
78
- st.write("- Enter your thoughts or feelings.")
79
- st.write("- Our AI analyzes your text to predict your emotional state.")
80
- st.write("- Receive personalized suggestions to improve your well-being.")
81
 
82
  # Define questions for the user
83
  questions = [
@@ -113,23 +109,23 @@ for i, question in enumerate(questions, start=1):
113
  responses[question] = (user_response, analysis)
114
  st.write(f"**Your Response**: {user_response}")
115
  st.write(f"**Emotion Analysis**: {analysis}")
116
-
117
  # Based on the emotion, suggest activities, articles, and videos
118
  max_emotion = max(analysis, key=analysis.get) if analysis else "neutral"
119
  suggestions, articles, videos = get_relevant_resources(max_emotion)
120
-
121
  if suggestions:
122
  st.write(f"### 🧘 Suggested Activity: {suggestions[0]}")
123
  else:
124
  st.write("### 🧘 No suggestions available at the moment.")
125
-
126
  if articles:
127
  st.write(f"### πŸ“š Suggested Articles:")
128
  for article in articles:
129
  st.write(f"[{article['title']}]({article['url']})")
130
  else:
131
  st.write("### πŸ“š No articles available at the moment.")
132
-
133
  if videos:
134
  st.write(f"### πŸŽ₯ Suggested Videos:")
135
  for video in videos:
 
40
  }
41
  }
42
 
43
+ # Function to fetch relevant resources (placeholder - needs actual API calls or database)
44
  def get_relevant_resources(emotion):
45
  resources = suggestion_database.get(emotion, {})
46
  return resources.get("suggestions", []), resources.get("articles", []), resources.get("videos", [])
 
63
  if emotion_analyzer is None:
64
  st.error("Model not loaded. Please try reloading the app.")
65
  return {"Error": "Emotion analyzer model not initialized. Please check model loading."}
66
+
67
  try:
68
  result = emotion_analyzer([response])
69
  return {res["label"]: round(res["score"], 4) for res in result}
 
72
  return {"Error": f"Prediction failed: {e}"}
73
 
74
  # Streamlit App Layout
75
+ st.title("Behavior Prediction App")
76
+ st.write("Enter your thoughts or feelings, and let the app predict your emotional states.")
 
 
 
 
77
 
78
  # Define questions for the user
79
  questions = [
 
109
  responses[question] = (user_response, analysis)
110
  st.write(f"**Your Response**: {user_response}")
111
  st.write(f"**Emotion Analysis**: {analysis}")
112
+
113
  # Based on the emotion, suggest activities, articles, and videos
114
  max_emotion = max(analysis, key=analysis.get) if analysis else "neutral"
115
  suggestions, articles, videos = get_relevant_resources(max_emotion)
116
+
117
  if suggestions:
118
  st.write(f"### 🧘 Suggested Activity: {suggestions[0]}")
119
  else:
120
  st.write("### 🧘 No suggestions available at the moment.")
121
+
122
  if articles:
123
  st.write(f"### πŸ“š Suggested Articles:")
124
  for article in articles:
125
  st.write(f"[{article['title']}]({article['url']})")
126
  else:
127
  st.write("### πŸ“š No articles available at the moment.")
128
+
129
  if videos:
130
  st.write(f"### πŸŽ₯ Suggested Videos:")
131
  for video in videos: