Spaces:
Sleeping
Sleeping
Download server/app.py from ashwin2005/opensupportops: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/ashwin2005/opensupportops/resolve/main/server/app.py
- Command line
-
hf download hf://spaces/ashwin2005/opensupportops/server/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ashwin2005/opensupportops/resolve/main/server/app.py
1.08 kB
| from fastapi import FastAPI | |
| import uvicorn | |
| from server.support_env import OpenSupportOpsEnv | |
| from models import SupportAction | |
| # Create FastAPI app | |
| app = FastAPI( | |
| title="OpenSupportOps API", | |
| docs_url="/docs", | |
| redoc_url="/redoc" | |
| ) | |
| # Initialize environment | |
| env = OpenSupportOpsEnv("easy_refund.json") | |
| # Root endpoint (health check) | |
| def root(): | |
| return {"message": "OpenSupportOps API is running"} | |
| # Reset environment | |
| def reset(): | |
| obs = env.reset() | |
| return { | |
| "observation": obs, | |
| "message": "Environment reset successful" | |
| } | |
| # Take a step | |
| def step(action: SupportAction): | |
| obs, reward, done, info = env.step(action) | |
| return { | |
| "observation": obs, | |
| "reward": reward, | |
| "done": done, | |
| "info": info, | |
| } | |
| # Get state | |
| def state(): | |
| return env.state() | |
| # ✅ REQUIRED for OpenEnv validation | |
| def main(): | |
| uvicorn.run("server.app:app", host="0.0.0.0", port=7860) | |
| # ✅ REQUIRED entry point | |
| if __name__ == "__main__": | |
| main() |