Spaces:
Sleeping
Sleeping
Update app.py
Browse filesAdded a new random function
app.py
CHANGED
@@ -33,6 +33,15 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
33 |
except Exception as e:
|
34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
final_answer = FinalAnswerTool()
|
38 |
model = HfApiModel(
|
@@ -51,7 +60,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
51 |
|
52 |
agent = CodeAgent(
|
53 |
model=model,
|
54 |
-
tools=[final_answer, get_current_time_in_timezone],
|
55 |
max_steps=6,
|
56 |
verbosity_level=1,
|
57 |
grammar=None,
|
@@ -62,4 +71,4 @@ agent = CodeAgent(
|
|
62 |
)
|
63 |
|
64 |
|
65 |
-
GradioUI(agent).launch()
|
|
|
33 |
except Exception as e:
|
34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
35 |
|
36 |
+
@tool
|
37 |
+
def get_dad_joke() -> str:
|
38 |
+
"""A tool that an arbitrary dad joke.
|
39 |
+
"""
|
40 |
+
try:
|
41 |
+
r = requests.get("https://icanhazdadjoke.com")
|
42 |
+
return f"The current joke is {r}"
|
43 |
+
except Exception as e:
|
44 |
+
return f"Error fetching joke"
|
45 |
|
46 |
final_answer = FinalAnswerTool()
|
47 |
model = HfApiModel(
|
|
|
60 |
|
61 |
agent = CodeAgent(
|
62 |
model=model,
|
63 |
+
tools=[final_answer, get_current_time_in_timezone, get_dad_joke],
|
64 |
max_steps=6,
|
65 |
verbosity_level=1,
|
66 |
grammar=None,
|
|
|
71 |
)
|
72 |
|
73 |
|
74 |
+
GradioUI(agent).launch(share=True)
|