Spaces:
Sleeping
Sleeping
Update ensemble.py
Browse files- ensemble.py +34 -0
ensemble.py
CHANGED
@@ -41,6 +41,37 @@ MINOR_ARCANA = {
|
|
41 |
"🌬️ Swords": ["fear", "anxious", "nervousness", "apprehensive", "guilt", "sad", "lonely", "embarrassed", "disappointed", "ashamed", "devastated", "angry", "frustrated"]
|
42 |
}
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
def run_quiz_step():
|
45 |
# Keep session history
|
46 |
if "question_index" not in st.session_state:
|
@@ -82,6 +113,9 @@ def run_quiz_step():
|
|
82 |
st.markdown("### 🃏 Your Tarot Archetype")
|
83 |
st.success(tarot)
|
84 |
|
|
|
|
|
|
|
85 |
def generate_reflection_and_prompt(user_input, detected_emotions):
|
86 |
base_emotion = detected_emotions[0][0] if detected_emotions else "something tender"
|
87 |
return f"What I hear is... you’re feeling {base_emotion}. Could you tell me more?"
|
|
|
41 |
"🌬️ Swords": ["fear", "anxious", "nervousness", "apprehensive", "guilt", "sad", "lonely", "embarrassed", "disappointed", "ashamed", "devastated", "angry", "frustrated"]
|
42 |
}
|
43 |
|
44 |
+
|
45 |
+
|
46 |
+
def detect_attachment_style(answers):
|
47 |
+
secure = avoidant = anxious = disorganized = 0
|
48 |
+
keywords = {
|
49 |
+
"secure": ["trust", "safe", "comfortable", "balance", "communicate"],
|
50 |
+
"avoidant": ["alone", "space", "suffocating", "independent", "self-reliant"],
|
51 |
+
"anxious": ["worry", "fear", "abandon", "cling", "reassurance"],
|
52 |
+
"disorganized": ["confused", "mixed", "unsafe", "trapped", "conflict"]
|
53 |
+
}
|
54 |
+
|
55 |
+
for answer in answers:
|
56 |
+
text = answer["response"].lower()
|
57 |
+
for style, terms in keywords.items():
|
58 |
+
if any(term in text for term in terms):
|
59 |
+
vars()[style] += 1
|
60 |
+
|
61 |
+
# Add emotion scoring
|
62 |
+
for answer in answers:
|
63 |
+
if "anxious" in answer["tone"]["top_emotions"]: anxious += 2
|
64 |
+
if "fear" in answer["tone"]["top_emotions"]: disorganized += 1
|
65 |
+
|
66 |
+
styles = {
|
67 |
+
"Secure": secure,
|
68 |
+
"Avoidant": avoidant,
|
69 |
+
"Anxious": anxious,
|
70 |
+
"Disorganized": disorganized
|
71 |
+
}
|
72 |
+
return max(styles.items(), key=lambda x: x[1])[0]
|
73 |
+
|
74 |
+
|
75 |
def run_quiz_step():
|
76 |
# Keep session history
|
77 |
if "question_index" not in st.session_state:
|
|
|
113 |
st.markdown("### 🃏 Your Tarot Archetype")
|
114 |
st.success(tarot)
|
115 |
|
116 |
+
|
117 |
+
|
118 |
+
|
119 |
def generate_reflection_and_prompt(user_input, detected_emotions):
|
120 |
base_emotion = detected_emotions[0][0] if detected_emotions else "something tender"
|
121 |
return f"What I hear is... you’re feeling {base_emotion}. Could you tell me more?"
|