pkduongsu commited on
Commit
4b6c107
·
verified ·
1 Parent(s): 62f88b0

Delete get_pl_data.py

Browse files
Files changed (1) hide show
  1. get_pl_data.py +0 -231
get_pl_data.py DELETED
@@ -1,231 +0,0 @@
1
- from smolagents import tool
2
- import requests
3
- import os
4
- from dotenv import load_dotenv
5
-
6
- load_dotenv()
7
-
8
- headers = {
9
- "x-rapidapi-key": os.getenv("RAPID_API_KEY"),
10
- "x-rapidapi-host": "free-api-live-football-data.p.rapidapi.com"
11
- }
12
-
13
- @tool
14
- def get_pl_standings() -> dict: # return the current Premier League standings
15
- """A tool that returns the current Premier League standings.
16
- Args:
17
- None
18
- Returns:
19
- The current Premier League standings in JSON.
20
- """
21
-
22
- url = "https://free-api-live-football-data.p.rapidapi.com/football-get-standing-all"
23
-
24
- querystring = {"leagueid":"47"}
25
-
26
- try:
27
- response = requests.get(url, headers=headers, params=querystring)
28
- response.raise_for_status()
29
- return response.json()
30
- except Exception as e:
31
- return f"Error fetching Premier League standings: {str(e)}"
32
-
33
- @tool
34
- def get_matches_by_date(date:str) -> dict: # return all matches in the current Premier League season by date
35
- """A tool that returns all matches in the current Premier League season by date.
36
- Args:
37
- date: The date in the format 'YYYYMMDD'.
38
- Returns:
39
- All matches in the current Premier League season by date in JSON.
40
- """
41
-
42
- url = "https://free-api-live-football-data.p.rapidapi.com/football-get-matches-by-date"
43
-
44
- querystring = {"date": date}
45
-
46
- try:
47
- response = requests.get(url, headers=headers, params=querystring)
48
- response.raise_for_status()
49
- return response.json()
50
- except Exception as e:
51
- return f"Error fetching Premier League standings: {str(e)}"
52
-
53
- @tool
54
- def get_head_to_head(eventid: str) -> dict: #return head to head records by the event (match) id
55
- """A tool that returns the head to head records by the event (match) id.
56
- Args:
57
- eventid: The event (match) id.
58
- Returns:
59
- The head to head records in JSON.
60
- """
61
-
62
- url = "https://free-api-live-football-data.p.rapidapi.com/football-get-head-to-head"
63
-
64
- querystring = {"eventid": eventid}
65
-
66
- try:
67
- response = requests.get(url, headers=headers, params=querystring)
68
- response.raise_for_status()
69
- return response.json()
70
- except Exception as e:
71
- return f"Error fetching Premier League standings: {str(e)}"
72
-
73
- @tool
74
- def get_all_teams() -> dict:
75
- """A tool that returns all teams in the Premier League.
76
- Args:
77
- None
78
- Returns:
79
- All teams in the Premier League in JSON.
80
- """
81
-
82
- url = "https://free-api-live-football-data.p.rapidapi.com/football-get-list-all-team"
83
-
84
- querystring = {"leagueid":"47"}
85
-
86
- try:
87
- response = requests.get(url, headers=headers, params=querystring)
88
- response.raise_for_status()
89
- return response.json()
90
- except Exception as e:
91
- return f"Error fetching Premier League standings: {str(e)}"
92
-
93
- @tool
94
- def get_all_players_by_team(teamid: str) -> dict:
95
- """A tool that returns all players by team.
96
- Args:
97
- teamid: The team id.
98
- Returns:
99
- All players by team in JSON.
100
- """
101
-
102
- url = "hhttps://free-api-live-football-data.p.rapidapi.com/football-get-list-player"
103
-
104
- querystring = {"teamid": teamid}
105
-
106
- try:
107
- response = requests.get(url, headers=headers, params=querystring)
108
- response.raise_for_status()
109
- return response.json()
110
- except Exception as e:
111
- return f"Error fetching Premier League standings: {str(e)}"
112
-
113
- @tool
114
- def get_player_details_by_id(playerid: str) -> dict:
115
- """A tool that returns player details by player id.
116
- Args:
117
- playerid: The player id.
118
- Returns:
119
- Player details in JSON.
120
- """
121
-
122
- url = "https://free-api-live-football-data.p.rapidapi.com/football-get-player-detail"
123
-
124
- querystring = {"playerid": playerid}
125
-
126
- try:
127
- response = requests.get(url, headers=headers, params=querystring)
128
- response.raise_for_status()
129
- return response.json()
130
- except Exception as e:
131
- return f"Error fetching Premier League standings: {str(e)}"
132
-
133
- @tool
134
- def get_home_lineup(eventid: str) -> dict:
135
- """A tool that returns the home team lineup by event (match) id.
136
- Args:
137
- eventid: The event (match) id.
138
- Returns:
139
- The home team lineup in JSON.
140
- """
141
-
142
- url = "https://free-api-live-football-data.p.rapidapi.com/football-get-hometeam-lineup"
143
-
144
- querystring = {"eventid": eventid}
145
-
146
- try:
147
- response = requests.get(url, headers=headers, params=querystring)
148
- response.raise_for_status()
149
- return response.json()
150
- except Exception as e:
151
- return f"Error fetching Premier League standings: {str(e)}"
152
-
153
- @tool
154
- def get_away_lineup(eventid: str) -> dict:
155
- """A tool that returns the away team lineup by event (match) id.
156
- Args:
157
- eventid: The event (match) id.
158
- Returns:
159
- The away team lineup in JSON.
160
- """
161
-
162
- url = "https://free-api-live-football-data.p.rapidapi.com/football-get-awayteam-lineup"
163
-
164
- querystring = {"eventid": eventid}
165
-
166
- try:
167
- response = requests.get(url, headers=headers, params=querystring)
168
- response.raise_for_status()
169
- return response.json()
170
- except Exception as e:
171
- return f"Error fetching Premier League standings: {str(e)}"
172
-
173
- @tool
174
- def get_top_goalscorers() -> dict:
175
- """A tool that returns the top goalscorers in the Premier League.
176
- Args:
177
- None
178
- Returns:
179
- The top goalscorers in JSON.
180
- """
181
-
182
- url = "https://free-api-live-football-data.p.rapidapi.com/football-get-top-players-by-goals"
183
-
184
- querystring = {"leagueid":"47"}
185
-
186
- try:
187
- response = requests.get(url, headers=headers, params=querystring)
188
- response.raise_for_status()
189
- return response.json()
190
- except Exception as e:
191
- return f"Error fetching Premier League standings: {str(e)}"
192
-
193
- @tool
194
- def get_top_assisters() -> dict:
195
- """A tool that returns the top assisters in the Premier League.
196
- Args:
197
- None
198
- Returns:
199
- The top assisters in JSON.
200
- """
201
-
202
- url = "https://free-api-live-football-data.p.rapidapi.com/football-get-top-players-by-assists"
203
-
204
- querystring = {"leagueid":"47"}
205
-
206
- try:
207
- response = requests.get(url, headers=headers, params=querystring)
208
- response.raise_for_status()
209
- return response.json()
210
- except Exception as e:
211
- return f"Error fetching Premier League standings: {str(e)}"
212
-
213
- @tool
214
- def get_top_rated_players() -> dict:
215
- """A tool that returns the top rated players in the Premier League.
216
- Args:
217
- None
218
- Returns:
219
- The top rated players in JSON.
220
- """
221
-
222
- url = "https://free-api-live-football-data.p.rapidapi.com/football-get-top-players-by-rating"
223
-
224
- querystring = {"leagueid":"47"}
225
-
226
- try:
227
- response = requests.get(url, headers=headers, params=querystring)
228
- response.raise_for_status()
229
- return response.json()
230
- except Exception as e:
231
- return f"Error fetching Premier League standings: {str(e)}"