Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,28 +35,52 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 35 |
|
| 36 |
|
| 37 |
@tool
|
| 38 |
-
def
|
| 39 |
"""
|
| 40 |
-
|
| 41 |
Returns:
|
| 42 |
-
|
| 43 |
"""
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
marsWeatherRaw = response.json()
|
| 48 |
-
firstKey = next(iter(marsWeatherRaw))
|
| 49 |
-
marsWeather = {
|
| 50 |
-
'sol': firstKey,
|
| 51 |
-
'temperature': marsWeatherRaw[firstKey]['AT']['av'],
|
| 52 |
-
'wind_speed': marsWeatherRaw[firstKey]['HWS']['av']
|
| 53 |
}
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
final_answer = FinalAnswerTool()
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
@tool
|
| 38 |
+
def get_nba_matches() -> str:
|
| 39 |
"""
|
| 40 |
+
Outil qui récupère les prochains matchs NBA via l'API TheRundown.
|
| 41 |
Returns:
|
| 42 |
+
Une chaîne de caractères contenant une liste lisible des prochains matchs.
|
| 43 |
"""
|
| 44 |
+
url = "https://api.apilayer.com/therundown/affiliates" # Remplacer par l'endpoint spécifique aux matchs NBA si nécessaire.
|
| 45 |
+
headers = {
|
| 46 |
+
"apikey": "7k4hKSUeWkbigKxZiNV5CQ8RSlEd72Cj"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
}
|
| 48 |
+
response = requests.get(url, headers=headers)
|
| 49 |
+
if response.status_code == 200:
|
| 50 |
+
events = response.json()
|
| 51 |
+
# Par exemple, supposons que 'events' est une liste de matchs
|
| 52 |
+
matchs = []
|
| 53 |
+
for event in events.get("events", []):
|
| 54 |
+
# Extraction d'informations fictives (date, équipes, etc.)
|
| 55 |
+
date = event.get("start_time", "Date inconnue")
|
| 56 |
+
teams = event.get("teams", "Match non défini")
|
| 57 |
+
matchs.append(f"{date} : {teams}")
|
| 58 |
+
if matchs:
|
| 59 |
+
return "\n".join(matchs)
|
| 60 |
+
else:
|
| 61 |
+
return "Aucun match NBA trouvé dans la réponse."
|
| 62 |
+
else:
|
| 63 |
+
return f"Erreur lors de la récupération des matchs NBA: {response.status_code}"
|
| 64 |
+
|
| 65 |
+
@tool
|
| 66 |
+
def predict_nba_match(match_info: str) -> str:
|
| 67 |
+
"""
|
| 68 |
+
Outil qui génère un pronostic pour un match NBA.
|
| 69 |
|
| 70 |
+
Args:
|
| 71 |
+
match_info: Une chaîne contenant les informations du match (format attendu par exemple: "ÉquipeA vs ÉquipeB")
|
| 72 |
+
|
| 73 |
+
Returns:
|
| 74 |
+
Une chaîne contenant le pronostic (exemple: "Le pronostic est que ÉquipeA va gagner.").
|
| 75 |
+
"""
|
| 76 |
+
import random
|
| 77 |
+
# On suppose que match_info est au format "ÉquipeA vs ÉquipeB"
|
| 78 |
+
teams = match_info.split(" vs ")
|
| 79 |
+
if len(teams) == 2:
|
| 80 |
+
prediction = random.choice(teams)
|
| 81 |
+
return f"Le pronostic est que {prediction} va gagner."
|
| 82 |
+
else:
|
| 83 |
+
return "Format du match_info incorrect. Veuillez fournir les équipes au format 'ÉquipeA vs ÉquipeB'."
|
| 84 |
|
| 85 |
|
| 86 |
final_answer = FinalAnswerTool()
|