File size: 1,639 Bytes
5fb3d31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import sys
import os
# Add the current directory to sys.path to allow relative imports
sys.path.append(os.getcwd())

from email_triage_env.server.environment import EmailTriageEnv
from email_triage_env.models import EmailAction

def test_env():
    env = EmailTriageEnv()
    print("--- Resetting Environment ---")
    obs = env.reset()
    print(f"Initial Obs: {obs.subject} | {obs.body}")
    
    done = False
    while not done:
        # Simple policy: choose category 0 if subject has 'Cannot' or 'Critical'
        cat = 0
        prio = 1
        reason = "This looks like a support issue or error."
        
        if "pricing" in obs.subject.lower() or "partnership" in obs.subject.lower():
            cat = 1
            prio = 2
            reason = "This is a business or pricing inquiry."
        elif "love" in obs.body.lower() or "suggestion" in obs.subject.lower():
            cat = 2
            prio = 3
            reason = "This is positive feedback or a feature suggestion."
        elif "meeting" in obs.subject.lower() or "internal" in obs.subject.lower():
            cat = 3
            prio = 3
            reason = "This is an internal team communication."
            
        action = EmailAction(category_id=cat, priority=prio, reasoning=reason) 
        print(f"Action: Category {cat}, Priority {prio}, Reason: {reason}")
        
        obs = env.step(action)
        print(f"Reward: {obs.reward:.2f}")
        print(f"Message: {obs.message}")
        if obs.done:
            print("--- Done ---")
            break
        print(f"Next Obs: {obs.subject}")

if __name__ == "__main__":
    test_env()