Add tools
Browse files
app.py
CHANGED
|
@@ -9,14 +9,22 @@ 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
|
| 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:
|
|
@@ -51,7 +59,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 51 |
|
| 52 |
agent = CodeAgent(
|
| 53 |
model=model,
|
| 54 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 55 |
max_steps=6,
|
| 56 |
verbosity_level=1,
|
| 57 |
grammar=None,
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def check_daytime_or_nighttime_from_current_time(current_time :str)-> str: #it's import to specify the return type
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
+
"""A tool that checks whether it's nighttime or daytime based on timestamp
|
| 15 |
Args:
|
| 16 |
+
current_time: A string representing current time in %Y-%m-%d %H:%M:%S format
|
|
|
|
| 17 |
"""
|
| 18 |
+
|
| 19 |
+
# Convert the string back to a datetime object
|
| 20 |
+
dt = datetime.datetime.strptime(local_time_str, "%Y-%m-%d %H:%M:%S")
|
| 21 |
+
|
| 22 |
+
# Check if the hour is between 6 and 18
|
| 23 |
+
if 6 <= dt.hour < 18:
|
| 24 |
+
return "It's daytime"
|
| 25 |
+
else:
|
| 26 |
+
return "It's nighttime"
|
| 27 |
+
|
| 28 |
|
| 29 |
@tool
|
| 30 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 59 |
|
| 60 |
agent = CodeAgent(
|
| 61 |
model=model,
|
| 62 |
+
tools=[get_current_time_in_timezone, check_daytime_or_nighttime_from_current_time, DuckDuckGoSearchTool, image_generation_tool, final_answer], ## add your tools here (don't remove final answer)
|
| 63 |
max_steps=6,
|
| 64 |
verbosity_level=1,
|
| 65 |
grammar=None,
|