Spaces:
Sleeping
Sleeping
Download openenv-sql-analyst/server/app.py from YashashMathur/sql_data_analyst: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/YashashMathur/sql_data_analyst/resolve/main/openenv-sql-analyst/server/app.py
- Command line
-
hf download hf://spaces/YashashMathur/sql_data_analyst/openenv-sql-analyst/server/app.py
-
curl -L -o app.py https://huggingface.co/spaces/YashashMathur/sql_data_analyst/resolve/main/openenv-sql-analyst/server/app.py
1.06 kB
| import os | |
| import uvicorn | |
| from fastapi import FastAPI | |
| from environment.env import SQLAnalystEnv | |
| from environment.models import Action | |
| # Initialize the API and our RL Environment | |
| app = FastAPI(title="OpenEnv SQL Analyst") | |
| env = SQLAnalystEnv() | |
| def health_check(): | |
| """Hackathon requirement: Ping must return 200 OK""" | |
| return {"status": "ok", "message": "OpenEnv SQL Analyst is live!"} | |
| def reset(): | |
| """Hackathon requirement: Must respond to reset()""" | |
| return env.reset() | |
| def step(action: Action): | |
| """Executes the agent's action and returns the new state""" | |
| obs, reward, done, info = env.step(action) | |
| return { | |
| "observation": obs, | |
| "reward": reward, | |
| "done": done, | |
| "info": info | |
| } | |
| def state(): | |
| return env.state() | |
| def main(): | |
| print("๐ Starting OpenEnv Production Server on port 7860...") | |
| uvicorn.run(app, host="0.0.0.0", port=7860) | |
| if __name__ == "__main__": | |
| main() |