Madiharehan commited on
Commit
5f100b2
Β·
verified Β·
1 Parent(s): f995b84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
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
- if sentiment in ['NEGATIVE', 'NEUTRAL']:
16
- return "Stay positive! 🌟 You can handle anything that comes your way."
17
- return "You're on the right track! Keep shining! 🌞"
 
 
 
 
 
 
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()