matteo-falcioni commited on
Commit
fe93c5d
·
verified ·
1 Parent(s): f5977ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -16
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 get_temperature(city_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 gets the temperature of a given city
15
- Args:
16
- city_name: the name of the city for which we want the temperature
17
- """
18
- async with python_weather.Client(unit=python_weather.IMPERIAL) as client:
19
-
20
- # Fetch a weather forecast from a city.
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: