roieri100 commited on
Commit
702a877
·
verified ·
1 Parent(s): 3ad2963

Update app.py

Browse files

Add get_songs tool

Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -49,6 +49,19 @@ def get_player_info(player_name:str)-> dict:
49
  return player_details
50
 
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
54
  @tool
@@ -98,7 +111,7 @@ with open("prompts.yaml", 'r') as stream:
98
 
99
  agent = CodeAgent(
100
  model=model,
101
- tools=[final_answer, get_current_time_in_timezone, get_player_info], ## add your tools here (don't remove final answer)
102
  max_steps=6,
103
  verbosity_level=1,
104
  grammar=None,
 
49
  return player_details
50
 
51
 
52
+ @tool
53
+ def get_songs_by_artist(artist_name:str)-> List:
54
+ """
55
+ A tool that gets a name of an artist, read a file with song details and return all the artist's songs according to the file.
56
+ Args:
57
+ artist_name: the name of the artist
58
+ """
59
+ df = pd.read_csv('spotify-2023.csv')
60
+ artist_name = artist_name.lower()
61
+ df['artist(s)_name'] = df['artist(s)_name'].str.lower()
62
+ songs = df.apply(lambda row: artist_name in row['artist(s)_name'].lower(), axis=1)['track_name'].tolist()
63
+ return songs
64
+
65
 
66
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
67
  @tool
 
111
 
112
  agent = CodeAgent(
113
  model=model,
114
+ tools=[final_answer, get_current_time_in_timezone, get_songs_by_artist], ## add your tools here (don't remove final answer)
115
  max_steps=6,
116
  verbosity_level=1,
117
  grammar=None,