Test to try to get music playing to work
Browse files- tools/play_music.py +20 -19
tools/play_music.py
CHANGED
|
@@ -1,27 +1,28 @@
|
|
| 1 |
from typing import Any, Optional
|
| 2 |
from smolagents.tools import Tool
|
| 3 |
-
import duckduckgo_search
|
| 4 |
|
| 5 |
-
class
|
| 6 |
-
name = "
|
| 7 |
-
description = "
|
| 8 |
-
inputs = {'
|
| 9 |
output_type = "string"
|
| 10 |
|
| 11 |
-
def __init__(self,
|
| 12 |
super().__init__()
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
self.ddgs = DDGS(**kwargs)
|
| 21 |
|
| 22 |
def forward(self, query: str) -> str:
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
| 1 |
from typing import Any, Optional
|
| 2 |
from smolagents.tools import Tool
|
| 3 |
+
#import duckduckgo_search
|
| 4 |
|
| 5 |
+
class PlaySomeMusicMeastro(Tool):
|
| 6 |
+
name = "play_music"
|
| 7 |
+
description = "Play a piece of music then returns sound to the listener."
|
| 8 |
+
inputs = {'query_song': {'type': 'string', 'description': 'The song to play.'}}
|
| 9 |
output_type = "string"
|
| 10 |
|
| 11 |
+
def __init__(self, **kwargs):
|
| 12 |
super().__init__()
|
| 13 |
+
# try:
|
| 14 |
+
# from duckduckgo_search import DDGS
|
| 15 |
+
# except ImportError as e:
|
| 16 |
+
# raise ImportError(
|
| 17 |
+
# "You must install package `duckduckgo_search` to run this tool: for instance run `pip install duckduckgo-search`."
|
| 18 |
+
# ) from e
|
| 19 |
+
# self.ddgs = DDGS(**kwargs)
|
|
|
|
| 20 |
|
| 21 |
def forward(self, query: str) -> str:
|
| 22 |
+
gr.Audio(value="../resources/GenAI Revolution.mp3", autoplay=True)
|
| 23 |
+
|
| 24 |
+
# results = self.ddgs.text(query, max_results=self.max_results)
|
| 25 |
+
# if len(results) == 0:
|
| 26 |
+
# raise Exception("No results found! Try a less restrictive/shorter query.")
|
| 27 |
+
# postprocessed_results = [f"[{result['title']}]({result['href']})\n{result['body']}" for result in results]
|
| 28 |
+
return "Dit zou een side effect moeten leveren"
|