Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,38 @@
|
|
| 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 |
|
| 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
|
| 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 second argument
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
+
import geocoder
|
| 4 |
+
import python_weather
|
| 5 |
import requests
|
| 6 |
import pytz
|
| 7 |
import yaml
|
| 8 |
+
import asyncio
|
| 9 |
from tools.final_answer import FinalAnswerTool
|
| 10 |
|
| 11 |
from Gradio_UI import GradioUI
|
| 12 |
|
| 13 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 14 |
@tool
|
| 15 |
+
def get_current_weather(arg1: str)-> str: #it's import to specify the return type
|
| 16 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 17 |
+
"""A tool that fetches current weather at specified location
|
| 18 |
Args:
|
| 19 |
+
arg1: city
|
|
|
|
| 20 |
"""
|
| 21 |
+
|
| 22 |
+
async with python_weather.Client(unit=python_weather.METRIC) as client:
|
| 23 |
+
# fetch a weather forecast from a city
|
| 24 |
+
weather = await client.get(arg1)
|
| 25 |
+
|
| 26 |
+
# returns the current day's forecast temperature (int)
|
| 27 |
+
return weather.temperature
|
| 28 |
+
|
| 29 |
+
@tool
|
| 30 |
+
def get_location_lat_lng() -> (float, float):
|
| 31 |
+
"""A tool that fetches current location
|
| 32 |
+
"""
|
| 33 |
+
g = geocoder.ip('me')
|
| 34 |
+
current_location = g.city
|
| 35 |
+
return current_location
|
| 36 |
|
| 37 |
@tool
|
| 38 |
def get_current_time_in_timezone(timezone: str) -> str:
|