Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,41 +19,6 @@ from Gradio_UI import GradioUI
|
|
| 19 |
|
| 20 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 21 |
|
| 22 |
-
@tool
|
| 23 |
-
def get_today_football_matches() -> str:
|
| 24 |
-
"""Fetches and displays today's football matches.
|
| 25 |
-
Returns:
|
| 26 |
-
A formatted string listing today's football matches with teams, competition, and match time.
|
| 27 |
-
"""
|
| 28 |
-
from datetime import datetime
|
| 29 |
-
import requests
|
| 30 |
-
|
| 31 |
-
today = datetime.today().strftime('%Y-%m-%d')
|
| 32 |
-
api_url = f"https://api.football-data.org/v4/matches?dateFrom={today}&dateTo={today}"
|
| 33 |
-
headers = {"X-Auth-Token": "GET https://api.football-data.org/v4/matches"} # Replace with your actual API key
|
| 34 |
-
|
| 35 |
-
try:
|
| 36 |
-
response = requests.get(api_url, headers=headers)
|
| 37 |
-
if response.status_code != 200:
|
| 38 |
-
return "Failed to fetch matches. Please check your API key or try again later."
|
| 39 |
-
|
| 40 |
-
matches = response.json().get("matches", [])
|
| 41 |
-
if not matches:
|
| 42 |
-
return "No football matches found for today."
|
| 43 |
-
|
| 44 |
-
result = "⚽ Today's Football Matches ⚽\n"
|
| 45 |
-
for match in matches:
|
| 46 |
-
home = match["homeTeam"]["name"]
|
| 47 |
-
away = match["awayTeam"]["name"]
|
| 48 |
-
competition = match["competition"]["name"]
|
| 49 |
-
time = match["utcDate"].split("T")[1][:5] # Extracts HH:MM format
|
| 50 |
-
|
| 51 |
-
result += f"{home} vs {away} - {competition} at {time} UTC\n"
|
| 52 |
-
|
| 53 |
-
return result
|
| 54 |
-
except Exception as e:
|
| 55 |
-
return f"An error occurred: {str(e)}"
|
| 56 |
-
|
| 57 |
@tool
|
| 58 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 59 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 19 |
|
| 20 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
@tool
|
| 23 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 24 |
"""A tool that fetches the current local time in a specified timezone.
|