Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -143,12 +143,24 @@ def health_check():
|
|
| 143 |
return {"status": "API is running"}
|
| 144 |
|
| 145 |
@app.post("/predict")
|
| 146 |
-
@app.post("/run/predict")
|
| 147 |
def predict(request: PredictionRequest):
|
| 148 |
disease = predict_disease(request.symptoms)
|
| 149 |
return {"predicted_disease": disease}
|
| 150 |
|
|
|
|
|
|
|
| 151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
if __name__ == "__main__":
|
| 154 |
import uvicorn
|
|
|
|
| 143 |
return {"status": "API is running"}
|
| 144 |
|
| 145 |
@app.post("/predict")
|
|
|
|
| 146 |
def predict(request: PredictionRequest):
|
| 147 |
disease = predict_disease(request.symptoms)
|
| 148 |
return {"predicted_disease": disease}
|
| 149 |
|
| 150 |
+
class GradioRequest(BaseModel):
|
| 151 |
+
data: list
|
| 152 |
|
| 153 |
+
@app.post("/run/predict")
|
| 154 |
+
def predict_gradio(request: GradioRequest):
|
| 155 |
+
# Gradio sends data as a list of arguments
|
| 156 |
+
# We expect the first argument to be the comma-separated symptoms string
|
| 157 |
+
if not request.data:
|
| 158 |
+
raise HTTPException(status_code=400, detail="No data provided")
|
| 159 |
+
|
| 160 |
+
symptoms = request.data[0]
|
| 161 |
+
disease = predict_disease(symptoms)
|
| 162 |
+
# Gradio expects the return value wrapped in a "data" list
|
| 163 |
+
return {"data": [disease]}
|
| 164 |
|
| 165 |
if __name__ == "__main__":
|
| 166 |
import uvicorn
|