JoshuaZywoo commited on
Commit
0db3c6a
·
verified ·
1 Parent(s): b35a08e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -60,7 +60,12 @@ if st.button("Analyze Message"):
60
 
61
  # Emotion detection
62
  emotion_result = emotion_classifier(user_input)
63
- emotion_label = emotion_result[0]['label']
 
 
 
 
 
64
  emotion_score = get_emotion_score(emotion_label)
65
 
66
  # Intent detection
 
60
 
61
  # Emotion detection
62
  emotion_result = emotion_classifier(user_input)
63
+ if isinstance(emotion_result[0], list): # Handle top_k output format
64
+ emotion_data = emotion_result[0][0]
65
+ else:
66
+ emotion_data = emotion_result[0]
67
+
68
+ emotion_label = emotion_data['label']
69
  emotion_score = get_emotion_score(emotion_label)
70
 
71
  # Intent detection