Spaces:
Runtime error
Runtime error
final
Browse files
app.py
CHANGED
@@ -138,7 +138,7 @@ def auto_retrieve_fn_strategy(
|
|
138 |
return str(response)
|
139 |
|
140 |
# loading CSV data
|
141 |
-
sheet_names = ['Teams', 'Players', 'Schedule', 'Player_Stats']
|
142 |
dict_of_dfs = {sheet: get_df_from_workbook(sheet) for sheet in sheet_names}
|
143 |
|
144 |
engine = create_engine("sqlite+pysqlite:///:memory:")
|
@@ -182,8 +182,16 @@ info_emails_players = VectorStoreInfo(
|
|
182 |
MetadataInfo(
|
183 |
name="from_to",
|
184 |
type="str",
|
|
|
185 |
description="""
|
186 |
-
email sent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
"""
|
188 |
),
|
189 |
]
|
@@ -191,23 +199,23 @@ email sent by a Golden States Warriors player, one of [Stephen Curry, Andrew Wi
|
|
191 |
|
192 |
strategy1 = Document(
|
193 |
text="Against the Phoenix Suns, we'll focus on ball movement and three-point shooting. Our starting five will consist of Stephen Curry, Klay Thompson, Andrew Wiggins, Draymond Green, and James Wiseman. We'll exploit their defense with our perimeter shooting while Draymond Green handles the playmaking and defense in the paint.",
|
194 |
-
metadata={'
|
195 |
)
|
196 |
strategy2 = Document(
|
197 |
text="Facing the Lakers, we'll emphasize defensive intensity and fast-break opportunities. Our starting lineup will feature Stephen Curry, Klay Thompson, Andrew Wiggins, Draymond Green, and Kevon Looney. We need to limit LeBron's impact and push the pace on offense to tire their older roster.",
|
198 |
-
metadata={'
|
199 |
)
|
200 |
strategy3 = Document(
|
201 |
text="Against the Denver Nuggets, our strategy is to control the boards and exploit their interior defense. Starting with Stephen Curry, Klay Thompson, Andrew Wiggins, Draymond Green, and James Wiseman, we aim to dominate the paint on both ends. We'll also look for opportunities to run in transition.",
|
202 |
-
metadata={'
|
203 |
)
|
204 |
strategy4 = Document(
|
205 |
text="Facing the Milwaukee Bucks, we'll prioritize perimeter defense and transition play. Our starting five will consist of Stephen Curry, Klay Thompson, Andrew Wiggins, Draymond Green, and Kevon Looney. We must limit Giannis' drives to the basket and exploit their defense with quick ball movement.",
|
206 |
-
metadata={'
|
207 |
)
|
208 |
strategy5 = Document(
|
209 |
text="In the matchup against the Brooklyn Nets, we'll focus on high-scoring games and exploiting defensive weaknesses. Our starting lineup will include Stephen Curry, Klay Thompson, Andrew Wiggins, Draymond Green, and Kevon Looney. We'll aim to outshoot and outpace them in a high-octane offensive battle.",
|
210 |
-
metadata={'
|
211 |
)
|
212 |
|
213 |
chroma_client_strategy = chromadb.Client()
|
@@ -221,13 +229,13 @@ vector_index_strategy.insert_nodes([strategy1, strategy2, strategy3, strategy4,
|
|
221 |
# setting up metadata
|
222 |
top_k = 1
|
223 |
info_strategy = VectorStoreInfo(
|
224 |
-
content_info="Game strategy by Steve Kerr for the Golden States Warriors against
|
225 |
metadata_info=[
|
226 |
MetadataInfo(
|
227 |
-
name="
|
228 |
type="str",
|
229 |
description="""
|
230 |
-
Game strategy for Golden State Warriors against
|
231 |
"""
|
232 |
),
|
233 |
]
|
@@ -244,18 +252,19 @@ def main():
|
|
244 |
sql_nba_tool = QueryEngineTool.from_defaults(
|
245 |
query_engine=sql_query_engine, #
|
246 |
name='sql_nba_tool',
|
247 |
-
description=("""Do not use this tool for queries
|
248 |
Use this tool for translating a natural language query into a SQL query over tables containing:
|
249 |
1. teams, containing historical information about NBA teams
|
250 |
2. players, containing information about the team that each player plays for
|
251 |
3. schedule, containing information related to the entire NBA game schedule
|
252 |
4. player_stats, containing information related to all NBA player stats
|
|
|
253 |
"""
|
254 |
),
|
255 |
)
|
256 |
|
257 |
description_emails = f"""\
|
258 |
-
Use this tool to
|
259 |
The vector database schema is given below:
|
260 |
{info_emails_players.json()}
|
261 |
"""
|
@@ -267,7 +276,7 @@ def main():
|
|
267 |
)
|
268 |
|
269 |
description_strategy = f"""\
|
270 |
-
Use this tool to look up information about the game strategy.
|
271 |
The vector database schema is given below:
|
272 |
{info_strategy.json()}
|
273 |
"""
|
|
|
138 |
return str(response)
|
139 |
|
140 |
# loading CSV data
|
141 |
+
sheet_names = ['Teams', 'Players', 'Schedule', 'Player_Stats', 'GSW_Players_Salary']
|
142 |
dict_of_dfs = {sheet: get_df_from_workbook(sheet) for sheet in sheet_names}
|
143 |
|
144 |
engine = create_engine("sqlite+pysqlite:///:memory:")
|
|
|
182 |
MetadataInfo(
|
183 |
name="from_to",
|
184 |
type="str",
|
185 |
+
# description="email sent to an NBA player by a Golden States Warriors player, one of [Stephen Curry, Andrew Wiggins, 'Draymond Green', 'Klay Thompson'], to any other NBA player"
|
186 |
description="""
|
187 |
+
email sent from a Golden States Warriors player to another NBA player, one of
|
188 |
+
Stephen Curry to Kevin Durant,
|
189 |
+
Draymond Green to Nikola Jokic,
|
190 |
+
Klay Thompson to LeBron James,
|
191 |
+
Draymond Green to Giannis Antetokounmpo,
|
192 |
+
Andrew Wiggins to Luka Dončić,
|
193 |
+
Klay Thompson to Devin Booker,
|
194 |
+
Draymond Green to Jayson Tatum
|
195 |
"""
|
196 |
),
|
197 |
]
|
|
|
199 |
|
200 |
strategy1 = Document(
|
201 |
text="Against the Phoenix Suns, we'll focus on ball movement and three-point shooting. Our starting five will consist of Stephen Curry, Klay Thompson, Andrew Wiggins, Draymond Green, and James Wiseman. We'll exploit their defense with our perimeter shooting while Draymond Green handles the playmaking and defense in the paint.",
|
202 |
+
metadata={'opponent': 'Phoenix Suns'}
|
203 |
)
|
204 |
strategy2 = Document(
|
205 |
text="Facing the Lakers, we'll emphasize defensive intensity and fast-break opportunities. Our starting lineup will feature Stephen Curry, Klay Thompson, Andrew Wiggins, Draymond Green, and Kevon Looney. We need to limit LeBron's impact and push the pace on offense to tire their older roster.",
|
206 |
+
metadata={'opponent': 'Lakers'}
|
207 |
)
|
208 |
strategy3 = Document(
|
209 |
text="Against the Denver Nuggets, our strategy is to control the boards and exploit their interior defense. Starting with Stephen Curry, Klay Thompson, Andrew Wiggins, Draymond Green, and James Wiseman, we aim to dominate the paint on both ends. We'll also look for opportunities to run in transition.",
|
210 |
+
metadata={'opponent': 'Denver Nuggets'}
|
211 |
)
|
212 |
strategy4 = Document(
|
213 |
text="Facing the Milwaukee Bucks, we'll prioritize perimeter defense and transition play. Our starting five will consist of Stephen Curry, Klay Thompson, Andrew Wiggins, Draymond Green, and Kevon Looney. We must limit Giannis' drives to the basket and exploit their defense with quick ball movement.",
|
214 |
+
metadata={'opponent': 'Milwaukee Bucks'}
|
215 |
)
|
216 |
strategy5 = Document(
|
217 |
text="In the matchup against the Brooklyn Nets, we'll focus on high-scoring games and exploiting defensive weaknesses. Our starting lineup will include Stephen Curry, Klay Thompson, Andrew Wiggins, Draymond Green, and Kevon Looney. We'll aim to outshoot and outpace them in a high-octane offensive battle.",
|
218 |
+
metadata={'opponent': 'Brooklyn Nets'}
|
219 |
)
|
220 |
|
221 |
chroma_client_strategy = chromadb.Client()
|
|
|
229 |
# setting up metadata
|
230 |
top_k = 1
|
231 |
info_strategy = VectorStoreInfo(
|
232 |
+
content_info="Game strategy by Steve Kerr for the Golden States Warriors against opponent NBA teams.",
|
233 |
metadata_info=[
|
234 |
MetadataInfo(
|
235 |
+
name="opponent",
|
236 |
type="str",
|
237 |
description="""
|
238 |
+
Game strategy for Golden State Warriors against opponent NBA teams, one of [Phoenix Suns, Lakers, Nuggets, Milwaukee Buck, Brooklyn Nets].
|
239 |
"""
|
240 |
),
|
241 |
]
|
|
|
252 |
sql_nba_tool = QueryEngineTool.from_defaults(
|
253 |
query_engine=sql_query_engine, #
|
254 |
name='sql_nba_tool',
|
255 |
+
description=("""Do not use this tool for queries related to game strategy.
|
256 |
Use this tool for translating a natural language query into a SQL query over tables containing:
|
257 |
1. teams, containing historical information about NBA teams
|
258 |
2. players, containing information about the team that each player plays for
|
259 |
3. schedule, containing information related to the entire NBA game schedule
|
260 |
4. player_stats, containing information related to all NBA player stats
|
261 |
+
5. GSW_players_salary, containing information related to the salary of Golden State Warriors players
|
262 |
"""
|
263 |
),
|
264 |
)
|
265 |
|
266 |
description_emails = f"""\
|
267 |
+
Use this tool to retrieve emails between NBA players.
|
268 |
The vector database schema is given below:
|
269 |
{info_emails_players.json()}
|
270 |
"""
|
|
|
276 |
)
|
277 |
|
278 |
description_strategy = f"""\
|
279 |
+
Use this tool to look up information about the game strategy of Golden State Warriors against other NBA teams.
|
280 |
The vector database schema is given below:
|
281 |
{info_strategy.json()}
|
282 |
"""
|