Spaces:
Sleeping
Sleeping
Commit ·
f5810e8
1
Parent(s): 7d5c46d
feat(app): add POST /grade endpoint with active-episode guard and programmatic grader
Browse files- server/app.py +14 -0
server/app.py
CHANGED
|
@@ -64,3 +64,17 @@ async def get_state():
|
|
| 64 |
@app.get("/history")
|
| 65 |
async def get_history():
|
| 66 |
return {"history": env.get_history()}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
@app.get("/history")
|
| 65 |
async def get_history():
|
| 66 |
return {"history": env.get_history()}
|
| 67 |
+
|
| 68 |
+
@app.post("/grade")
|
| 69 |
+
async def grade_episode():
|
| 70 |
+
if env.is_active:
|
| 71 |
+
raise HTTPException(status_code=400, detail="Episode still active — finish it before grading.")
|
| 72 |
+
|
| 73 |
+
history = env.get_history()
|
| 74 |
+
if not history:
|
| 75 |
+
raise HTTPException(status_code=400, detail="No episode history to grade.")
|
| 76 |
+
|
| 77 |
+
from graders.programmatic_grader import grade_episode as do_grade
|
| 78 |
+
result = do_grade(history)
|
| 79 |
+
result["episode_id"] = env.episode_id
|
| 80 |
+
return result
|