Spaces:
Sleeping
Sleeping
Update app.py
Browse filesweather search changed to duckgo
app.py
CHANGED
|
@@ -68,14 +68,15 @@ def get_movie_recommendation(mood: str, location: str, user_preferences: dict) -
|
|
| 68 |
- "link" (str): A link to more information about the movie.
|
| 69 |
"""
|
| 70 |
|
| 71 |
-
# Fetch weather data
|
| 72 |
-
|
| 73 |
-
|
|
|
|
| 74 |
|
| 75 |
-
if
|
| 76 |
-
return {"error":
|
| 77 |
|
| 78 |
-
weather_condition =
|
| 79 |
|
| 80 |
# Define mood & weather-based genre mapping
|
| 81 |
genre_mapping = {
|
|
|
|
| 68 |
- "link" (str): A link to more information about the movie.
|
| 69 |
"""
|
| 70 |
|
| 71 |
+
# Fetch weather data using DuckDuckGo search
|
| 72 |
+
search_tool = DuckDuckGoSearchTool()
|
| 73 |
+
weather_query = f"current weather in {location}"
|
| 74 |
+
weather_results = search_tool.search(weather_query)
|
| 75 |
|
| 76 |
+
if not weather_results:
|
| 77 |
+
return {"error": "Could not fetch weather data."}
|
| 78 |
|
| 79 |
+
weather_condition = weather_results[0].get("snippet", "").lower()
|
| 80 |
|
| 81 |
# Define mood & weather-based genre mapping
|
| 82 |
genre_mapping = {
|