Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Emotion classifier
|
5 |
emotion_analyzer = pipeline("text-classification", model="distilbert-base-uncased")
|
6 |
|
7 |
# Enhanced Suggestion Database with resources
|
@@ -67,8 +67,8 @@ def main():
|
|
67 |
question_2 = st.text_input("What's something that is currently on your mind?")
|
68 |
question_3 = st.text_input("Do you feel overwhelmed or calm right now?")
|
69 |
|
|
|
70 |
if question_1 and question_2 and question_3:
|
71 |
-
# Step 2: Analyze sentiment of responses
|
72 |
text_to_analyze = f"{question_1} {question_2} {question_3}"
|
73 |
analysis_result = emotion_analyzer(text_to_analyze)
|
74 |
emotion = analysis_result[0]['label'] # Get the emotion from the analysis result
|
@@ -85,6 +85,8 @@ def main():
|
|
85 |
|
86 |
# Step 3: Suggest activities, articles, and videos
|
87 |
resources = suggest_activity({emotion: 1})
|
|
|
|
|
88 |
st.write("Suggestions:")
|
89 |
for suggestion in resources["suggestions"]:
|
90 |
st.write(f"- {suggestion}")
|
@@ -96,7 +98,8 @@ def main():
|
|
96 |
st.write("Videos:")
|
97 |
for video in resources["videos"]:
|
98 |
st.write(f"- [{video['title']}]({video['url']})")
|
|
|
|
|
99 |
|
100 |
if __name__ == "__main__":
|
101 |
main()
|
102 |
-
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Emotion classifier (use a pre-trained model from Hugging Face)
|
5 |
emotion_analyzer = pipeline("text-classification", model="distilbert-base-uncased")
|
6 |
|
7 |
# Enhanced Suggestion Database with resources
|
|
|
67 |
question_2 = st.text_input("What's something that is currently on your mind?")
|
68 |
question_3 = st.text_input("Do you feel overwhelmed or calm right now?")
|
69 |
|
70 |
+
# Step 2: Analyze sentiment of responses (only proceed if all questions are answered)
|
71 |
if question_1 and question_2 and question_3:
|
|
|
72 |
text_to_analyze = f"{question_1} {question_2} {question_3}"
|
73 |
analysis_result = emotion_analyzer(text_to_analyze)
|
74 |
emotion = analysis_result[0]['label'] # Get the emotion from the analysis result
|
|
|
85 |
|
86 |
# Step 3: Suggest activities, articles, and videos
|
87 |
resources = suggest_activity({emotion: 1})
|
88 |
+
|
89 |
+
# Display suggestions, articles, and videos
|
90 |
st.write("Suggestions:")
|
91 |
for suggestion in resources["suggestions"]:
|
92 |
st.write(f"- {suggestion}")
|
|
|
98 |
st.write("Videos:")
|
99 |
for video in resources["videos"]:
|
100 |
st.write(f"- [{video['title']}]({video['url']})")
|
101 |
+
else:
|
102 |
+
st.write("Please answer all three questions to receive suggestions.")
|
103 |
|
104 |
if __name__ == "__main__":
|
105 |
main()
|
|