Spaces:
Sleeping
Sleeping
Upload drift.py
Browse files- engine/drift.py +14 -12
engine/drift.py
CHANGED
|
@@ -31,15 +31,16 @@ def get_current_mode(state):
|
|
| 31 |
trust = state.get("trust", 0.5)
|
| 32 |
openness = state.get("openness", 0.5)
|
| 33 |
|
| 34 |
-
|
|
|
|
| 35 |
return "decompensating"
|
| 36 |
-
if anxiety > 0.
|
| 37 |
return "triggered"
|
| 38 |
-
if openness < 0.
|
| 39 |
return "guarded"
|
| 40 |
-
if trust > 0.
|
| 41 |
return "trusting"
|
| 42 |
-
if anxiety < 0.
|
| 43 |
return "recovering"
|
| 44 |
return state.get("mode", "baseline")
|
| 45 |
|
|
@@ -63,20 +64,21 @@ def calculate_state_change(state, student_response):
|
|
| 63 |
advice_score = sum(1 for word in advice_words if word in response_lower)
|
| 64 |
minimizing_score = sum(1 for word in minimizing if word in response_lower)
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
|
|
|
| 68 |
|
| 69 |
changes = {
|
| 70 |
-
"trust": positive_impact * 0.
|
| 71 |
-
"anxiety": negative_impact * 0.
|
| 72 |
-
"openness": positive_impact * 0.
|
| 73 |
}
|
| 74 |
|
| 75 |
word_count = len(student_response.split())
|
| 76 |
if word_count < 5:
|
| 77 |
-
changes["trust"] -= 0.05
|
| 78 |
elif word_count > 100:
|
| 79 |
-
changes["anxiety"] += 0.05
|
| 80 |
|
| 81 |
return changes
|
| 82 |
|
|
|
|
| 31 |
trust = state.get("trust", 0.5)
|
| 32 |
openness = state.get("openness", 0.5)
|
| 33 |
|
| 34 |
+
# Raised thresholds significantly to prevent premature crisis states
|
| 35 |
+
if anxiety > 0.85: # Was 0.8 - now much harder to reach decompensating
|
| 36 |
return "decompensating"
|
| 37 |
+
if anxiety > 0.75 and trust < 0.25: # Was 0.6 and 0.3 - much higher bar for triggered
|
| 38 |
return "triggered"
|
| 39 |
+
if openness < 0.3 and trust < 0.4: # Was 0.4 and 0.5 - harder to be guarded
|
| 40 |
return "guarded"
|
| 41 |
+
if trust > 0.7 and openness > 0.7: # Was 0.6 - higher bar for trusting too
|
| 42 |
return "trusting"
|
| 43 |
+
if anxiety < 0.3 and openness > 0.6: # Was 0.4 and 0.5 - adjusted
|
| 44 |
return "recovering"
|
| 45 |
return state.get("mode", "baseline")
|
| 46 |
|
|
|
|
| 64 |
advice_score = sum(1 for word in advice_words if word in response_lower)
|
| 65 |
minimizing_score = sum(1 for word in minimizing if word in response_lower)
|
| 66 |
|
| 67 |
+
# Reduced magnitude significantly - was causing too-fast emotional escalation
|
| 68 |
+
positive_impact = (validation_score * 0.02 + open_q_score * 0.015 + empathy_score * 0.01) # Was 0.05, 0.04, 0.03
|
| 69 |
+
negative_impact = (advice_score * 0.03 + minimizing_score * 0.025) # Was 0.08, 0.06
|
| 70 |
|
| 71 |
changes = {
|
| 72 |
+
"trust": positive_impact * 0.5 - negative_impact * 0.3, # Was 0.8 and 0.5 - reduced multipliers
|
| 73 |
+
"anxiety": negative_impact * 0.3 - positive_impact * 0.2, # Was 0.5 and 0.3 - reduced
|
| 74 |
+
"openness": positive_impact * 0.3 - negative_impact * 0.15 # Was 0.4 and 0.2 - reduced
|
| 75 |
}
|
| 76 |
|
| 77 |
word_count = len(student_response.split())
|
| 78 |
if word_count < 5:
|
| 79 |
+
changes["trust"] -= 0.02 # Was 0.05 - reduced
|
| 80 |
elif word_count > 100:
|
| 81 |
+
changes["anxiety"] += 0.02 # Was 0.05 - reduced
|
| 82 |
|
| 83 |
return changes
|
| 84 |
|