Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
@@ -9,15 +9,19 @@ 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 |
-
arg1:
|
| 17 |
-
arg2: the
|
| 18 |
"""
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
@tool
|
| 23 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -57,7 +61,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 57 |
|
| 58 |
agent = CodeAgent(
|
| 59 |
model=model,
|
| 60 |
-
tools=[final_answer, get_current_time_in_timezone], ## add your tools here (don't remove final answer) image_generation_tool, multiply_two_int_numbers,
|
| 61 |
max_steps=6,
|
| 62 |
verbosity_level=1,
|
| 63 |
grammar=None,
|
|
|
|
| 1 |
+
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel, load_tool, tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def coffee_drinking_permission(hour:int, day:int)-> bool: #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 decides whether it is allowed to drink coffee for user at this time or not.
|
| 15 |
Args:
|
| 16 |
+
arg1: time hour (in 24h format)
|
| 17 |
+
arg2: the day of the week
|
| 18 |
"""
|
| 19 |
+
if day.lower() in ('saturday', 'sunday'):
|
| 20 |
+
return False
|
| 21 |
+
if hour < 14:
|
| 22 |
+
return True
|
| 23 |
+
else:
|
| 24 |
+
return False
|
| 25 |
|
| 26 |
@tool
|
| 27 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 61 |
|
| 62 |
agent = CodeAgent(
|
| 63 |
model=model,
|
| 64 |
+
tools=[final_answer, get_current_time_in_timezone, coffee_drinking_permission], ## add your tools here (don't remove final answer) image_generation_tool, multiply_two_int_numbers,
|
| 65 |
max_steps=6,
|
| 66 |
verbosity_level=1,
|
| 67 |
grammar=None,
|