Spaces:
Sleeping
Sleeping
Download server/tasks/incident_routing_task.py from TheCrustaceans/Pm-ops: direct link, hf CLI and curl.
- Browser
- Download file 1.19 kB
-
https://huggingface.co/spaces/TheCrustaceans/Pm-ops/resolve/main/server/tasks/incident_routing_task.py
- Command line
-
hf download hf://spaces/TheCrustaceans/Pm-ops/server/tasks/incident_routing_task.py
-
curl -L -o incident_routing_task.py https://huggingface.co/spaces/TheCrustaceans/Pm-ops/resolve/main/server/tasks/incident_routing_task.py
1.19 kB
| from typing import Any, Dict | |
| from server.tasks.base_task import BaseTask | |
| class IncidentRoutingTask(BaseTask): | |
| def grade(self, final_state: Dict[str, Any], org_config: Dict[str, Any], scenario: Dict[str, Any]) -> float: | |
| score = 0.0 | |
| expected = scenario["expected"] | |
| msgs = final_state["chat"]["messages_posted_this_episode"] | |
| tickets = final_state["ticketing"]["tickets"] | |
| new_tickets = [t for t in tickets if t.get("created_this_episode")] | |
| correct_msgs = [m for m in msgs if m.get("channel") == expected.get("channel")] | |
| wrong_msgs = [m for m in msgs if m.get("channel") != expected.get("channel")] | |
| if correct_msgs: | |
| score += 0.30 | |
| if new_tickets: | |
| t = new_tickets[0] | |
| if t.get("label") == expected.get("label"): | |
| score += 0.20 | |
| if t.get("priority") == expected.get("priority"): | |
| score += 0.20 | |
| if t.get("assigned_team") == expected.get("team"): | |
| score += 0.15 | |
| if t.get("linked_pr"): | |
| score += 0.05 | |
| score -= 0.15 * len(wrong_msgs) | |
| return max(0.0, min(1.0, score)) | |