Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ from Gradio_UI import GradioUI
|
|
| 12 |
|
| 13 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 14 |
@tool
|
| 15 |
-
def get_song_lyrics(artist:str = "artist", song:str = "song") ->
|
| 16 |
"""
|
| 17 |
Fetches the lyrics of a song from the lyrics.ovh API.
|
| 18 |
|
|
@@ -21,9 +21,9 @@ def get_song_lyrics(artist:str = "artist", song:str = "song") -> Dict[str, str]:
|
|
| 21 |
song: The name of the song. Defaults to "song".
|
| 22 |
|
| 23 |
Returns:
|
| 24 |
-
|
| 25 |
-
-
|
| 26 |
-
-
|
| 27 |
"""
|
| 28 |
|
| 29 |
if len(artist)<1:
|
|
@@ -41,9 +41,9 @@ def get_song_lyrics(artist:str = "artist", song:str = "song") -> Dict[str, str]:
|
|
| 41 |
response = requests.get(url)
|
| 42 |
|
| 43 |
if json.loads(response.text).get('error','ok').lower()=='no lyrics found':
|
| 44 |
-
return
|
| 45 |
if response.status_code == 200:
|
| 46 |
-
return
|
| 47 |
|
| 48 |
return {"Error": str(response.status_code)}
|
| 49 |
|
|
|
|
| 12 |
|
| 13 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 14 |
@tool
|
| 15 |
+
def get_song_lyrics(artist:str = "artist", song:str = "song") -> str:
|
| 16 |
"""
|
| 17 |
Fetches the lyrics of a song from the lyrics.ovh API.
|
| 18 |
|
|
|
|
| 21 |
song: The name of the song. Defaults to "song".
|
| 22 |
|
| 23 |
Returns:
|
| 24 |
+
String containing either:
|
| 25 |
+
- 'No lyrics found' if the lyrics are not available.
|
| 26 |
+
- 'lyrics: <song lyrics>' if the lyrics are successfully retrieved.
|
| 27 |
"""
|
| 28 |
|
| 29 |
if len(artist)<1:
|
|
|
|
| 41 |
response = requests.get(url)
|
| 42 |
|
| 43 |
if json.loads(response.text).get('error','ok').lower()=='no lyrics found':
|
| 44 |
+
return 'No lyrics found'
|
| 45 |
if response.status_code == 200:
|
| 46 |
+
return f'lyrics: {json.loads(response.text).get('lyrics')}'
|
| 47 |
|
| 48 |
return {"Error": str(response.status_code)}
|
| 49 |
|