Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,13 +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
|
| 13 |
-
"""
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
@tool
|
| 21 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def get_location(arg1:str, arg2:int)-> str:
|
| 13 |
+
"""retrieves the users approximate location using there ip address."""
|
| 14 |
+
try:
|
| 15 |
+
response = requests.get("https://ipinfo.io.json")
|
| 16 |
+
data = response.json()
|
| 17 |
+
location_info = {
|
| 18 |
+
"city": data.get("city", "unknown"),
|
| 19 |
+
"region": data.get("region", "unkown"),
|
| 20 |
+
"country": data.get("county", "unkown"),
|
| 21 |
+
"latitude": data.get("loc", "").split(',')[0] if data.get("loc")else "unknown",
|
| 22 |
+
"longitude": data.get("loc", "").split(',')[1] if data.get("loc")else"unknown",
|
| 23 |
+
"ip": data.get("ip", unknown)
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
return location_info
|
| 27 |
+
except Exception as e:
|
| 28 |
+
return{"error": str(e)}
|
| 29 |
|
| 30 |
@tool
|
| 31 |
def get_current_time_in_timezone(timezone: str) -> str:
|