Upload app.py
Browse files
app.py
CHANGED
|
@@ -33,6 +33,21 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
+
@tool
|
| 37 |
+
def get_public_ip_address() -> str:
|
| 38 |
+
"""A tool that fetches the public IP address of the machine running the script.
|
| 39 |
+
|
| 40 |
+
Returns:
|
| 41 |
+
A string with the public IP address.
|
| 42 |
+
"""
|
| 43 |
+
try:
|
| 44 |
+
# Using the ipify API to get the public IP address
|
| 45 |
+
response = requests.get("https://api.ipify.org?format=json")
|
| 46 |
+
ip = response.json()["ip"]
|
| 47 |
+
return f"The public IP address is: {ip}"
|
| 48 |
+
except Exception as e:
|
| 49 |
+
return f"Error fetching public IP address: {str(e)}"
|
| 50 |
+
|
| 51 |
|
| 52 |
final_answer = FinalAnswerTool()
|
| 53 |
|