Alejadro Sanchez-Giraldo commited on
Commit
796b25f
·
1 Parent(s): 2ffcbc1

added Injuries query

Browse files
Files changed (2) hide show
  1. fpl_client.py +8 -1
  2. nlp_utils.py +5 -0
fpl_client.py CHANGED
@@ -89,4 +89,11 @@ class FPLClient:
89
  logging.debug(f"Players found for team {team_name}: {players}")
90
  return players
91
  logging.warning(f"Team not found: {team_name}")
92
- return "Team not found"
 
 
 
 
 
 
 
 
89
  logging.debug(f"Players found for team {team_name}: {players}")
90
  return players
91
  logging.warning(f"Team not found: {team_name}")
92
+ return "Team not found"
93
+
94
+ def list_injuries(self):
95
+ logging.info("Fetching injuries list")
96
+ players = self.data['elements']
97
+ injuries = [(p['web_name'], p['news']) for p in players if p['news'] and 'injury' in p['news'].lower()]
98
+ logging.debug(f"Injured players: {injuries}")
99
+ return injuries
nlp_utils.py CHANGED
@@ -59,5 +59,10 @@ def process_query(query, fpl_client):
59
 
60
  return "It sound like you need the latest EPL team list: " + "\n" + "\n".join(enumerated_teams)
61
 
 
 
 
 
 
62
 
63
  return "I'm not sure how to help with that."
 
59
 
60
  return "It sound like you need the latest EPL team list: " + "\n" + "\n".join(enumerated_teams)
61
 
62
+ if "injuries" in query.lower():
63
+ injuries = fpl_client.list_injuries()
64
+ formatted_injuries = "\n\n".join([f"Player: {name} Injury: {news}" for name, news in injuries])
65
+ injury_count = len(injuries)
66
+ return f"There are {injury_count} players with injuries:\n\n{formatted_injuries}"
67
 
68
  return "I'm not sure how to help with that."