Spaces:
Running
Running
Update model.py
Browse files
model.py
CHANGED
|
@@ -55,10 +55,13 @@ def smart_summarize(text, n_clusters=1):
|
|
| 55 |
|
| 56 |
# === Emotion Detection (Fixed) ===
|
| 57 |
def detect_emotion(text):
|
| 58 |
-
result = emotion_model(text)
|
| 59 |
-
if isinstance(result, list) and
|
| 60 |
return result[0]["label"]
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
# === Follow-up Q&A ===
|
| 64 |
def answer_followup(text, question, verbosity="brief"):
|
|
|
|
| 55 |
|
| 56 |
# === Emotion Detection (Fixed) ===
|
| 57 |
def detect_emotion(text):
|
| 58 |
+
result = emotion_model(text, top_k=1)
|
| 59 |
+
if isinstance(result, list) and isinstance(result[0], dict):
|
| 60 |
return result[0]["label"]
|
| 61 |
+
elif isinstance(result, dict) and "label" in result:
|
| 62 |
+
return result["label"]
|
| 63 |
+
else:
|
| 64 |
+
return "neutral"
|
| 65 |
|
| 66 |
# === Follow-up Q&A ===
|
| 67 |
def answer_followup(text, question, verbosity="brief"):
|