Spaces:
Runtime error
Runtime error
Commit
Β·
d57b950
1
Parent(s):
5d95723
Update tools.py
Browse files
tools.py
CHANGED
|
@@ -50,9 +50,12 @@ class Tools:
|
|
| 50 |
city = location_data["city"]
|
| 51 |
region = location_data["regionName"]
|
| 52 |
country = location_data["countryCode"]
|
| 53 |
-
|
|
|
|
| 54 |
except:
|
| 55 |
-
|
|
|
|
|
|
|
| 56 |
|
| 57 |
def sort_results(
|
| 58 |
self, places: list, sort: str, descending: bool = True, first_n: int = None
|
|
@@ -105,6 +108,7 @@ class Tools:
|
|
| 105 |
)
|
| 106 |
if results["status"] != "OK":
|
| 107 |
return []
|
|
|
|
| 108 |
|
| 109 |
# We always use the first candidate
|
| 110 |
place_id = results["candidates"][0]["place_id"]
|
|
|
|
| 50 |
city = location_data["city"]
|
| 51 |
region = location_data["regionName"]
|
| 52 |
country = location_data["countryCode"]
|
| 53 |
+
location = f"{city}, {region}, {country}"
|
| 54 |
+
print(f"User successfully located in {location}")
|
| 55 |
except:
|
| 56 |
+
location = "San Francisco, California, US"
|
| 57 |
+
print(f"Not able to find user. Defaulting to {location}")
|
| 58 |
+
return location
|
| 59 |
|
| 60 |
def sort_results(
|
| 61 |
self, places: list, sort: str, descending: bool = True, first_n: int = None
|
|
|
|
| 108 |
)
|
| 109 |
if results["status"] != "OK":
|
| 110 |
return []
|
| 111 |
+
print(results)
|
| 112 |
|
| 113 |
# We always use the first candidate
|
| 114 |
place_id = results["candidates"][0]["place_id"]
|