Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,14 +9,23 @@ 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(
|
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:
|
@@ -56,7 +65,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
56 |
|
57 |
agent = CodeAgent(
|
58 |
model=model,
|
59 |
-
tools=[final_answer, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
60 |
max_steps=6,
|
61 |
verbosity_level=1,
|
62 |
grammar=None,
|
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
+
def my_custom_tool(location_name: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 fetches the weather for a provided location_name
|
15 |
Args:
|
16 |
+
location_name: weather location
|
|
|
17 |
"""
|
18 |
+
api_key = "3MfEYSjmLMlWRZCbw7VSLhaGyptxpUYP"
|
19 |
+
location_key = "35341"
|
20 |
+
url = f"http://dataservice.accuweather.com/currentconditions/v1/{location_key}?apikey={api_key}"
|
21 |
+
|
22 |
+
try:
|
23 |
+
response = requests.get(url)
|
24 |
+
data = response.json()
|
25 |
+
return data
|
26 |
+
except Exception as e:
|
27 |
+
return f"Error fetching location"
|
28 |
+
|
29 |
|
30 |
@tool
|
31 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
65 |
|
66 |
agent = CodeAgent(
|
67 |
model=model,
|
68 |
+
tools=[final_answer, get_current_time_in_timezone, my_custom_tool, image_generation_tool], ## add your tools here (don't remove final answer)
|
69 |
max_steps=6,
|
70 |
verbosity_level=1,
|
71 |
grammar=None,
|