chris-clippd commited on
Commit
decb3b7
·
verified ·
1 Parent(s): 3236cd6

Added school ID to get_top_ranked_team

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -1,4 +1,5 @@
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
 
2
  import datetime
3
  import requests
4
  import pytz
@@ -20,6 +21,27 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
20
 
21
  @tool
22
  def get_top_ranked_team(division:str, gender:str)-> str:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  """A tool that fetches the name of the top ranked ream for a given division and gender.
24
  Args:
25
  division: A string representing the division. This can only take values from ["NCAA Division I", "NCAA Division II", "NCAA Division III].
 
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
+ from bs4 import BeautifulSoup
3
  import datetime
4
  import requests
5
  import pytz
 
21
 
22
  @tool
23
  def get_top_ranked_team(division:str, gender:str)-> str:
24
+ """A tool that fetches the name and ID of the top ranked ream for a given division and gender.
25
+ Args:
26
+ division: A string representing the division. This can only take values from ["NCAA Division I", "NCAA Division II", "NCAA Division III].
27
+ gender: A string representing the gender. This can only take vaues from ["Women", "Men"].
28
+ """
29
+ api_url = f"https://scoreboard.clippd.com/api/rankings/leaderboard?rankingType=Team&gender={gender}&division={division}&sortField=rank&season=2025&limit=1&offset=0"
30
+ headers = {
31
+ 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)',
32
+ 'Content-Type': 'application/json'
33
+ }
34
+ response = requests.get(api_url, headers=headers)
35
+ if response.status_code == 200:
36
+ data = response.json()
37
+ school_name = data.get("results", [{}])[0].get("schoolName", "No school name available")
38
+ school_id = data.get("results", [{}])[0].get("schoolId", "No school name available")
39
+ return school_name, school_id
40
+ else:
41
+ return "Error: Unable to fetch the school."
42
+
43
+ @tool
44
+ def get_team(division:str, gender:str)-> str:
45
  """A tool that fetches the name of the top ranked ream for a given division and gender.
46
  Args:
47
  division: A string representing the division. This can only take values from ["NCAA Division I", "NCAA Division II", "NCAA Division III].