Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -9,11 +9,15 @@ import io
|
|
9 |
from PIL import Image
|
10 |
from datetime import datetime
|
11 |
from transformers import pipeline as hf_pipeline # prevent name collision with gradio pipeline
|
12 |
-
def
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
# Emotion model (no retraining needed)
|
18 |
emotion_pipeline = hf_pipeline(
|
19 |
"text-classification",
|
@@ -131,13 +135,15 @@ ESCALATION_QUESTIONS = [
|
|
131 |
]
|
132 |
|
133 |
|
134 |
-
def get_emotional_tone_tag(
|
135 |
-
sadness =
|
136 |
-
joy =
|
137 |
-
neutral =
|
138 |
-
disgust =
|
139 |
-
anger =
|
140 |
-
fear =
|
|
|
|
|
141 |
# 1. Performative Regret
|
142 |
if (
|
143 |
sadness > 0.4 and
|
@@ -453,7 +459,7 @@ def analyze_single_message(text, thresholds):
|
|
453 |
label for label, score in zip(LABELS, scores)
|
454 |
if score > adjusted_thresholds[label]
|
455 |
]
|
456 |
-
tone_tag = get_emotional_tone_tag(emotion_profile, sentiment, threshold_labels,
|
457 |
|
458 |
|
459 |
top_patterns = sorted(
|
|
|
9 |
from PIL import Image
|
10 |
from datetime import datetime
|
11 |
from transformers import pipeline as hf_pipeline # prevent name collision with gradio pipeline
|
12 |
+
def get_emotional_tone_tag(emotion_profile, sentiment, patterns, abuse_score, text):
|
13 |
+
sadness = emotion_profile.get("sadness", 0)
|
14 |
+
joy = emotion_profile.get("joy", 0)
|
15 |
+
neutral = emotion_profile.get("neutral", 0)
|
16 |
+
disgust = emotion_profile.get("disgust", 0)
|
17 |
+
anger = emotion_profile.get("anger", 0)
|
18 |
+
fear = emotion_profile.get("fear", 0)
|
19 |
+
|
20 |
+
# [then all the logic for performative regret → hostile moralizing]
|
21 |
# Emotion model (no retraining needed)
|
22 |
emotion_pipeline = hf_pipeline(
|
23 |
"text-classification",
|
|
|
135 |
]
|
136 |
|
137 |
|
138 |
+
def get_emotional_tone_tag(emotion_profile, sentiment, patterns, abuse_score, text):
|
139 |
+
sadness = emotion_profile.get("sadness", 0)
|
140 |
+
joy = emotion_profile.get("joy", 0)
|
141 |
+
neutral = emotion_profile.get("neutral", 0)
|
142 |
+
disgust = emotion_profile.get("disgust", 0)
|
143 |
+
anger = emotion_profile.get("anger", 0)
|
144 |
+
fear = emotion_profile.get("fear", 0)
|
145 |
+
|
146 |
+
# [then all the logic for performative regret → hostile moralizing]
|
147 |
# 1. Performative Regret
|
148 |
if (
|
149 |
sadness > 0.4 and
|
|
|
459 |
label for label, score in zip(LABELS, scores)
|
460 |
if score > adjusted_thresholds[label]
|
461 |
]
|
462 |
+
tone_tag = get_emotional_tone_tag(emotion_profile, sentiment, threshold_labels, abuse_score, text)
|
463 |
|
464 |
|
465 |
top_patterns = sorted(
|