Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,24 +9,32 @@ 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 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
# Example usage
|
| 27 |
-
if __name__ == "__main__":
|
| 28 |
-
location = get_location()
|
| 29 |
-
print(location)
|
| 30 |
|
| 31 |
@tool
|
| 32 |
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 |
+
async function getLocation() {
|
| 13 |
+
return new Promise((resolve, reject) => {
|
| 14 |
+
if ("geolocation" in navigator) {
|
| 15 |
+
navigator.geolocation.getCurrentPosition(
|
| 16 |
+
(position) => {
|
| 17 |
+
resolve({
|
| 18 |
+
latitude: position.coords.latitude,
|
| 19 |
+
longitude: position.coords.longitude,
|
| 20 |
+
accuracy: position.coords.accuracy
|
| 21 |
+
});
|
| 22 |
+
},
|
| 23 |
+
(error) => {
|
| 24 |
+
reject({ error: "Location access denied or unavailable." });
|
| 25 |
+
}
|
| 26 |
+
);
|
| 27 |
+
} else {
|
| 28 |
+
reject({ error: "Geolocation is not supported by this browser." });
|
| 29 |
}
|
| 30 |
+
});
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
// Example Usage
|
| 34 |
+
getLocation()
|
| 35 |
+
.then(location => console.log("User Location:", location))
|
| 36 |
+
.catch(error => console.error("Error:", error));
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
@tool
|
| 40 |
def get_current_time_in_timezone(timezone: str) -> str:
|