sicknick32 commited on
Commit
f85215d
·
verified ·
1 Parent(s): 2bb8a35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -7
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 get_current_location(arg1:str, arg2:int)-> str:
13
- """A tool that finds my current location
14
- Args:
15
- arg1: the first argument
16
- arg2: the second argument
17
- """
18
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
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: