Spaces:
Sleeping
Sleeping
File size: 999 Bytes
dc762fd | 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 | import gradio as gr
from fastapi import FastAPI
app = FastAPI()
class EmailEnv:
def __init__(self):
self.reset()
def reset(self):
self.emails = [
{"id": 1, "from": "alice@example.com", "subject": "Meeting Tomorrow", "status": "Unread"},
{"id": 2, "from": "bob@example.com", "subject": "Lunch Plans", "status": "Archived"}
]
return {"emails": self.emails}
def step(self, action):
return {
"emails": self.emails,
"reward": 1,
"done": False
}
env = EmailEnv()
@app.post("/reset")
def reset():
return env.reset()
@app.post("/step")
def step(action: dict):
return env.step(action)
def ui(action):
return f"Selected: {action}"
iface = gr.Interface(
fn=ui,
inputs=gr.Radio(["important", "spam", "normal"]),
outputs="text",
title="Smart Email AI Trainer"
)
app = gr.mount_gradio_app(app, iface, path="/ui") |