Update app.py
Browse files
app.py
CHANGED
|
@@ -3,27 +3,20 @@ import datetime
|
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
-
import python_weather
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
weather = await client.get(city_name)
|
| 22 |
-
|
| 23 |
-
# Fetch the temperature for today.
|
| 24 |
-
temp = weather.temperature
|
| 25 |
-
|
| 26 |
-
return temp.to_string()
|
| 27 |
|
| 28 |
@tool
|
| 29 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 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 |
@tool
|
| 11 |
+
def get_country_by_ip() -> str:
|
| 12 |
+
"""Gets the user's country based on IP address."""
|
| 13 |
+
try:
|
| 14 |
+
response = requests.get("https://ipapi.co/json/")
|
| 15 |
+
data = response.json()
|
| 16 |
+
return f"You are in {data['country_name']} ({data['country_code']})."
|
| 17 |
+
except Exception as e:
|
| 18 |
+
return f"Error getting country: {str(e)}"
|
| 19 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|