Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- .gitignore +4 -0
- app.py +4 -3
.gitignore
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__/
|
| 2 |
+
*.py[cod]
|
| 3 |
+
.DS_Store
|
| 4 |
+
.venv/
|
app.py
CHANGED
|
@@ -6,7 +6,7 @@ from __future__ import annotations
|
|
| 6 |
import os
|
| 7 |
from typing import Any, Dict, Optional
|
| 8 |
|
| 9 |
-
from fastapi import FastAPI, HTTPException, Query, Request
|
| 10 |
from fastapi.middleware.cors import CORSMiddleware
|
| 11 |
from fastapi.responses import HTMLResponse, RedirectResponse
|
| 12 |
from pydantic import BaseModel
|
|
@@ -814,9 +814,10 @@ def health() -> Dict[str, str]:
|
|
| 814 |
|
| 815 |
|
| 816 |
@app.post("/reset", response_model=Dict[str, Any])
|
| 817 |
-
def reset(request: ResetRequest) -> Dict[str, Any]:
|
| 818 |
try:
|
| 819 |
-
|
|
|
|
| 820 |
except ValueError as exc:
|
| 821 |
raise HTTPException(status_code=422, detail=str(exc)) from exc
|
| 822 |
return observation.model_dump()
|
|
|
|
| 6 |
import os
|
| 7 |
from typing import Any, Dict, Optional
|
| 8 |
|
| 9 |
+
from fastapi import Body, FastAPI, HTTPException, Query, Request
|
| 10 |
from fastapi.middleware.cors import CORSMiddleware
|
| 11 |
from fastapi.responses import HTMLResponse, RedirectResponse
|
| 12 |
from pydantic import BaseModel
|
|
|
|
| 814 |
|
| 815 |
|
| 816 |
@app.post("/reset", response_model=Dict[str, Any])
|
| 817 |
+
def reset(request: Optional[ResetRequest] = Body(default=None)) -> Dict[str, Any]:
|
| 818 |
try:
|
| 819 |
+
payload = request or ResetRequest()
|
| 820 |
+
observation = store.reset(task_id=payload.task_id, seed=payload.seed)
|
| 821 |
except ValueError as exc:
|
| 822 |
raise HTTPException(status_code=422, detail=str(exc)) from exc
|
| 823 |
return observation.model_dump()
|