Aktraiser commited on
Commit
5fa8814
·
verified ·
1 Parent(s): 179d75d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -20
app.py CHANGED
@@ -37,50 +37,51 @@ def get_current_time_in_timezone(timezone: str) -> str:
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()
 
37
  @tool
38
  def get_nba_matches() -> str:
39
  """
40
+ A tool that retrieves upcoming NBA games via TheRundown API.
41
+
42
  Returns:
43
+ A string containing a human-readable list of upcoming games.
44
  """
45
+ url = "https://api.apilayer.com/therundown/affiliates" # Replace with the NBA-specific endpoint if available.
46
  headers = {
47
+ "apikey": "7k4hKSUeWkbigKxZiNV5CQ8RSlEd72Cj"
48
  }
49
  response = requests.get(url, headers=headers)
50
  if response.status_code == 200:
51
  events = response.json()
52
+ # Suppose 'events' is a dictionary containing a list of games under the key "events"
53
+ games = []
54
  for event in events.get("events", []):
55
+ # Extract relevant information: date, teams, etc.
56
+ date = event.get("start_time", "Unknown date")
57
+ teams = event.get("teams", "Game info not defined")
58
+ games.append(f"{date} : {teams}")
59
+ if games:
60
+ return "\n".join(games)
61
  else:
62
+ return "No NBA games found in the response."
63
  else:
64
+ return f"Error retrieving NBA games: {response.status_code}"
65
 
66
  @tool
67
  def predict_nba_match(match_info: str) -> str:
68
  """
69
+ A tool that generates a prediction for an NBA match.
70
 
71
  Args:
72
+ match_info: A string containing the match details in the format "TeamA vs TeamB".
73
 
74
  Returns:
75
+ A string with the prediction (e.g., "The prediction is that TeamA will win.").
76
  """
77
  import random
78
+ # Assume match_info is in the format "TeamA vs TeamB"
79
  teams = match_info.split(" vs ")
80
  if len(teams) == 2:
81
  prediction = random.choice(teams)
82
+ return f"The prediction is that {prediction} will win."
83
  else:
84
+ return "Incorrect match_info format. Please provide teams in the format 'TeamA vs TeamB'."
85
 
86
 
87
  final_answer = FinalAnswerTool()