Spaces:
Sleeping
Sleeping
Commit ·
8510c35
1
Parent(s): 784d1a2
Implemented processing of support session finalized version
Browse files- environment.py +26 -0
environment.py
CHANGED
|
@@ -249,6 +249,32 @@ class EmailSortingEnvironment:
|
|
| 249 |
components["response_present"] = 0.02
|
| 250 |
total += 0.02
|
| 251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
def process_action(self, action: Action) -> Tuple[Reward, Dict]:
|
| 253 |
if self.task_id == "email_classification":
|
| 254 |
return self.process_email_classification(action)
|
|
|
|
| 249 |
components["response_present"] = 0.02
|
| 250 |
total += 0.02
|
| 251 |
|
| 252 |
+
if email.get("correct_category") == "spam" and action_type != "archive":
|
| 253 |
+
components["spam_not_archived"] = -0.04
|
| 254 |
+
total -= 0.04
|
| 255 |
+
|
| 256 |
+
self.episode_actions.append(
|
| 257 |
+
{
|
| 258 |
+
"email_id": email["id"],
|
| 259 |
+
"action_type": action_type,
|
| 260 |
+
"category": cat_given,
|
| 261 |
+
"urgency": urg_given,
|
| 262 |
+
"correct_category": email.get("correct_category"),
|
| 263 |
+
"correct_urgency": email.get("correct_urgency"),
|
| 264 |
+
"correct_action": correct_action,
|
| 265 |
+
"position": position,
|
| 266 |
+
}
|
| 267 |
+
)
|
| 268 |
+
|
| 269 |
+
self.processed_emails.append(email)
|
| 270 |
+
self.current_email_idx += 1
|
| 271 |
+
|
| 272 |
+
return Reward(
|
| 273 |
+
value=round(total, 4),
|
| 274 |
+
components=components,
|
| 275 |
+
reason=f"{email['id']} at position {position}: action={action_type}",
|
| 276 |
+
), {"email_id": email["id"]}
|
| 277 |
+
|
| 278 |
def process_action(self, action: Action) -> Tuple[Reward, Dict]:
|
| 279 |
if self.task_id == "email_classification":
|
| 280 |
return self.process_email_classification(action)
|