Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,8 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
-
|
|
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
|
|
@@ -15,6 +16,34 @@ search_model = HfApiModel(
|
|
| 15 |
streaming=False # ensures the output is plain text
|
| 16 |
)
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
@tool
|
| 19 |
def my_custom_tool(city:str, season:str)-> str: # it's important to specify the return type
|
| 20 |
"""
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
import requests
|
| 8 |
+
from bs4 import BeautifulSoup
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
|
|
|
|
| 16 |
streaming=False # ensures the output is plain text
|
| 17 |
)
|
| 18 |
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
@tool
|
| 23 |
+
def get_top_sightseeing_web(city: str, count: int) -> str:
|
| 24 |
+
"""Searches the web for top sightseeing locations in a given city.
|
| 25 |
+
Args:
|
| 26 |
+
city: Name of the city.
|
| 27 |
+
count: Number of top sightseeing locations to return.
|
| 28 |
+
"""
|
| 29 |
+
# Example using TripAdvisor search URL
|
| 30 |
+
search_url = f"https://www.tripadvisor.com/Search?q={city}+top+sightseeing"
|
| 31 |
+
|
| 32 |
+
try:
|
| 33 |
+
response = requests.get(search_url)
|
| 34 |
+
soup = BeautifulSoup(response.text, 'html.parser')
|
| 35 |
+
|
| 36 |
+
# This is a placeholder logic. You would need to inspect the actual HTML structure.
|
| 37 |
+
attractions = [tag.text for tag in soup.select('.result-title')][:count]
|
| 38 |
+
|
| 39 |
+
if attractions:
|
| 40 |
+
return f"Top {len(attractions)} sightseeing locations in {city}:\n" + "\n".join(f"{i+1}. {spot}" for i, spot in enumerate(attractions))
|
| 41 |
+
else:
|
| 42 |
+
return f"No sightseeing data found for {city}."
|
| 43 |
+
except Exception as e:
|
| 44 |
+
return f"Error retrieving sightseeing data for {city}: {str(e)}"
|
| 45 |
+
|
| 46 |
+
|
| 47 |
@tool
|
| 48 |
def my_custom_tool(city:str, season:str)-> str: # it's important to specify the return type
|
| 49 |
"""
|