Spaces:
Sleeping
Sleeping
Upload tool
Browse files
tool.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
from typing import Any, Optional
|
| 2 |
from smolagents.tools import Tool
|
| 3 |
-
import pytz
|
| 4 |
import datetime
|
|
|
|
| 5 |
|
| 6 |
class GetTime(Tool):
|
| 7 |
name = "get_time"
|
|
@@ -9,7 +9,7 @@ class GetTime(Tool):
|
|
| 9 |
inputs = {'tz': {'type': 'string', 'description': 'the timezone (such as Asia/Shanghai, Europe/Amsterdam, etc.)'}}
|
| 10 |
output_type = "string"
|
| 11 |
|
| 12 |
-
def forward(self, tz: str) ->
|
| 13 |
"""Get the current time in a specific timezone.
|
| 14 |
|
| 15 |
Args:
|
|
@@ -18,7 +18,7 @@ class GetTime(Tool):
|
|
| 18 |
import pytz
|
| 19 |
from datetime import datetime
|
| 20 |
|
| 21 |
-
return datetime.now(pytz.timezone(tz))
|
| 22 |
|
| 23 |
def __init__(self, *args, **kwargs):
|
| 24 |
self.is_initialized = False
|
|
|
|
| 1 |
from typing import Any, Optional
|
| 2 |
from smolagents.tools import Tool
|
|
|
|
| 3 |
import datetime
|
| 4 |
+
import pytz
|
| 5 |
|
| 6 |
class GetTime(Tool):
|
| 7 |
name = "get_time"
|
|
|
|
| 9 |
inputs = {'tz': {'type': 'string', 'description': 'the timezone (such as Asia/Shanghai, Europe/Amsterdam, etc.)'}}
|
| 10 |
output_type = "string"
|
| 11 |
|
| 12 |
+
def forward(self, tz: str) -> datetime:
|
| 13 |
"""Get the current time in a specific timezone.
|
| 14 |
|
| 15 |
Args:
|
|
|
|
| 18 |
import pytz
|
| 19 |
from datetime import datetime
|
| 20 |
|
| 21 |
+
return datetime.now(pytz.timezone(tz))
|
| 22 |
|
| 23 |
def __init__(self, *args, **kwargs):
|
| 24 |
self.is_initialized = False
|