Spaces:
Sleeping
Sleeping
Upload server/main.py with huggingface_hub
Browse files- server/main.py +19 -5
server/main.py
CHANGED
|
@@ -1,9 +1,16 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from pydantic import BaseModel
|
| 3 |
-
from typing import Optional
|
| 4 |
from server.environment import DataCentricEnvironment
|
| 5 |
|
| 6 |
-
app = FastAPI(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
env = DataCentricEnvironment()
|
| 8 |
|
| 9 |
|
|
@@ -11,6 +18,12 @@ class ResetRequest(BaseModel):
|
|
| 11 |
difficulty: Optional[str] = None
|
| 12 |
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
@app.post("/reset")
|
| 15 |
def reset(body: ResetRequest = None):
|
| 16 |
difficulty = body.difficulty if body else None
|
|
@@ -18,8 +31,9 @@ def reset(body: ResetRequest = None):
|
|
| 18 |
|
| 19 |
|
| 20 |
@app.post("/step")
|
| 21 |
-
def step(
|
| 22 |
-
|
|
|
|
| 23 |
|
| 24 |
|
| 25 |
@app.get("/state")
|
|
@@ -29,4 +43,4 @@ def state():
|
|
| 29 |
|
| 30 |
@app.get("/health")
|
| 31 |
def health():
|
| 32 |
-
return {"status": "ok"}
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from pydantic import BaseModel
|
| 3 |
+
from typing import Optional, Any
|
| 4 |
from server.environment import DataCentricEnvironment
|
| 5 |
|
| 6 |
+
app = FastAPI(
|
| 7 |
+
title="DataCentric-Env",
|
| 8 |
+
version="0.2.0",
|
| 9 |
+
description=(
|
| 10 |
+
"RL environment where an LLM acts as a data engineer. "
|
| 11 |
+
"Query specialist agents for recommendations, then apply them to fix a noisy dataset."
|
| 12 |
+
),
|
| 13 |
+
)
|
| 14 |
env = DataCentricEnvironment()
|
| 15 |
|
| 16 |
|
|
|
|
| 18 |
difficulty: Optional[str] = None
|
| 19 |
|
| 20 |
|
| 21 |
+
class ActionRequest(BaseModel):
|
| 22 |
+
action: str # query_cleaner | query_augmenter | ... | apply
|
| 23 |
+
rec_id: Optional[str] = None # required for action="apply"
|
| 24 |
+
target_class: Optional[int] = None # optional for query_augmenter
|
| 25 |
+
|
| 26 |
+
|
| 27 |
@app.post("/reset")
|
| 28 |
def reset(body: ResetRequest = None):
|
| 29 |
difficulty = body.difficulty if body else None
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
@app.post("/step")
|
| 34 |
+
def step(body: ActionRequest):
|
| 35 |
+
action_dict = body.model_dump(exclude_none=True)
|
| 36 |
+
return env.step(action_dict)
|
| 37 |
|
| 38 |
|
| 39 |
@app.get("/state")
|
|
|
|
| 43 |
|
| 44 |
@app.get("/health")
|
| 45 |
def health():
|
| 46 |
+
return {"status": "ok", "version": "0.2.0"}
|