Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -31,12 +31,20 @@ user_input = st.text_input("How are you feeling today?", placeholder="Share what
|
|
31 |
# Check if user has entered text
|
32 |
if user_input:
|
33 |
# Run sentiment analysis to assess mood
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
-
# Generate empathetic response
|
38 |
-
bot_response = conversational_bot(user_input, max_length=150)[0]['generated_text']
|
39 |
-
|
40 |
# Display response
|
41 |
st.text_area("Bot's Response:", bot_response, height=150)
|
42 |
|
|
|
31 |
# Check if user has entered text
|
32 |
if user_input:
|
33 |
# Run sentiment analysis to assess mood
|
34 |
+
try:
|
35 |
+
sentiment = sentiment_analysis(user_input)[0]
|
36 |
+
sentiment_label = sentiment['label'].lower()
|
37 |
+
st.write(f"Sentiment detected: {sentiment_label}") # Debugging line
|
38 |
+
except Exception as e:
|
39 |
+
st.write(f"Error in sentiment analysis: {e}") # Error handling
|
40 |
+
|
41 |
+
# Generate empathetic response from the conversational bot
|
42 |
+
try:
|
43 |
+
bot_response = conversational_bot(user_input, max_length=150)[0]['generated_text']
|
44 |
+
st.write(f"Bot Response: {bot_response}") # Debugging line
|
45 |
+
except Exception as e:
|
46 |
+
st.write(f"Error generating bot response: {e}") # Error handling
|
47 |
|
|
|
|
|
|
|
48 |
# Display response
|
49 |
st.text_area("Bot's Response:", bot_response, height=150)
|
50 |
|