Spaces:
Sleeping
Sleeping
| from typing import Any, Optional | |
| from smolagents.tools import Tool | |
| import datetime | |
| import pytz | |
| class GetTime(Tool): | |
| name = "get_time" | |
| description = "Get the current time in a specific timezone." | |
| inputs = {'tz': {'type': 'string', 'description': 'the timezone (such as Asia/Shanghai, Europe/Amsterdam, etc.)'}} | |
| output_type = "string" | |
| def forward(self, tz: str) -> str: | |
| """Get the current time in a specific timezone. | |
| Args: | |
| tz (str): the timezone (such as Asia/Shanghai, Europe/Amsterdam, etc.) | |
| """ | |
| import pytz | |
| from datetime import datetime | |
| return datetime.now(pytz.timezone(tz)).strftime("%Y-%m-%d %H:%M:%S") | |
| def __init__(self, *args, **kwargs): | |
| self.is_initialized = False | |