Spaces:
No application file
No application file
File size: 960 Bytes
48fe091 | 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 | import random
class EmailEnv:
def __init__(self):
self.emails = [
{
"text": "Meeting at 5 PM, please attend",
"label": "important",
"reply": "Sure, I will attend the meeting."
},
{
"text": "Congratulations! You won a lottery",
"label": "spam",
"reply": "This looks like spam."
},
{
"text": "Lunch tomorrow?",
"label": "normal",
"reply": "Sounds good!"
}
]
def reset(self):
self.current = random.choice(self.emails)
return self.current
def step(self, action):
reward = 0
if action["label"] == self.current["label"]:
reward += 0.5
if action["reply"] == self.current["reply"]:
reward += 0.5
return reward
|