Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -83,6 +83,23 @@ def get_box_score_data(links: list) -> dict:
|
|
83 |
except Exception as e:
|
84 |
return {"Error": f"Error fetching boxScore data: {str(e)}"}
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
final_answer = FinalAnswerTool()
|
87 |
search_tool = DuckDuckGoSearchTool()
|
88 |
visit_webpage_tool = VisitWebpageTool()
|
@@ -115,7 +132,8 @@ agent = CodeAgent(
|
|
115 |
visit_webpage_tool,
|
116 |
user_input_tool,
|
117 |
get_box_score_links,
|
118 |
-
get_box_score_data
|
|
|
119 |
], # Add your tools here (don't remove final answer)
|
120 |
max_steps=6,
|
121 |
verbosity_level=1,
|
|
|
83 |
except Exception as e:
|
84 |
return {"Error": f"Error fetching boxScore data: {str(e)}"}
|
85 |
|
86 |
+
@tool
|
87 |
+
def get_stats_from_boxScore_data(box_scores: dict, stat: str) -> dict:
|
88 |
+
"""A tool that fetches the player names and box score statistic for the provided stat and from the provided box score data
|
89 |
+
Args:
|
90 |
+
box_scores: A dictionary representing the box score data for all of last nights games
|
91 |
+
stat: A string representing the statistic that this function will return for each player in box_scores
|
92 |
+
"""
|
93 |
+
try:
|
94 |
+
stats = {}
|
95 |
+
stat_key = ('Basic Box Score Stats', stat)
|
96 |
+
for teams in box_scores.keys():
|
97 |
+
for player in box_scores[teams]:
|
98 |
+
stats[player[list(player.keys())[0]]]=player[stat_key]
|
99 |
+
return stats
|
100 |
+
except Exception as e:
|
101 |
+
return {"Error": f"Error fetching boxScore data for given statistic: {str(e)}"}
|
102 |
+
|
103 |
final_answer = FinalAnswerTool()
|
104 |
search_tool = DuckDuckGoSearchTool()
|
105 |
visit_webpage_tool = VisitWebpageTool()
|
|
|
132 |
visit_webpage_tool,
|
133 |
user_input_tool,
|
134 |
get_box_score_links,
|
135 |
+
get_box_score_data,
|
136 |
+
get_stats_from_boxScore_data
|
137 |
], # Add your tools here (don't remove final answer)
|
138 |
max_steps=6,
|
139 |
verbosity_level=1,
|