Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import uuid
|
|
| 2 |
import os
|
| 3 |
from fastapi import FastAPI, HTTPException
|
| 4 |
from pydantic import BaseModel
|
| 5 |
-
from typing import Dict
|
| 6 |
|
| 7 |
# Import your environment logic
|
| 8 |
# Ensure these files exist in a folder named 'environment' with an __init__.py file
|
|
@@ -15,7 +15,7 @@ app = FastAPI(title="CodeReviewEnv")
|
|
| 15 |
sessions: Dict[str, CodeReviewEnv] = {}
|
| 16 |
|
| 17 |
class ResetRequest(BaseModel):
|
| 18 |
-
task_id: str
|
| 19 |
|
| 20 |
class StepRequest(BaseModel):
|
| 21 |
session_id: str
|
|
@@ -38,8 +38,10 @@ async def health():
|
|
| 38 |
return {"status": "ok"}
|
| 39 |
|
| 40 |
@app.post("/reset")
|
| 41 |
-
async def reset_endpoint(req: ResetRequest):
|
| 42 |
try:
|
|
|
|
|
|
|
| 43 |
# Create a new session with a unique ID
|
| 44 |
session_id = str(uuid.uuid4())
|
| 45 |
env = CodeReviewEnv(req.task_id)
|
|
@@ -87,4 +89,4 @@ async def state_endpoint(session_id: str):
|
|
| 87 |
|
| 88 |
# Note: In Hugging Face Spaces with Docker,
|
| 89 |
# you do NOT need 'if __name__ == "__main__": uvicorn.run(...)'
|
| 90 |
-
# because it is handled by your Dockerfile CMD.
|
|
|
|
| 2 |
import os
|
| 3 |
from fastapi import FastAPI, HTTPException
|
| 4 |
from pydantic import BaseModel
|
| 5 |
+
from typing import Dict, Optional
|
| 6 |
|
| 7 |
# Import your environment logic
|
| 8 |
# Ensure these files exist in a folder named 'environment' with an __init__.py file
|
|
|
|
| 15 |
sessions: Dict[str, CodeReviewEnv] = {}
|
| 16 |
|
| 17 |
class ResetRequest(BaseModel):
|
| 18 |
+
task_id: str = "easy"
|
| 19 |
|
| 20 |
class StepRequest(BaseModel):
|
| 21 |
session_id: str
|
|
|
|
| 38 |
return {"status": "ok"}
|
| 39 |
|
| 40 |
@app.post("/reset")
|
| 41 |
+
async def reset_endpoint(req: Optional[ResetRequest] = None):
|
| 42 |
try:
|
| 43 |
+
if req is None:
|
| 44 |
+
req = ResetRequest()
|
| 45 |
# Create a new session with a unique ID
|
| 46 |
session_id = str(uuid.uuid4())
|
| 47 |
env = CodeReviewEnv(req.task_id)
|
|
|
|
| 89 |
|
| 90 |
# Note: In Hugging Face Spaces with Docker,
|
| 91 |
# you do NOT need 'if __name__ == "__main__": uvicorn.run(...)'
|
| 92 |
+
# because it is handled by your Dockerfile CMD.
|