Spaces:
Running
Running
Eric Hierholzer commited on
Commit ยท
069d6cd
1
Parent(s): b13b0da
updates
Browse files- README.md +1 -2
- recommend_app.py +2 -2
- recommendation_engine.py +2 -2
- static/js/autocomplete.js +1 -1
README.md
CHANGED
|
@@ -120,7 +120,7 @@ deactivate
|
|
| 120 |
```sh
|
| 121 |
venv\Scripts\deactivate
|
| 122 |
```
|
| 123 |
-
## DOCKER Deployment (EASY local deployment using Docker)
|
| 124 |
|
| 125 |
```sh
|
| 126 |
docker build -t my-recommend-app .
|
|
@@ -139,4 +139,3 @@ access app at http://0.0.0.0:7860 or http://localhost:7860
|
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
-
|
|
|
|
| 120 |
```sh
|
| 121 |
venv\Scripts\deactivate
|
| 122 |
```
|
| 123 |
+
## DOCKER Deployment (optional EASY local deployment using Docker)
|
| 124 |
|
| 125 |
```sh
|
| 126 |
docker build -t my-recommend-app .
|
|
|
|
| 139 |
|
| 140 |
|
| 141 |
|
|
|
recommend_app.py
CHANGED
|
@@ -46,7 +46,7 @@ def recommend():
|
|
| 46 |
content_type = request.args.get("type", None)
|
| 47 |
fields = request.args.getlist("fields")
|
| 48 |
|
| 49 |
-
#
|
| 50 |
logger.info(f"Received API request: {request.url}")
|
| 51 |
logger.info(f"Raw title received: '{raw_title}'")
|
| 52 |
logger.info(f"Normalized title used for lookup: '{title}'")
|
|
@@ -58,7 +58,7 @@ def recommend():
|
|
| 58 |
if not title:
|
| 59 |
return jsonify({"message": "Title required", "recommendations": []}), 400
|
| 60 |
|
| 61 |
-
#
|
| 62 |
if title not in title_to_index or title_to_index[title] is None:
|
| 63 |
logger.error(f"Title '{title}' is missing from title_to_index or maps to None!")
|
| 64 |
return jsonify({"message": f"'{raw_title}' not found", "recommendations": []}), 404
|
|
|
|
| 46 |
content_type = request.args.get("type", None)
|
| 47 |
fields = request.args.getlist("fields")
|
| 48 |
|
| 49 |
+
# Debugging logs
|
| 50 |
logger.info(f"Received API request: {request.url}")
|
| 51 |
logger.info(f"Raw title received: '{raw_title}'")
|
| 52 |
logger.info(f"Normalized title used for lookup: '{title}'")
|
|
|
|
| 58 |
if not title:
|
| 59 |
return jsonify({"message": "Title required", "recommendations": []}), 400
|
| 60 |
|
| 61 |
+
# Print available keys to debug mismatches
|
| 62 |
if title not in title_to_index or title_to_index[title] is None:
|
| 63 |
logger.error(f"Title '{title}' is missing from title_to_index or maps to None!")
|
| 64 |
return jsonify({"message": f"'{raw_title}' not found", "recommendations": []}), 404
|
recommendation_engine.py
CHANGED
|
@@ -127,13 +127,13 @@ def get_recommendations(title, df, title_to_index, cosine_sim_matrix, top_n=10,
|
|
| 127 |
logger.error(f"Error computing similarity scores for '{title}': {str(e)}")
|
| 128 |
return []
|
| 129 |
|
| 130 |
-
logger.info(f"
|
| 131 |
|
| 132 |
# Sort by similarity
|
| 133 |
sim_scores = sorted(sim_scores, key=lambda x: x[1], reverse=True)
|
| 134 |
sim_scores = sim_scores[1:] # Exclude the input title itself
|
| 135 |
|
| 136 |
-
logger.info(f"
|
| 137 |
|
| 138 |
# If all similarity scores are 0, issue a warning
|
| 139 |
if all(score[1] == 0 for score in sim_scores):
|
|
|
|
| 127 |
logger.error(f"Error computing similarity scores for '{title}': {str(e)}")
|
| 128 |
return []
|
| 129 |
|
| 130 |
+
logger.info(f"Raw similarity scores for '{title}': {sim_scores[:10]}")
|
| 131 |
|
| 132 |
# Sort by similarity
|
| 133 |
sim_scores = sorted(sim_scores, key=lambda x: x[1], reverse=True)
|
| 134 |
sim_scores = sim_scores[1:] # Exclude the input title itself
|
| 135 |
|
| 136 |
+
logger.info(f"Sorted similarity scores for '{title}': {sim_scores[:10]}")
|
| 137 |
|
| 138 |
# If all similarity scores are 0, issue a warning
|
| 139 |
if all(score[1] == 0 for score in sim_scores):
|
static/js/autocomplete.js
CHANGED
|
@@ -61,7 +61,7 @@ export function showSuggestions(suggestions) {
|
|
| 61 |
}
|
| 62 |
suggestionBox.innerHTML = "";
|
| 63 |
suggestionBox.classList.add("d-none");
|
| 64 |
-
getRecommendations();
|
| 65 |
});
|
| 66 |
suggestionBox.appendChild(item);
|
| 67 |
});
|
|
|
|
| 61 |
}
|
| 62 |
suggestionBox.innerHTML = "";
|
| 63 |
suggestionBox.classList.add("d-none");
|
| 64 |
+
getRecommendations();
|
| 65 |
});
|
| 66 |
suggestionBox.appendChild(item);
|
| 67 |
});
|