Spaces:
Build error
Build error
| 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"] | |
| class EmailMeta: | |
| deadline_minutes: Optional[int] = None | |
| expected_intent: Optional[Intent] = None | |
| expected_reply_keywords: List[str] = field(default_factory=list) | |
| 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"), | |
| }, | |
| ), | |
| ] | |