Spaces:
Sleeping
Sleeping
Download tool.py from aneesarom/datetime_tool: direct link, hf CLI and curl.
- Browser
- Download file 661 Bytes
-
https://huggingface.co/spaces/aneesarom/datetime_tool/resolve/main/tool.py
- Command line
-
hf download hf://spaces/aneesarom/datetime_tool/tool.py
-
curl -L -o tool.py https://huggingface.co/spaces/aneesarom/datetime_tool/resolve/main/tool.py
661 Bytes
| from typing import Any, Optional | |
| from smolagents.tools import Tool | |
| import datetime | |
| class DateTimeTool(Tool): | |
| """ | |
| A simple tool to get the current local date and time. | |
| """ | |
| name = "get_today_datetime" | |
| description = "Get the current local date and time in the format 'YYYY-MM-DD HH:MM:SS'." | |
| inputs = {} | |
| output_type = "string" | |
| def forward(self): | |
| """ | |
| Executes the tool. | |
| Returns: | |
| str: Current date and time. | |
| """ | |
| from datetime import datetime | |
| return datetime.now().strftime("%Y-%m-%d %H:%M:%S") | |
| def __init__(self, *args, **kwargs): | |
| self.is_initialized = False | |