saravanatanjiro commited on
Commit
d13e7d7
·
1 Parent(s): a07aaca

Added Boss Fight scenario support to reset endpoint

Browse files
Files changed (1) hide show
  1. server.py +13 -4
server.py CHANGED
@@ -77,11 +77,20 @@ def format_semantic_obs(env_instance):
77
  # Track the previous veto count to know if the CURRENT action was vetoed
78
  server_state = {"last_veto_count": 0}
79
 
 
 
 
 
 
80
  @app.post("/reset")
81
- def reset():
82
- obs, info = env.reset()
83
- server_state["last_veto_count"] = env.veto_count # Reset our tracker
84
- # FIXED: Pass the 'env' object directly
 
 
 
 
85
  return {"observation": format_semantic_obs(env)}
86
 
87
  @app.post("/step")
 
77
  # Track the previous veto count to know if the CURRENT action was vetoed
78
  server_state = {"last_veto_count": 0}
79
 
80
+
81
+
82
+ class ResetRequest(BaseModel):
83
+ scenario_id: int = 0 # Default to 0 (normal random episode)
84
+
85
  @app.post("/reset")
86
+ def reset(req: ResetRequest = None):
87
+ # If no request body is sent, default to scenario 0
88
+ scenario = req.scenario_id if req else 0
89
+
90
+ # Pass the scenario option to your original environment
91
+ obs, info = env.reset(options={"scenario": scenario})
92
+
93
+ server_state["last_veto_count"] = env.veto_count
94
  return {"observation": format_semantic_obs(env)}
95
 
96
  @app.post("/step")