Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
2 |
-
|
|
|
3 |
import requests
|
4 |
import pytz
|
5 |
import yaml
|
@@ -8,6 +9,15 @@ from tools.final_answer import FinalAnswerTool
|
|
8 |
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 my_custom_tool(arg1:str, arg2:int)-> 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
|
@@ -41,6 +51,7 @@ def get_horoscope(sign: str, date: str = None) -> str:
|
|
41 |
sign: Zodiac sign (e.g., Aries, Taurus, Gemini)
|
42 |
date: Date in any format (optional)
|
43 |
"""
|
|
|
44 |
# Placeholder logic
|
45 |
if not date:
|
46 |
date = datetime.now().strftime("%Y-%m-%d")
|
@@ -114,7 +125,15 @@ with open("prompts.yaml", 'r') as stream:
|
|
114 |
|
115 |
agent = CodeAgent(
|
116 |
model=model,
|
117 |
-
tools=[final_answer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
max_steps=6,
|
119 |
verbosity_level=1,
|
120 |
grammar=None,
|
|
|
1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
2 |
+
from datetime
|
3 |
+
from dateutil import parser # for flexible date parsing
|
4 |
import requests
|
5 |
import pytz
|
6 |
import yaml
|
|
|
9 |
from Gradio_UI import GradioUI
|
10 |
|
11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
12 |
+
|
13 |
+
|
14 |
+
def parse_date(date_str: str) -> str:
|
15 |
+
try:
|
16 |
+
return parser.parse(date_str).strftime("%Y-%m-%d")
|
17 |
+
except:
|
18 |
+
return datetime.now().strftime("%Y-%m-%d")
|
19 |
+
|
20 |
+
|
21 |
@tool
|
22 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
23 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
|
|
51 |
sign: Zodiac sign (e.g., Aries, Taurus, Gemini)
|
52 |
date: Date in any format (optional)
|
53 |
"""
|
54 |
+
date = parse_date(date)
|
55 |
# Placeholder logic
|
56 |
if not date:
|
57 |
date = datetime.now().strftime("%Y-%m-%d")
|
|
|
125 |
|
126 |
agent = CodeAgent(
|
127 |
model=model,
|
128 |
+
tools=[final_answer,
|
129 |
+
get_horoscope,
|
130 |
+
get_date_panchang,
|
131 |
+
get_holidays,
|
132 |
+
get_panchang_field,
|
133 |
+
get_festivals_today,
|
134 |
+
get_current_time_in_timezone,
|
135 |
+
my_custom_tool,
|
136 |
+
image_generation_tool], ## add your tools here (don't remove final answer)
|
137 |
max_steps=6,
|
138 |
verbosity_level=1,
|
139 |
grammar=None,
|