Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,6 +27,37 @@ def fetch_marathon_plan(goal_time: str) -> str:
|
|
| 27 |
else:
|
| 28 |
return f"Could not find a specific plan for {goal_time}, but you can check Runner's World for more details."
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
final_answer = FinalAnswerTool()
|
| 31 |
|
| 32 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
|
|
|
| 27 |
else:
|
| 28 |
return f"Could not find a specific plan for {goal_time}, but you can check Runner's World for more details."
|
| 29 |
|
| 30 |
+
# Fetch marathons in Europe for 2025
|
| 31 |
+
@tool
|
| 32 |
+
def fetch_european_marathons_2025() -> str:
|
| 33 |
+
"""Fetches a list of marathons in Europe in 2025 from MarathonRunnersDiary."""
|
| 34 |
+
url = "http://www.marathonrunnersdiary.com/races/europe-marathons-list.php"
|
| 35 |
+
response = requests.get(url)
|
| 36 |
+
|
| 37 |
+
if response.status_code != 200:
|
| 38 |
+
return "Failed to fetch marathon data."
|
| 39 |
+
|
| 40 |
+
soup = BeautifulSoup(response.text, 'html.parser')
|
| 41 |
+
|
| 42 |
+
# Locate the marathon table (this is based on the structure of the website)
|
| 43 |
+
marathons = []
|
| 44 |
+
table = soup.find('table', {'class': 'racedatatable'}) # Adjust the class if necessary
|
| 45 |
+
|
| 46 |
+
if table:
|
| 47 |
+
rows = table.find_all('tr')[1:] # Skip the header row
|
| 48 |
+
for row in rows:
|
| 49 |
+
columns = row.find_all('td')
|
| 50 |
+
if len(columns) >= 4:
|
| 51 |
+
marathon_name = columns[0].get_text(strip=True)
|
| 52 |
+
marathon_date = columns[1].get_text(strip=True)
|
| 53 |
+
marathon_location = columns[2].get_text(strip=True)
|
| 54 |
+
marathons.append(f"{marathon_name} on {marathon_date} in {marathon_location}")
|
| 55 |
+
|
| 56 |
+
if marathons:
|
| 57 |
+
return "\n".join(marathons)
|
| 58 |
+
else:
|
| 59 |
+
return "No marathons found for 2025."
|
| 60 |
+
|
| 61 |
final_answer = FinalAnswerTool()
|
| 62 |
|
| 63 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|