Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,23 +9,27 @@ from Gradio_UI import GradioUI
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
|
|
|
|
|
|
|
| 12 |
@tool
|
| 13 |
-
def my_custom_tool(arg1: str) -> str:
|
| 14 |
-
"""A tool that generates a funny coding joke.
|
| 15 |
|
| 16 |
-
Args:
|
| 17 |
-
arg1 (str):
|
|
|
|
| 18 |
|
| 19 |
-
Returns:
|
| 20 |
-
str: A generated joke.
|
| 21 |
"""
|
| 22 |
-
search_query = f"funny programming joke about {
|
| 23 |
results = DuckDuckGoSearchTool(search_query)
|
| 24 |
|
| 25 |
if results:
|
| 26 |
-
return f"The joke on {
|
| 27 |
else:
|
| 28 |
-
return f"Sorry, I couldn't find a joke about {
|
|
|
|
| 29 |
|
| 30 |
@tool
|
| 31 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
|
| 12 |
+
from smolagents import tool, DuckDuckGoSearchTool
|
| 13 |
+
|
| 14 |
@tool
|
| 15 |
+
def my_custom_tool(arg1: str, arg2: int) -> str:
|
| 16 |
+
"""A tool that generates a funny coding joke.
|
| 17 |
|
| 18 |
+
Args:
|
| 19 |
+
arg1 (str): Level of funny (e.g., "low", "medium", "high").
|
| 20 |
+
arg2 (int): Topic of the joke (e.g., 1 for Python, 2 for JavaScript).
|
| 21 |
|
| 22 |
+
Returns:
|
| 23 |
+
str: A generated joke.
|
| 24 |
"""
|
| 25 |
+
search_query = f"funny programming joke about {arg2}"
|
| 26 |
results = DuckDuckGoSearchTool(search_query)
|
| 27 |
|
| 28 |
if results:
|
| 29 |
+
return f"The joke on {arg2} at level {arg1}: {results[0]}"
|
| 30 |
else:
|
| 31 |
+
return f"Sorry, I couldn't find a joke about {arg2}."
|
| 32 |
+
|
| 33 |
|
| 34 |
@tool
|
| 35 |
def get_current_time_in_timezone(timezone: str) -> str:
|