Update app.py
Browse files
app.py
CHANGED
|
@@ -184,11 +184,11 @@ async def root():
|
|
| 184 |
async def health_check():
|
| 185 |
return {"status": "healthy"}
|
| 186 |
|
| 187 |
-
@app.get("/training-status")
|
| 188 |
async def get_training_status():
|
| 189 |
return training_status
|
| 190 |
|
| 191 |
-
@app.post("/upload")
|
| 192 |
async def upload_file(file: UploadFile = File(...)):
|
| 193 |
"""Upload a CSV file for training or validation"""
|
| 194 |
if not file.filename.endswith('.csv'):
|
|
@@ -200,7 +200,7 @@ async def upload_file(file: UploadFile = File(...)):
|
|
| 200 |
|
| 201 |
return {"message": f"File {file.filename} uploaded successfully", "file_path": str(file_path)}
|
| 202 |
|
| 203 |
-
@app.post("/bert/train", response_model=TrainingResponse)
|
| 204 |
async def start_training(
|
| 205 |
config: TrainingConfig,
|
| 206 |
background_tasks: BackgroundTasks,
|
|
@@ -224,7 +224,7 @@ async def start_training(
|
|
| 224 |
|
| 225 |
background_tasks.add_task(train_model_task, config, file_path, training_id)
|
| 226 |
|
| 227 |
-
download_url = f"/bert/download-model/{training_id}"
|
| 228 |
|
| 229 |
return TrainingResponse(
|
| 230 |
message="Training started successfully",
|
|
@@ -233,7 +233,7 @@ async def start_training(
|
|
| 233 |
download_url=download_url
|
| 234 |
)
|
| 235 |
|
| 236 |
-
@app.post("/bert/validate")
|
| 237 |
async def validate_model(
|
| 238 |
file: UploadFile = File(...),
|
| 239 |
model_name: str = "BERT_model"
|
|
@@ -319,7 +319,7 @@ async def validate_model(
|
|
| 319 |
if os.path.exists(file_path):
|
| 320 |
os.remove(file_path)
|
| 321 |
|
| 322 |
-
@app.post("/bert/predict")
|
| 323 |
async def predict(
|
| 324 |
request: Optional[PredictionRequest] = None,
|
| 325 |
file: Optional[UploadFile] = File(None),
|
|
|
|
| 184 |
async def health_check():
|
| 185 |
return {"status": "healthy"}
|
| 186 |
|
| 187 |
+
@app.get("/v1/bert/training-status")
|
| 188 |
async def get_training_status():
|
| 189 |
return training_status
|
| 190 |
|
| 191 |
+
@app.post("/v1/bert/upload")
|
| 192 |
async def upload_file(file: UploadFile = File(...)):
|
| 193 |
"""Upload a CSV file for training or validation"""
|
| 194 |
if not file.filename.endswith('.csv'):
|
|
|
|
| 200 |
|
| 201 |
return {"message": f"File {file.filename} uploaded successfully", "file_path": str(file_path)}
|
| 202 |
|
| 203 |
+
@app.post("/v1/bert/train", response_model=TrainingResponse)
|
| 204 |
async def start_training(
|
| 205 |
config: TrainingConfig,
|
| 206 |
background_tasks: BackgroundTasks,
|
|
|
|
| 224 |
|
| 225 |
background_tasks.add_task(train_model_task, config, file_path, training_id)
|
| 226 |
|
| 227 |
+
download_url = f"/v1/bert/download-model/{training_id}"
|
| 228 |
|
| 229 |
return TrainingResponse(
|
| 230 |
message="Training started successfully",
|
|
|
|
| 233 |
download_url=download_url
|
| 234 |
)
|
| 235 |
|
| 236 |
+
@app.post("/v1/bert/validate")
|
| 237 |
async def validate_model(
|
| 238 |
file: UploadFile = File(...),
|
| 239 |
model_name: str = "BERT_model"
|
|
|
|
| 319 |
if os.path.exists(file_path):
|
| 320 |
os.remove(file_path)
|
| 321 |
|
| 322 |
+
@app.post("/v1/bert/predict")
|
| 323 |
async def predict(
|
| 324 |
request: Optional[PredictionRequest] = None,
|
| 325 |
file: Optional[UploadFile] = File(None),
|