Spaces:
Runtime error
Runtime error
Add tell a joke tool
Browse files
app.py
CHANGED
@@ -10,14 +10,19 @@ from Gradio_UI import GradioUI
|
|
10 |
|
11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
12 |
@tool
|
13 |
-
def
|
14 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
15 |
-
"""A tool that
|
16 |
-
Args:
|
17 |
-
arg1: the first argument
|
18 |
-
arg2: the second argument
|
19 |
"""
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
@tool
|
23 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -58,7 +63,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
58 |
|
59 |
agent = CodeAgent(
|
60 |
model=model,
|
61 |
-
tools=[final_answer, image_generation_tool, web_search_tool, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
62 |
max_steps=6,
|
63 |
verbosity_level=1,
|
64 |
grammar=None,
|
|
|
10 |
|
11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
12 |
@tool
|
13 |
+
def tell_a_joke()-> str:
|
14 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
15 |
+
"""A tool that tells a joke.
|
|
|
|
|
|
|
16 |
"""
|
17 |
+
url = "https://v2.jokeapi.dev/joke/Programming,Misc?format=json&blacklistFlags=nsfw,sexist,racist,explicit&type=single&lang=en&amount=1"
|
18 |
+
response = requests.get(url)
|
19 |
+
|
20 |
+
if response.status_code == 200:
|
21 |
+
data = response.json()
|
22 |
+
joke = data.get("joke", "No joke found")
|
23 |
+
return joke
|
24 |
+
else:
|
25 |
+
return "Failed to retrieve joke"
|
26 |
|
27 |
@tool
|
28 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
63 |
|
64 |
agent = CodeAgent(
|
65 |
model=model,
|
66 |
+
tools=[final_answer, image_generation_tool, web_search_tool, get_current_time_in_timezone, tell_a_joke], ## add your tools here (don't remove final answer)
|
67 |
max_steps=6,
|
68 |
verbosity_level=1,
|
69 |
grammar=None,
|