Spaces:
Sleeping
Sleeping
ekhatskevich commited on
Commit ·
eebcf01
1
Parent(s): b77bd3a
fix: address
Browse files- app.py +5 -7
- prompts.yaml +3 -3
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import geoip2.database
|
| 3 |
-
import requests
|
| 4 |
import datetime
|
| 5 |
import pytz
|
| 6 |
import yaml
|
|
@@ -9,17 +8,16 @@ from tools.final_answer import FinalAnswerTool
|
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
@tool
|
| 12 |
-
def show_internet_location()-> str:
|
| 13 |
-
"""A tool that shows
|
|
|
|
|
|
|
| 14 |
"""
|
| 15 |
try:
|
| 16 |
-
response = requests.get("https://api64.ipify.org?format=json")
|
| 17 |
-
public_ip = response.json()["ip"]
|
| 18 |
-
|
| 19 |
reader = geoip2.database.Reader('geo_cities/GeoLite2-City.mmdb')
|
| 20 |
response = reader.city(public_ip)
|
| 21 |
|
| 22 |
-
internet_location = f"
|
| 23 |
return internet_location
|
| 24 |
except Exception as e:
|
| 25 |
return f"Error fetching the response for query internet location: {str(e)}"
|
|
|
|
| 1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import geoip2.database
|
|
|
|
| 3 |
import datetime
|
| 4 |
import pytz
|
| 5 |
import yaml
|
|
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
@tool
|
| 11 |
+
def show_internet_location(public_ip)-> str:
|
| 12 |
+
"""A tool that shows location based on IP address.
|
| 13 |
+
Args:
|
| 14 |
+
public_ip: IP address
|
| 15 |
"""
|
| 16 |
try:
|
|
|
|
|
|
|
|
|
|
| 17 |
reader = geoip2.database.Reader('geo_cities/GeoLite2-City.mmdb')
|
| 18 |
response = reader.city(public_ip)
|
| 19 |
|
| 20 |
+
internet_location = f"IP address {public_ip}, is from {response.country.name}, {response.city.name}"
|
| 21 |
return internet_location
|
| 22 |
except Exception as e:
|
| 23 |
return f"Error fetching the response for query internet location: {str(e)}"
|
prompts.yaml
CHANGED
|
@@ -39,12 +39,12 @@
|
|
| 39 |
```<end_code>
|
| 40 |
|
| 41 |
---
|
| 42 |
-
Task: "What is
|
| 43 |
|
| 44 |
-
Thought: I will use python code to retrieve
|
| 45 |
Code:
|
| 46 |
```py
|
| 47 |
-
result = show_internet_location()
|
| 48 |
final_answer(result)
|
| 49 |
```<end_code>
|
| 50 |
|
|
|
|
| 39 |
```<end_code>
|
| 40 |
|
| 41 |
---
|
| 42 |
+
Task: "What is the location of the IP address: 8.8.8.8?"
|
| 43 |
|
| 44 |
+
Thought: I will use python code to retrieve the location based on IP address provided in the request and then return the final answer using the `final_answer` tool
|
| 45 |
Code:
|
| 46 |
```py
|
| 47 |
+
result = show_internet_location(public_ip)
|
| 48 |
final_answer(result)
|
| 49 |
```<end_code>
|
| 50 |
|