Spaces:
Build error
Build error
File size: 4,586 Bytes
0387a1c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | from __future__ import annotations
from dataclasses import dataclass, field
from typing import Dict, List, Literal, Optional
from app.schemas import EmailMessage, Intent
Difficulty = Literal["easy", "medium", "hard"]
TaskId = Literal["easy_classification", "medium_prioritization", "hard_workflow"]
@dataclass(frozen=True)
class EmailMeta:
deadline_minutes: Optional[int] = None
expected_intent: Optional[Intent] = None
expected_reply_keywords: List[str] = field(default_factory=list)
@dataclass(frozen=True)
class EmailTask:
task_id: TaskId
difficulty: Difficulty
description: str
max_steps: int
inbox: List[EmailMessage]
email_meta: Dict[str, EmailMeta]
expected_priority_message_id: Optional[str] = None
expected_send_message_id: Optional[str] = None
def get_all_tasks() -> List[EmailTask]:
"""
Deterministic hackathon tasks (no IMAP required).
Full evaluation logic lives in graders + EmailEnv.
"""
easy_email = EmailMessage(
message_id="easy-1",
from_email="customer@example.com",
subject="Can't log in to my account",
body="Hi team, I can't log in since yesterday. Password reset link says token invalid. Please help.",
date="2026-03-30T09:00:00+05:30",
)
medium_emails = [
EmailMessage(
message_id="med-1",
from_email="billing@vendor.com",
subject="Invoice overdue — action required",
body="Reminder: invoice INV-1842 is overdue. Please confirm payment status within 24 hours.",
date="2026-03-30T08:40:00+05:30",
),
EmailMessage(
message_id="med-2",
from_email="newsletter@updates.com",
subject="Weekly product updates",
body="Here's what shipped this week...",
date="2026-03-30T08:30:00+05:30",
),
EmailMessage(
message_id="med-3",
from_email="candidate@example.com",
subject="Interview availability",
body="Sharing my availability for next week.",
date="2026-03-30T08:20:00+05:30",
),
]
hard_emails = [
EmailMessage(
message_id="hard-1",
from_email="vip_customer@example.com",
subject="URGENT: Production outage impacting our team",
body=(
"We're seeing 500 errors on checkout since 30 minutes. This is blocking revenue. "
"Please advise ETA and immediate mitigation."
),
date="2026-03-30T08:55:00+05:30",
),
EmailMessage(
message_id="hard-2",
from_email="saleslead@example.com",
subject="Pricing for 50 seats",
body="Can you share pricing for 50 seats and if SSO is included?",
date="2026-03-30T08:10:00+05:30",
),
]
return [
EmailTask(
task_id="easy_classification",
difficulty="easy",
description="Classify a single inbound email into the correct intent.",
max_steps=4,
inbox=[easy_email],
email_meta={"easy-1": EmailMeta(deadline_minutes=120, expected_intent="Support")},
),
EmailTask(
task_id="medium_prioritization",
difficulty="medium",
description="Pick the most urgent email from a small inbox under SLA deadlines.",
max_steps=5,
inbox=medium_emails,
expected_priority_message_id="med-1",
email_meta={
"med-1": EmailMeta(deadline_minutes=60, expected_intent="Sales"),
"med-2": EmailMeta(deadline_minutes=None, expected_intent="General"),
"med-3": EmailMeta(deadline_minutes=7 * 24 * 60, expected_intent="General"),
},
),
EmailTask(
task_id="hard_workflow",
difficulty="hard",
description="Run a full workflow: classify, prioritize, draft a reply, and send the correct email.",
max_steps=10,
inbox=hard_emails,
expected_priority_message_id="hard-1",
expected_send_message_id="hard-1",
email_meta={
"hard-1": EmailMeta(
deadline_minutes=30,
expected_intent="Support",
expected_reply_keywords=["mitigation", "eta", "apolog", "impact"],
),
"hard-2": EmailMeta(deadline_minutes=24 * 60, expected_intent="Sales"),
},
),
]
|