Spaces:
Sleeping
Sleeping
Commit
·
60572ef
1
Parent(s):
9d76e23
msid api bug fix
Browse files- DataEmbeddings.bin +2 -2
- __pycache__/app.cpython-311.pyc +0 -0
- app.py +27 -4
- src/api/__pycache__/routes.cpython-311.pyc +0 -0
DataEmbeddings.bin
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:54e444e5881756030f44025dd516011affa16cd20449642677778a144f06a468
|
| 3 |
+
size 988422
|
__pycache__/app.cpython-311.pyc
ADDED
|
Binary file (11.8 kB). View file
|
|
|
app.py
CHANGED
|
@@ -203,15 +203,38 @@ async def get_recommendations_by_id_api(msid: str, k: int = 5):
|
|
| 203 |
Get recommendations based on a given MSID.
|
| 204 |
"""
|
| 205 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
if not hasattr(fastapi_app.state, "recommender") or fastapi_app.state.recommender is None:
|
| 207 |
logger.error("Recommender is not available.")
|
| 208 |
raise HTTPException(status_code=503, detail="Recommender service not available")
|
| 209 |
|
| 210 |
-
|
| 211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
except Exception as e:
|
| 213 |
-
logger.error(f"
|
| 214 |
-
raise HTTPException(status_code=500, detail=
|
| 215 |
|
| 216 |
@fastapi_app.post("/recommendations/feedback/user/", response_model=FeedbackResponse)
|
| 217 |
async def submit_user_feedback_api(payload: FeedbackPayload):
|
|
|
|
| 203 |
Get recommendations based on a given MSID.
|
| 204 |
"""
|
| 205 |
try:
|
| 206 |
+
# Validate input parameters
|
| 207 |
+
if not msid or not isinstance(msid, str):
|
| 208 |
+
raise HTTPException(status_code=400, detail="Invalid MSID provided")
|
| 209 |
+
|
| 210 |
+
if not isinstance(k, int) or k < 1 or k > 10:
|
| 211 |
+
raise HTTPException(status_code=400, detail="k must be an integer between 1 and 10")
|
| 212 |
+
|
| 213 |
+
# Check if recommender service is available
|
| 214 |
if not hasattr(fastapi_app.state, "recommender") or fastapi_app.state.recommender is None:
|
| 215 |
logger.error("Recommender is not available.")
|
| 216 |
raise HTTPException(status_code=503, detail="Recommender service not available")
|
| 217 |
|
| 218 |
+
# Get recommendations with error handling
|
| 219 |
+
try:
|
| 220 |
+
response = fastapi_app.state.recommender.get_recommendations_by_id(msid, k)
|
| 221 |
+
if not response:
|
| 222 |
+
raise HTTPException(status_code=404, detail=f"No recommendations found for MSID: {msid}")
|
| 223 |
+
return response
|
| 224 |
+
|
| 225 |
+
except ValueError as ve:
|
| 226 |
+
logger.error(f"Value error in get_recommendations_by_id for msid '{msid}': {ve}")
|
| 227 |
+
raise HTTPException(status_code=400, detail=str(ve))
|
| 228 |
+
|
| 229 |
+
except Exception as e:
|
| 230 |
+
logger.error(f"Error getting recommendations for msid '{msid}': {e}", exc_info=True)
|
| 231 |
+
raise HTTPException(status_code=500, detail="Internal server error while getting recommendations")
|
| 232 |
+
|
| 233 |
+
except HTTPException as he:
|
| 234 |
+
raise he
|
| 235 |
except Exception as e:
|
| 236 |
+
logger.error(f"Unexpected error in get_recommendations_by_id_api for msid '{msid}': {e}", exc_info=True)
|
| 237 |
+
raise HTTPException(status_code=500, detail="An unexpected error occurred")
|
| 238 |
|
| 239 |
@fastapi_app.post("/recommendations/feedback/user/", response_model=FeedbackResponse)
|
| 240 |
async def submit_user_feedback_api(payload: FeedbackPayload):
|
src/api/__pycache__/routes.cpython-311.pyc
CHANGED
|
Binary files a/src/api/__pycache__/routes.cpython-311.pyc and b/src/api/__pycache__/routes.cpython-311.pyc differ
|
|
|