Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,10 +15,32 @@ if "last_login" not in st.session_state:
|
|
| 15 |
if "personalized_resources" not in st.session_state:
|
| 16 |
st.session_state.personalized_resources = []
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
resources = {
|
| 19 |
-
"stress_management": [
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
# Function to track mood
|
|
@@ -28,7 +50,7 @@ def track_mood():
|
|
| 28 |
st.session_state.mood_history.append((datetime.now().strftime("%Y-%m-%d %H:%M:%S"), mood))
|
| 29 |
st.success(f"Your mood '{mood}' has been recorded. Thank you for sharing!")
|
| 30 |
|
| 31 |
-
# Function to provide personalized
|
| 32 |
def recommend_resources():
|
| 33 |
if not st.session_state.mood_history:
|
| 34 |
st.warning("No mood data available. Please track your mood first.")
|
|
@@ -47,26 +69,75 @@ def recommend_resources():
|
|
| 47 |
|
| 48 |
st.subheader("Here are some resources tailored for you:")
|
| 49 |
for resource in st.session_state.personalized_resources:
|
| 50 |
-
st.
|
| 51 |
-
|
| 52 |
-
#
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
st.session_state.
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
-
|
| 63 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
# Main app layout
|
| 66 |
def main():
|
| 67 |
-
st.title("AfyaMind: Your Mental Health Companion")
|
| 68 |
st.sidebar.title("Menu")
|
| 69 |
-
menu_choice = st.sidebar.radio("Choose an option", ["Track Mood", "Get Personalized Resources", "
|
| 70 |
|
| 71 |
if menu_choice == "Track Mood":
|
| 72 |
st.header("Track Your Mood")
|
|
@@ -76,9 +147,8 @@ def main():
|
|
| 76 |
st.header("Personalized Resources")
|
| 77 |
recommend_resources()
|
| 78 |
|
| 79 |
-
elif menu_choice == "
|
| 80 |
-
|
| 81 |
-
check_streak()
|
| 82 |
|
| 83 |
# Run the app
|
| 84 |
if __name__ == "__main__":
|
|
|
|
| 15 |
if "personalized_resources" not in st.session_state:
|
| 16 |
st.session_state.personalized_resources = []
|
| 17 |
|
| 18 |
+
if "saved_resources" not in st.session_state:
|
| 19 |
+
st.session_state.saved_resources = []
|
| 20 |
+
|
| 21 |
+
if "liked_resources" not in st.session_state:
|
| 22 |
+
st.session_state.liked_resources = []
|
| 23 |
+
|
| 24 |
+
if "comments" not in st.session_state:
|
| 25 |
+
st.session_state.comments = {}
|
| 26 |
+
|
| 27 |
+
# Mock resources with clickable links
|
| 28 |
resources = {
|
| 29 |
+
"stress_management": [
|
| 30 |
+
{"title": "5 Ways to Manage Stress", "link": "https://example.com/stress-management", "type": "Article"},
|
| 31 |
+
{"title": "Mindfulness Techniques", "link": "https://example.com/mindfulness", "type": "Video"},
|
| 32 |
+
{"title": "Stress Relief Tips", "link": "https://example.com/stress-relief", "type": "Podcast"}
|
| 33 |
+
],
|
| 34 |
+
"mindfulness": [
|
| 35 |
+
{"title": "Introduction to Mindfulness", "link": "https://example.com/intro-mindfulness", "type": "Article"},
|
| 36 |
+
{"title": "Guided Meditation", "link": "https://example.com/guided-meditation", "type": "Video"},
|
| 37 |
+
{"title": "Daily Mindfulness Practices", "link": "https://example.com/daily-mindfulness", "type": "Podcast"}
|
| 38 |
+
],
|
| 39 |
+
"emotional_intelligence": [
|
| 40 |
+
{"title": "Understanding Emotions", "link": "https://example.com/understanding-emotions", "type": "Article"},
|
| 41 |
+
{"title": "Building Emotional Resilience", "link": "https://example.com/emotional-resilience", "type": "Video"},
|
| 42 |
+
{"title": "Emotional Intelligence 101", "link": "https://example.com/emotional-intelligence", "type": "Podcast"}
|
| 43 |
+
]
|
| 44 |
}
|
| 45 |
|
| 46 |
# Function to track mood
|
|
|
|
| 50 |
st.session_state.mood_history.append((datetime.now().strftime("%Y-%m-%d %H:%M:%S"), mood))
|
| 51 |
st.success(f"Your mood '{mood}' has been recorded. Thank you for sharing!")
|
| 52 |
|
| 53 |
+
# Function to provide personalized resources
|
| 54 |
def recommend_resources():
|
| 55 |
if not st.session_state.mood_history:
|
| 56 |
st.warning("No mood data available. Please track your mood first.")
|
|
|
|
| 69 |
|
| 70 |
st.subheader("Here are some resources tailored for you:")
|
| 71 |
for resource in st.session_state.personalized_resources:
|
| 72 |
+
st.markdown(f"**[{resource['title']}]({resource['link']})** ({resource['type']})")
|
| 73 |
+
|
| 74 |
+
# Like, Comment, Share, and Bookmark buttons
|
| 75 |
+
col1, col2, col3, col4 = st.columns(4)
|
| 76 |
+
with col1:
|
| 77 |
+
if st.button(f"π Like {resource['title']}"):
|
| 78 |
+
if resource not in st.session_state.liked_resources:
|
| 79 |
+
st.session_state.liked_resources.append(resource)
|
| 80 |
+
st.success(f"Liked {resource['title']}!")
|
| 81 |
+
with col2:
|
| 82 |
+
if st.button(f"π¬ Comment {resource['title']}"):
|
| 83 |
+
comment = st.text_input(f"Add a comment for {resource['title']}:")
|
| 84 |
+
if comment:
|
| 85 |
+
if resource['title'] not in st.session_state.comments:
|
| 86 |
+
st.session_state.comments[resource['title']] = []
|
| 87 |
+
st.session_state.comments[resource['title']].append(comment)
|
| 88 |
+
st.success("Comment added!")
|
| 89 |
+
with col3:
|
| 90 |
+
if st.button(f"π Share {resource['title']}"):
|
| 91 |
+
st.write(f"Share this link: {resource['link']}")
|
| 92 |
+
with col4:
|
| 93 |
+
if st.button(f"π Bookmark {resource['title']}"):
|
| 94 |
+
if resource not in st.session_state.saved_resources:
|
| 95 |
+
st.session_state.saved_resources.append(resource)
|
| 96 |
+
st.success(f"Bookmarked {resource['title']}!")
|
| 97 |
+
|
| 98 |
+
# Function to display user profile
|
| 99 |
+
def user_profile():
|
| 100 |
+
st.header("Your Profile")
|
| 101 |
+
|
| 102 |
+
# Mood History
|
| 103 |
+
st.subheader("Mood History")
|
| 104 |
+
if st.session_state.mood_history:
|
| 105 |
+
for timestamp, mood in st.session_state.mood_history:
|
| 106 |
+
st.write(f"{timestamp}: {mood}")
|
| 107 |
+
else:
|
| 108 |
+
st.write("No mood history available.")
|
| 109 |
|
| 110 |
+
# Saved Resources
|
| 111 |
+
st.subheader("Saved Resources")
|
| 112 |
+
if st.session_state.saved_resources:
|
| 113 |
+
for resource in st.session_state.saved_resources:
|
| 114 |
+
st.markdown(f"**[{resource['title']}]({resource['link']})** ({resource['type']})")
|
| 115 |
+
else:
|
| 116 |
+
st.write("No saved resources yet.")
|
| 117 |
|
| 118 |
+
# Liked Resources
|
| 119 |
+
st.subheader("Liked Resources")
|
| 120 |
+
if st.session_state.liked_resources:
|
| 121 |
+
for resource in st.session_state.liked_resources:
|
| 122 |
+
st.markdown(f"**[{resource['title']}]({resource['link']})** ({resource['type']})")
|
| 123 |
+
else:
|
| 124 |
+
st.write("No liked resources yet.")
|
| 125 |
+
|
| 126 |
+
# Comments
|
| 127 |
+
st.subheader("Your Comments")
|
| 128 |
+
if st.session_state.comments:
|
| 129 |
+
for resource_title, comments in st.session_state.comments.items():
|
| 130 |
+
st.write(f"**{resource_title}**:")
|
| 131 |
+
for comment in comments:
|
| 132 |
+
st.write(f"- {comment}")
|
| 133 |
+
else:
|
| 134 |
+
st.write("No comments yet.")
|
| 135 |
|
| 136 |
# Main app layout
|
| 137 |
def main():
|
| 138 |
+
st.title("AfyaMind Space: Your Mental Health Companion")
|
| 139 |
st.sidebar.title("Menu")
|
| 140 |
+
menu_choice = st.sidebar.radio("Choose an option", ["Track Mood", "Get Personalized Resources", "User Profile"])
|
| 141 |
|
| 142 |
if menu_choice == "Track Mood":
|
| 143 |
st.header("Track Your Mood")
|
|
|
|
| 147 |
st.header("Personalized Resources")
|
| 148 |
recommend_resources()
|
| 149 |
|
| 150 |
+
elif menu_choice == "User Profile":
|
| 151 |
+
user_profile()
|
|
|
|
| 152 |
|
| 153 |
# Run the app
|
| 154 |
if __name__ == "__main__":
|