Spaces:
Sleeping
Sleeping
| 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() | |
| def reset(): | |
| obs = env.reset() | |
| return {"observation": obs} | |
| def step(action: dict): | |
| act = action.get("action") | |
| obs, reward, done, info = env.step(act) | |
| return { | |
| "observation": obs, | |
| "reward": reward, | |
| "done": done, | |
| "info": info | |
| } | |
| 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() |