Spaces:
Sleeping
Sleeping
File size: 943 Bytes
bbebcaf 48c9fc6 bbebcaf 48c9fc6 668232e 48c9fc6 668232e bbebcaf 668232e | 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 | import os
import sys
from fastapi import FastAPI
# Add the parent directory to sys.path to allow importing root-level modules
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from env import EmailEnv
from inference import run_inference
app = FastAPI()
env = EmailEnv()
@app.post("/reset")
def reset():
obs = env.reset()
return {"observation": obs}
@app.post("/step")
def step(action: dict):
act = action.get("action")
obs, reward, done, info = env.step(act)
return {
"observation": obs,
"reward": reward,
"done": done,
"info": info
}
@app.get("/")
def root():
return {"message": "Email Env is running"}
def start_server():
import uvicorn
# Now that app is in the server package, we need the full import path
uvicorn.run("server.app:app", host="0.0.0.0", port=7860)
def main():
run_inference()
if __name__ == "__main__":
main() |