Spaces:
Sleeping
Sleeping
Commit ·
191af87
1
Parent(s): 8eba78d
fix: correct observation key for OpenEnv compliance
Browse files- server/app.py +10 -12
server/app.py
CHANGED
|
@@ -6,7 +6,7 @@ from fastapi import FastAPI
|
|
| 6 |
from pydantic import BaseModel
|
| 7 |
from app.env import CustomerSupportEnv
|
| 8 |
|
| 9 |
-
import uvicorn
|
| 10 |
import json
|
| 11 |
|
| 12 |
app = FastAPI()
|
|
@@ -45,27 +45,25 @@ def parse_action(action_str: str):
|
|
| 45 |
|
| 46 |
@app.post("/reset")
|
| 47 |
def reset():
|
| 48 |
-
|
| 49 |
return {
|
| 50 |
-
"
|
| 51 |
"reward": 0,
|
| 52 |
"done": False,
|
| 53 |
"info": {}
|
| 54 |
}
|
| 55 |
-
|
| 56 |
|
| 57 |
@app.post("/step")
|
| 58 |
def step(req: StepRequest):
|
| 59 |
-
|
| 60 |
action_dict = parse_action(req.action)
|
| 61 |
-
|
| 62 |
obs, reward, done, info = env.step(action_dict)
|
| 63 |
|
| 64 |
return {
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
}
|
| 70 |
|
| 71 |
@app.get("/")
|
|
@@ -73,6 +71,6 @@ def root():
|
|
| 73 |
return {"status": "ok"}
|
| 74 |
|
| 75 |
|
| 76 |
-
if __name__ == "__main__":
|
| 77 |
-
uvicorn.run("server.app:app", host="127.0.0.1", port=8000, reload=True)
|
| 78 |
|
|
|
|
| 6 |
from pydantic import BaseModel
|
| 7 |
from app.env import CustomerSupportEnv
|
| 8 |
|
| 9 |
+
#import uvicorn
|
| 10 |
import json
|
| 11 |
|
| 12 |
app = FastAPI()
|
|
|
|
| 45 |
|
| 46 |
@app.post("/reset")
|
| 47 |
def reset():
|
| 48 |
+
obs = env.reset()
|
| 49 |
return {
|
| 50 |
+
"observation": obs,
|
| 51 |
"reward": 0,
|
| 52 |
"done": False,
|
| 53 |
"info": {}
|
| 54 |
}
|
| 55 |
+
|
| 56 |
|
| 57 |
@app.post("/step")
|
| 58 |
def step(req: StepRequest):
|
|
|
|
| 59 |
action_dict = parse_action(req.action)
|
|
|
|
| 60 |
obs, reward, done, info = env.step(action_dict)
|
| 61 |
|
| 62 |
return {
|
| 63 |
+
"observation": obs, # ✅ NOT "state"
|
| 64 |
+
"reward": reward,
|
| 65 |
+
"done": done,
|
| 66 |
+
"info": info or {}
|
| 67 |
}
|
| 68 |
|
| 69 |
@app.get("/")
|
|
|
|
| 71 |
return {"status": "ok"}
|
| 72 |
|
| 73 |
|
| 74 |
+
#if __name__ == "__main__":
|
| 75 |
+
# uvicorn.run("server.app:app", host="127.0.0.1", port=8000, reload=True)
|
| 76 |
|