Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,15 +10,24 @@ 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 |
-
|
| 18 |
"""
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
@tool
|
| 24 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -59,7 +68,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 59 |
|
| 60 |
agent = CodeAgent(
|
| 61 |
model=model,
|
| 62 |
-
tools=[final_answer, image_generation_tool, get_current_time_in_timezone, visit_page, web_search,
|
| 63 |
max_steps=6,
|
| 64 |
verbosity_level=1,
|
| 65 |
grammar=None,
|
|
|
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
@tool
|
| 13 |
+
def days_until_new_year()-> str: #it's import to specify the return type
|
| 14 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 15 |
+
"""A tool that returns how many days are left until new year.
|
| 16 |
Args:
|
| 17 |
+
No arguments.
|
| 18 |
"""
|
| 19 |
+
try:
|
| 20 |
+
import requests
|
| 21 |
+
from bs4 import BeautifulSoup
|
| 22 |
+
response = requests.get("https://www.timeanddate.com/counters/newyear.html")
|
| 23 |
+
response.raise_for_status()
|
| 24 |
+
parsed_content = BeautifulSoup(response.content, 'html_parser')
|
| 25 |
+
element = parsed_content.find('el_2')
|
| 26 |
+
return element.text
|
| 27 |
+
|
| 28 |
+
except Exception as e:
|
| 29 |
+
return f"An exception occured: {str(e)}"
|
| 30 |
+
|
| 31 |
|
| 32 |
@tool
|
| 33 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 68 |
|
| 69 |
agent = CodeAgent(
|
| 70 |
model=model,
|
| 71 |
+
tools=[final_answer, image_generation_tool, get_current_time_in_timezone, visit_page, web_search, days_until_new_year], ## add your tools here (don't remove final answer)
|
| 72 |
max_steps=6,
|
| 73 |
verbosity_level=1,
|
| 74 |
grammar=None,
|