Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,12 +42,15 @@ def get_top_tourist_attractions(city: str) -> str:
|
|
| 42 |
search_tool = DuckDuckGoSearchTool()
|
| 43 |
results = search_tool.forward(f"Top tourist attractions in {city}")
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
| 47 |
return f"Top 5 Tourist Attractions in {city}:\n{top_places}"
|
| 48 |
-
|
| 49 |
-
return f"
|
| 50 |
-
|
| 51 |
except Exception as e:
|
| 52 |
return f"Error fetching tourist attractions: {e}"
|
| 53 |
|
|
|
|
| 42 |
search_tool = DuckDuckGoSearchTool()
|
| 43 |
results = search_tool.forward(f"Top tourist attractions in {city}")
|
| 44 |
|
| 45 |
+
# Debugging: Print raw results
|
| 46 |
+
print("Raw search results:", results)
|
| 47 |
+
|
| 48 |
+
if isinstance(results, list) and all(isinstance(r, dict) for r in results):
|
| 49 |
+
top_places = '\n'.join([f"{i+1}. {r.get('title', 'Unknown')}" for i, r in enumerate(results[:5])])
|
| 50 |
return f"Top 5 Tourist Attractions in {city}:\n{top_places}"
|
| 51 |
+
|
| 52 |
+
return f"Invalid search results for {city}. Please try again."
|
| 53 |
+
|
| 54 |
except Exception as e:
|
| 55 |
return f"Error fetching tourist attractions: {e}"
|
| 56 |
|