Spaces:
Sleeping
Sleeping
Updated get_top_ranked_team to refine the returned dictionary
Browse files
app.py
CHANGED
|
@@ -21,7 +21,8 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 21 |
|
| 22 |
@tool
|
| 23 |
def get_top_ranked_team(division:str, gender:str)-> dict:
|
| 24 |
-
"""A tool that returns a dictionary of information
|
|
|
|
| 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 values from ["Women", "Men"].
|
|
@@ -35,9 +36,10 @@ def get_top_ranked_team(division:str, gender:str)-> dict:
|
|
| 35 |
if response.status_code == 200:
|
| 36 |
data = response.json()
|
| 37 |
school_info = data.get("results", [{}])[0]
|
|
|
|
| 38 |
return school_info
|
| 39 |
else:
|
| 40 |
-
return "Error: Unable to fetch the school."
|
| 41 |
|
| 42 |
@tool
|
| 43 |
def get_team_results(school_id: str) -> dict:
|
|
|
|
| 21 |
|
| 22 |
@tool
|
| 23 |
def get_top_ranked_team(division:str, gender:str)-> dict:
|
| 24 |
+
"""A tool that returns a dictionary of information about the top ranked ream for a given division and gender.
|
| 25 |
+
This dictionary includes the team name, their board name (i.e. the short form of their name) and their school ID.
|
| 26 |
Args:
|
| 27 |
division: A string representing the division. This can only take values from ["NCAA Division I", "NCAA Division II", "NCAA Division III].
|
| 28 |
gender: A string representing the gender. This can only take values from ["Women", "Men"].
|
|
|
|
| 36 |
if response.status_code == 200:
|
| 37 |
data = response.json()
|
| 38 |
school_info = data.get("results", [{}])[0]
|
| 39 |
+
school_info = {k: school_info[k] for k in ["schoolName", "boardName", "schoolId"] if k in school_info}
|
| 40 |
return school_info
|
| 41 |
else:
|
| 42 |
+
return "Error: Unable to fetch the school information."
|
| 43 |
|
| 44 |
@tool
|
| 45 |
def get_team_results(school_id: str) -> dict:
|