nangelov commited on
Commit
4e5660b
·
verified ·
1 Parent(s): af0d5eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -13,21 +13,21 @@ from huggingface_hub import login
13
  login(token = os.getenv('nangelov_hf_token'))
14
  FOOTBALL_DATA_TOKEN = os.getenv('football_data_token')
15
 
16
- # Below is an example of a tool that does nothing. Amaze us with your creativity !
17
  @tool
18
  def getCompetitionInitials(competition: str) -> str:
19
  """
20
  Returns the competition initials (code) for a given competition name.
21
 
22
- Example usage:
23
- competitionCode = getCompetitionInitials("Premier League") # Output: PL
24
- competitionCode = getCompetitionInitials("Bundesliga") # Output: BL1
25
-
26
  Args:
27
- competition (str): The full name of the competition.
28
 
29
  Returns:
30
  str: The competition code if found, otherwise None.
 
 
 
 
 
31
  """
32
  competitions = {
33
  "WC": "FIFA World Cup",
@@ -51,7 +51,6 @@ def getCompetitionInitials(competition: str) -> str:
51
  # Return None if no match is found.
52
  return None
53
 
54
- @tool
55
  @tool
56
  def getCompetitionMatchesResultsByDate(competitionInitials: str, match_date: date) -> dict:
57
  """
@@ -59,10 +58,15 @@ def getCompetitionMatchesResultsByDate(competitionInitials: str, match_date: dat
59
 
60
  Args:
61
  competitionInitials (str): The code of the competition (e.g., 'PL' for Premier League).
62
- match_date (date): The date for which to retrieve match results.
63
 
64
  Returns:
65
  dict: The JSON response from the API if successful, or an error message.
 
 
 
 
 
66
  """
67
  # Format the date as needed by the API (e.g., YYYY-MM-DD)
68
  date_str = match_date.isoformat() # converts date to 'YYYY-MM-DD'
@@ -80,8 +84,7 @@ def getCompetitionMatchesResultsByDate(competitionInitials: str, match_date: dat
80
 
81
  # Check if the request was successful.
82
  if response.status_code == 200:
83
- data = response.json() # Parse the JSON response.
84
- return data
85
  else:
86
  # Return error details as a dict
87
  return {"error": response.status_code, "message": response.text}
 
13
  login(token = os.getenv('nangelov_hf_token'))
14
  FOOTBALL_DATA_TOKEN = os.getenv('football_data_token')
15
 
 
16
  @tool
17
  def getCompetitionInitials(competition: str) -> str:
18
  """
19
  Returns the competition initials (code) for a given competition name.
20
 
 
 
 
 
21
  Args:
22
+ competition (str): The full name of the competition, e.g., "Premier League" or "Bundesliga".
23
 
24
  Returns:
25
  str: The competition code if found, otherwise None.
26
+
27
+ Example:
28
+ >>> code = getCompetitionInitials("Premier League")
29
+ >>> print(code)
30
+ PL
31
  """
32
  competitions = {
33
  "WC": "FIFA World Cup",
 
51
  # Return None if no match is found.
52
  return None
53
 
 
54
  @tool
55
  def getCompetitionMatchesResultsByDate(competitionInitials: str, match_date: date) -> dict:
56
  """
 
58
 
59
  Args:
60
  competitionInitials (str): The code of the competition (e.g., 'PL' for Premier League).
61
+ match_date (date): The date for which to retrieve match results (format: YYYY-MM-DD).
62
 
63
  Returns:
64
  dict: The JSON response from the API if successful, or an error message.
65
+
66
+ Example:
67
+ >>> from datetime import date
68
+ >>> results = getCompetitionMatchesResultsByDate("PL", date(2025, 2, 14))
69
+ >>> print(results)
70
  """
71
  # Format the date as needed by the API (e.g., YYYY-MM-DD)
72
  date_str = match_date.isoformat() # converts date to 'YYYY-MM-DD'
 
84
 
85
  # Check if the request was successful.
86
  if response.status_code == 200:
87
+ return response.json() # Parse and return the JSON response.
 
88
  else:
89
  # Return error details as a dict
90
  return {"error": response.status_code, "message": response.text}