Spaces:
Sleeping
Sleeping
Update env_tasks.py
Browse files- env_tasks.py +26 -25
env_tasks.py
CHANGED
|
@@ -10,22 +10,20 @@ from env_models import (
|
|
| 10 |
EscalationDecision,
|
| 11 |
)
|
| 12 |
|
| 13 |
-
# βββ
|
| 14 |
-
|
|
|
|
| 15 |
def _clamp(score: float) -> float:
|
| 16 |
-
|
| 17 |
-
return 0.99
|
| 18 |
-
if score <= 0.0:
|
| 19 |
-
return 0.01
|
| 20 |
-
return score
|
| 21 |
-
|
| 22 |
|
| 23 |
-
# βββ TICKETS βββββββββββββββββββββββββββββββββββββββββββ
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
TICKET_EASY = TicketObservation(
|
| 26 |
-
ticket_id="
|
| 27 |
-
subject="Laptop not
|
| 28 |
-
body="
|
| 29 |
reporter_name="User",
|
| 30 |
reporter_role="Employee",
|
| 31 |
system_info="Windows",
|
|
@@ -41,8 +39,9 @@ TICKET_MEDIUM = TICKET_EASY
|
|
| 41 |
TICKET_HARD = TICKET_EASY
|
| 42 |
|
| 43 |
|
| 44 |
-
# βββ
|
| 45 |
-
|
|
|
|
| 46 |
def grade_easy(action: TriageAction) -> Tuple[float, Dict[str, Any]]:
|
| 47 |
score = 0.0
|
| 48 |
breakdown = {}
|
|
@@ -53,12 +52,12 @@ def grade_easy(action: TriageAction) -> Tuple[float, Dict[str, Any]]:
|
|
| 53 |
if action.priority in {TicketPriority.HIGH, TicketPriority.CRITICAL}:
|
| 54 |
score += 0.25
|
| 55 |
|
| 56 |
-
if len(action.response) > 10:
|
| 57 |
score += 0.15
|
| 58 |
|
| 59 |
score = _clamp(score)
|
| 60 |
breakdown["score"] = score
|
| 61 |
-
return score, breakdown
|
| 62 |
|
| 63 |
|
| 64 |
def grade_medium(action: TriageAction) -> Tuple[float, Dict[str, Any]]:
|
|
@@ -77,12 +76,12 @@ def grade_medium(action: TriageAction) -> Tuple[float, Dict[str, Any]]:
|
|
| 77 |
if action.escalate == EscalationDecision.ESCALATE:
|
| 78 |
score += 0.1
|
| 79 |
|
| 80 |
-
if len(action.response) > 20:
|
| 81 |
score += 0.15
|
| 82 |
|
| 83 |
score = _clamp(score)
|
| 84 |
breakdown["score"] = score
|
| 85 |
-
return score, breakdown
|
| 86 |
|
| 87 |
|
| 88 |
def grade_hard(action: TriageAction) -> Tuple[float, Dict[str, Any]]:
|
|
@@ -102,15 +101,16 @@ def grade_hard(action: TriageAction) -> Tuple[float, Dict[str, Any]]:
|
|
| 102 |
if action.escalate == EscalationDecision.ESCALATE:
|
| 103 |
score += 0.1
|
| 104 |
|
| 105 |
-
resp = action.response.lower()
|
| 106 |
|
| 107 |
if "disconnect" in resp:
|
| 108 |
score += 0.15
|
| 109 |
|
| 110 |
-
if "do not" in resp:
|
| 111 |
score += 0.15
|
| 112 |
|
| 113 |
-
|
|
|
|
| 114 |
penalty += 0.4
|
| 115 |
|
| 116 |
if "disconnect" not in resp:
|
|
@@ -120,14 +120,15 @@ def grade_hard(action: TriageAction) -> Tuple[float, Dict[str, Any]]:
|
|
| 120 |
penalty += 0.2
|
| 121 |
|
| 122 |
raw = score - penalty
|
| 123 |
-
final = _clamp(raw)
|
| 124 |
|
|
|
|
| 125 |
breakdown["score"] = final
|
| 126 |
-
return final, breakdown
|
| 127 |
-
|
| 128 |
|
| 129 |
-
# βββ TASK STRUCTURE βββββββββββββββββββββββββββββββββββ
|
| 130 |
|
|
|
|
|
|
|
|
|
|
| 131 |
@dataclass
|
| 132 |
class Task:
|
| 133 |
task_id: str
|
|
|
|
| 10 |
EscalationDecision,
|
| 11 |
)
|
| 12 |
|
| 13 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 14 |
+
# STRICT CLAMP (NO EDGE FAILURES)
|
| 15 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 16 |
def _clamp(score: float) -> float:
|
| 17 |
+
return max(0.01, min(0.99, float(score)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
|
|
|
| 19 |
|
| 20 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 21 |
+
# TICKETS
|
| 22 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 23 |
TICKET_EASY = TicketObservation(
|
| 24 |
+
ticket_id="T1",
|
| 25 |
+
subject="Laptop not booting",
|
| 26 |
+
body="My laptop shows black screen",
|
| 27 |
reporter_name="User",
|
| 28 |
reporter_role="Employee",
|
| 29 |
system_info="Windows",
|
|
|
|
| 39 |
TICKET_HARD = TICKET_EASY
|
| 40 |
|
| 41 |
|
| 42 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 43 |
+
# GRADERS
|
| 44 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 45 |
def grade_easy(action: TriageAction) -> Tuple[float, Dict[str, Any]]:
|
| 46 |
score = 0.0
|
| 47 |
breakdown = {}
|
|
|
|
| 52 |
if action.priority in {TicketPriority.HIGH, TicketPriority.CRITICAL}:
|
| 53 |
score += 0.25
|
| 54 |
|
| 55 |
+
if isinstance(action.response, str) and len(action.response) > 10:
|
| 56 |
score += 0.15
|
| 57 |
|
| 58 |
score = _clamp(score)
|
| 59 |
breakdown["score"] = score
|
| 60 |
+
return float(score), breakdown
|
| 61 |
|
| 62 |
|
| 63 |
def grade_medium(action: TriageAction) -> Tuple[float, Dict[str, Any]]:
|
|
|
|
| 76 |
if action.escalate == EscalationDecision.ESCALATE:
|
| 77 |
score += 0.1
|
| 78 |
|
| 79 |
+
if isinstance(action.response, str) and len(action.response) > 20:
|
| 80 |
score += 0.15
|
| 81 |
|
| 82 |
score = _clamp(score)
|
| 83 |
breakdown["score"] = score
|
| 84 |
+
return float(score), breakdown
|
| 85 |
|
| 86 |
|
| 87 |
def grade_hard(action: TriageAction) -> Tuple[float, Dict[str, Any]]:
|
|
|
|
| 101 |
if action.escalate == EscalationDecision.ESCALATE:
|
| 102 |
score += 0.1
|
| 103 |
|
| 104 |
+
resp = (action.response or "").lower()
|
| 105 |
|
| 106 |
if "disconnect" in resp:
|
| 107 |
score += 0.15
|
| 108 |
|
| 109 |
+
if "do not" in resp or "don't" in resp:
|
| 110 |
score += 0.15
|
| 111 |
|
| 112 |
+
# penalties
|
| 113 |
+
if "decrypt" in resp or "recover" in resp:
|
| 114 |
penalty += 0.4
|
| 115 |
|
| 116 |
if "disconnect" not in resp:
|
|
|
|
| 120 |
penalty += 0.2
|
| 121 |
|
| 122 |
raw = score - penalty
|
|
|
|
| 123 |
|
| 124 |
+
final = _clamp(raw)
|
| 125 |
breakdown["score"] = final
|
| 126 |
+
return float(final), breakdown
|
|
|
|
| 127 |
|
|
|
|
| 128 |
|
| 129 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 130 |
+
# TASK STRUCTURE
|
| 131 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 132 |
@dataclass
|
| 133 |
class Task:
|
| 134 |
task_id: str
|