Spaces:
Sleeping
Sleeping
File size: 770 Bytes
90c769d 088a23a b117711 90c769d b312790 90c769d b312790 90c769d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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
|