Update app.py
Browse files
app.py
CHANGED
|
@@ -85,20 +85,20 @@ async def predict_masked_lm(request: InferenceRequest):
|
|
| 85 |
logger.info(f"Successfully processed request. Returning {len(results)} predictions.")
|
| 86 |
return results
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
|
| 103 |
@api_router.get(
|
| 104 |
"/health", # Health check endpoint
|
|
|
|
| 85 |
logger.info(f"Successfully processed request. Returning {len(results)} predictions.")
|
| 86 |
return results
|
| 87 |
|
| 88 |
+
except ValidationError as e: # This is line 88
|
| 89 |
+
logger.error(f"Validation error for request: {e.errors()}")
|
| 90 |
+
raise HTTPException(
|
| 91 |
+
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
| 92 |
+
detail=e.errors()
|
| 93 |
+
)
|
| 94 |
+
except HTTPException:
|
| 95 |
+
raise
|
| 96 |
+
except Exception as e:
|
| 97 |
+
logger.exception(f"An unexpected error occurred during prediction: {e}")
|
| 98 |
+
raise HTTPException(
|
| 99 |
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
| 100 |
+
detail=f"An internal server error occurred: {e}"
|
| 101 |
+
)
|
| 102 |
|
| 103 |
@api_router.get(
|
| 104 |
"/health", # Health check endpoint
|