Update app.py
Browse files
app.py
CHANGED
@@ -10,11 +10,17 @@ sentiment_model = load_model()
|
|
10 |
# Define the function to analyze sentiment
|
11 |
def analyze_sentiment(user_input):
|
12 |
result = sentiment_model(user_input)[0]
|
13 |
-
sentiment = result['label']
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
# Gradio UI
|
20 |
def chatbot_ui():
|
@@ -32,4 +38,3 @@ def chatbot_ui():
|
|
32 |
# Launch the interface
|
33 |
if __name__ == "__main__":
|
34 |
chatbot_ui().launch()
|
35 |
-
|
|
|
10 |
# Define the function to analyze sentiment
|
11 |
def analyze_sentiment(user_input):
|
12 |
result = sentiment_model(user_input)[0]
|
13 |
+
sentiment = result['label'].lower() # Convert to lowercase for easier comparison
|
14 |
|
15 |
+
# Customize messages based on detected sentiment
|
16 |
+
if sentiment == 'negative':
|
17 |
+
return "Mood Detected: Negative π\n\nStay positive! π Remember, tough times don't last, but tough people do!"
|
18 |
+
elif sentiment == 'neutral':
|
19 |
+
return "Mood Detected: Neutral π\n\nIt's good to reflect on steady days. Keep your goals in mind, and stay motivated!"
|
20 |
+
elif sentiment == 'positive':
|
21 |
+
return "Mood Detected: Positive π\n\nYou're on the right track! Keep shining! π"
|
22 |
+
else:
|
23 |
+
return "Mood Detected: Unknown π€\n\nKeep going, you're doing great!"
|
24 |
|
25 |
# Gradio UI
|
26 |
def chatbot_ui():
|
|
|
38 |
# Launch the interface
|
39 |
if __name__ == "__main__":
|
40 |
chatbot_ui().launch()
|
|