Spaces:
Runtime error
Runtime error
Download server/app.py from jananiprakash152519/OpenEnv_Autonomous_Work_Simulator: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/spaces/jananiprakash152519/OpenEnv_Autonomous_Work_Simulator/resolve/main/server/app.py
- Command line
-
hf download hf://spaces/jananiprakash152519/OpenEnv_Autonomous_Work_Simulator/server/app.py
-
curl -L -o app.py https://huggingface.co/spaces/jananiprakash152519/OpenEnv_Autonomous_Work_Simulator/resolve/main/server/app.py
1.16 kB
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| import uvicorn | |
| app = FastAPI() | |
| class Action(BaseModel): | |
| action: str | |
| class SimpleEnv: | |
| def __init__(self): | |
| self.step_count = 0 | |
| self.done = False | |
| def reset(self): | |
| self.step_count = 0 | |
| self.done = False | |
| return {"observation": "Classify emails using classify(id, label)"} | |
| def step(self, action): | |
| self.step_count += 1 | |
| reward = 0.0 | |
| error = None | |
| if "classify" in action: | |
| reward = 0.5 | |
| else: | |
| reward = -0.2 | |
| error = "invalid_action" | |
| if self.step_count >= 3: | |
| self.done = True | |
| reward = 1.0 | |
| return { | |
| "observation": "Next step", | |
| "reward": reward, | |
| "done": self.done, | |
| "info": {"error": error} | |
| } | |
| env = SimpleEnv() | |
| def reset(): | |
| return env.reset() | |
| def step(action: Action): | |
| return env.step(action.action) | |
| def root(): | |
| return {"status": "running"} | |
| if __name__ == "__main__": | |
| uvicorn.run(app, host="0.0.0.0", port=8000) |