Spaces:
Running
Running
Update api/main.py
Browse files- api/main.py +4 -4
api/main.py
CHANGED
|
@@ -81,7 +81,7 @@ def preprocess_text(text):
|
|
| 81 |
def root():
|
| 82 |
return {"status": "running", "message": "Sentiment ML System - DistilBERT"}
|
| 83 |
|
| 84 |
-
@app.post("/predict", response_model=PredictionResponse)
|
| 85 |
def predict(request: ReviewRequest):
|
| 86 |
if not request.review.strip():
|
| 87 |
raise HTTPException(status_code=400, detail="Review text cannot be empty")
|
|
@@ -117,7 +117,7 @@ def predict(request: ReviewRequest):
|
|
| 117 |
except Exception as e:
|
| 118 |
raise HTTPException(status_code=500, detail=str(e))
|
| 119 |
|
| 120 |
-
@app.get("/metrics")
|
| 121 |
def get_metrics():
|
| 122 |
response = {}
|
| 123 |
|
|
@@ -141,7 +141,7 @@ def get_metrics():
|
|
| 141 |
|
| 142 |
return response
|
| 143 |
|
| 144 |
-
@app.get("/health")
|
| 145 |
def health():
|
| 146 |
return {
|
| 147 |
"status": "healthy",
|
|
@@ -150,7 +150,7 @@ def health():
|
|
| 150 |
}
|
| 151 |
|
| 152 |
|
| 153 |
-
@app.post("/explain", response_model=ExplanationResponse)
|
| 154 |
def explain(request: ReviewRequest):
|
| 155 |
if not request.review.strip():
|
| 156 |
raise HTTPException(status_code=400, detail="Review text cannot be empty")
|
|
|
|
| 81 |
def root():
|
| 82 |
return {"status": "running", "message": "Sentiment ML System - DistilBERT"}
|
| 83 |
|
| 84 |
+
@app.post("/api/predict", response_model=PredictionResponse)
|
| 85 |
def predict(request: ReviewRequest):
|
| 86 |
if not request.review.strip():
|
| 87 |
raise HTTPException(status_code=400, detail="Review text cannot be empty")
|
|
|
|
| 117 |
except Exception as e:
|
| 118 |
raise HTTPException(status_code=500, detail=str(e))
|
| 119 |
|
| 120 |
+
@app.get("/api/metrics")
|
| 121 |
def get_metrics():
|
| 122 |
response = {}
|
| 123 |
|
|
|
|
| 141 |
|
| 142 |
return response
|
| 143 |
|
| 144 |
+
@app.get("/api/health")
|
| 145 |
def health():
|
| 146 |
return {
|
| 147 |
"status": "healthy",
|
|
|
|
| 150 |
}
|
| 151 |
|
| 152 |
|
| 153 |
+
@app.post("/api/explain", response_model=ExplanationResponse)
|
| 154 |
def explain(request: ReviewRequest):
|
| 155 |
if not request.review.strip():
|
| 156 |
raise HTTPException(status_code=400, detail="Review text cannot be empty")
|