hp1318 commited on
Commit
323afad
·
verified ·
1 Parent(s): 47edb3d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -42,14 +42,10 @@ 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
- # 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}"
 
42
  search_tool = DuckDuckGoSearchTool()
43
  results = search_tool.forward(f"Top tourist attractions in {city}")
44
 
45
+ if results:
46
+ return f"Top 5 Tourist Attractions in {city}:\n{results}"
47
+
48
+ return f"No tourist attractions found for {city}."
 
 
 
 
49
 
50
  except Exception as e:
51
  return f"Error fetching tourist attractions: {e}"