Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI, Request | |
| from fastapi.responses import HTMLResponse # <--- Add this import | |
| from env import FinAuditEnv | |
| import os | |
| app = FastAPI() | |
| # Initialize your environment natively | |
| env_instance = FinAuditEnv() | |
| # 🚨 THE FIX: Serve the beautiful HTML dashboard to humans | |
| def home(): | |
| # Fallback message just in case index.html is missing | |
| if not os.path.exists("index.html"): | |
| return "<h1>FinAuditEnv is Live! (index.html missing)</h1>" | |
| with open("index.html", "r") as f: | |
| return f.read() | |
| def health(): | |
| return {"status": "ok"} | |
| async def reset_env(request: Request): | |
| payload = await request.json() if await request.body() else {} | |
| task = payload.get("task_name", "finaudit_complex") | |
| obs = env_instance.reset(task) | |
| return {"observation": obs} | |
| async def step_env(request: Request): | |
| payload = await request.json() | |
| action = payload.get("action") if "action" in payload else payload | |
| obs, reward, done = env_instance.step(action) | |
| return {"observation": obs, "reward": reward, "done": done} | |
| async def get_state(): | |
| return {"state": "active"} |