hp1318 commited on
Commit
47edb3d
·
verified ·
1 Parent(s): 19d06fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
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
- if results:
46
- top_places = '\n'.join([f"{i+1}. {r['title']}" for i, r in enumerate(results[:5])])
 
 
 
47
  return f"Top 5 Tourist Attractions in {city}:\n{top_places}"
48
-
49
- return f"No tourist attractions found for {city}."
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