Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
|
|
2 |
import datetime
|
3 |
import requests
|
4 |
-
import pytz
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
|
@@ -9,31 +9,34 @@ 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 |
-
|
14 |
-
|
15 |
-
Args:
|
16 |
-
arg1: the first argument
|
17 |
-
arg2: the second argument
|
18 |
-
"""
|
19 |
-
return "What magic will you build ?"
|
20 |
-
|
21 |
-
@tool
|
22 |
-
def get_current_time_in_timezone(timezone: str) -> str:
|
23 |
-
"""A tool that fetches the current local time in a specified timezone.
|
24 |
Args:
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
"""
|
27 |
try:
|
28 |
-
#
|
29 |
-
|
30 |
-
|
31 |
-
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
32 |
-
return f"The current local time in {timezone} is: {local_time}"
|
33 |
-
except Exception as e:
|
34 |
-
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
35 |
|
|
|
|
|
|
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
final_answer = FinalAnswerTool()
|
38 |
|
39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
|
|
1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
2 |
+
from meteostat import Stations, Daily
|
3 |
import datetime
|
4 |
import requests
|
|
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
|
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
+
def World_temperature(lat: float, lon: float) -> str:
|
13 |
+
"""Fetches the current temperature in a specified location using latitude & longitude.
|
14 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
Args:
|
16 |
+
lat: Latitude of the location (e.g., 51.51 for London).
|
17 |
+
lon: Longitude of the location (e.g., -0.13 for London).
|
18 |
+
|
19 |
+
Returns:
|
20 |
+
A string with the current temperature.
|
21 |
"""
|
22 |
try:
|
23 |
+
# Get nearest weather station
|
24 |
+
stations = Stations().nearby(lat, lon).fetch(1)
|
25 |
+
station_id = stations.index[0]
|
|
|
|
|
|
|
|
|
26 |
|
27 |
+
# Get today's weather data
|
28 |
+
today = datetime.datetime.today()
|
29 |
+
data = Daily(station_id, today, today).fetch()
|
30 |
|
31 |
+
if not data.empty:
|
32 |
+
temp = data["tavg"].iloc[0] # Get average temperature
|
33 |
+
return f"The current temperature at ({lat}, {lon}) is {temp}°C."
|
34 |
+
else:
|
35 |
+
return "No temperature data available for this location."
|
36 |
+
|
37 |
+
except Exception as e:
|
38 |
+
return f"Error fetching temperature: {str(e)}"
|
39 |
+
|
40 |
final_answer = FinalAnswerTool()
|
41 |
|
42 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|