Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,19 +4,28 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
-
def my_custom_tool(
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
-
"""A tool that
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
arg2: the second argument
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
import numpy as np
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
| 12 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 13 |
@tool
|
| 14 |
+
def my_custom_tool()-> str: #it's import to specify the return type
|
| 15 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 16 |
+
"""A tool that randomly selects a dad joke from the list of the greatest dad jokes of all time
|
| 17 |
Args:
|
| 18 |
+
|
|
|
|
| 19 |
"""
|
| 20 |
+
path = Path("dad_jokes.txt")
|
| 21 |
+
if not path.exists():
|
| 22 |
+
raise FileNotFoundError(f"{path} not found")
|
| 23 |
+
|
| 24 |
+
jokes = []
|
| 25 |
+
with path.open(encoding="utf-8") as f:
|
| 26 |
+
jokes = [line.rstrip("\n") for line in f if line.strip()]
|
| 27 |
+
|
| 28 |
+
return jokes[np.random.randint(len(jokes))]
|
| 29 |
|
| 30 |
@tool
|
| 31 |
def get_current_time_in_timezone(timezone: str) -> str:
|