Spaces:
Sleeping
Sleeping
File size: 1,904 Bytes
fee8744 | 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 | """Pydantic models for Email Triage OpenEnv."""
from datetime import datetime
from enum import Enum
from typing import Optional, List, Dict, Any
from pydantic import BaseModel, Field
class EmailCategory(str, Enum):
"""Email classification categories"""
SPAM = "spam"
NORMAL = "normal"
URGENT = "urgent"
BILLING = "billing"
class Team(str, Enum):
"""Teams to route emails to"""
SUPPORT = "support"
SALES = "sales"
BILLING = "billing"
NONE = "none"
class Email(BaseModel):
"""Represents an email message"""
email_id: str
subject: str
body: str
sender_domain: str
timestamp: datetime
is_vip_sender: bool = False
sla_hours: Optional[int] = None
class GroundTruth(BaseModel):
"""Ground truth labels for an email"""
email_id: str
category: EmailCategory
team: Team
priority: int = Field(ge=0, le=3) # 0=low, 3=high
class Observation(BaseModel):
"""Observation returned after each step"""
current_email: Email
inbox_state: Dict[str, int] = Field(
default_factory=lambda: {
"pending": 0,
"spam": 0,
"urgent": 0,
"processed": 0
}
)
step_count: int = 0
task_name: str = ""
info: Dict[str, Any] = Field(default_factory=dict)
class Action(BaseModel):
"""Action taken by the agent"""
classification: EmailCategory
team: Team = Team.NONE
priority: int = Field(ge=0, le=3, default=1)
class Reward(BaseModel):
"""Reward signal for an action"""
value: float = Field(ge=0.0, le=1.0)
breakdown: Dict[str, float] = Field(default_factory=dict)
class State(BaseModel):
"""Complete environment state"""
current_observation: Observation
current_reward: float
done: bool
info: Dict[str, Any] = Field(default_factory=dict)
history: List[Dict[str, Any]] = Field(default_factory=list)
|