-
Notifications
You must be signed in to change notification settings - Fork 20
/
get_time.py
61 lines (48 loc) · 1.66 KB
/
get_time.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import ast
import json
import pytz
def get_time(timezone):
from datetime import datetime
datetime = datetime.now(pytz.timezone(timezone))
return f"当前日期和时间:{datetime}"
class time_tool:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"timezone": ("STRING", {"default": "Asia/Shanghai"}),
"is_enable": ("BOOLEAN", {"default": True}),
}
}
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("tool",)
FUNCTION = "time"
# OUTPUT_NODE = False
CATEGORY = "大模型派对(llm_party)/工具(tools)"
def time(self, timezone, is_enable=True):
if is_enable == False:
return (None,)
output = [
{
"type": "function",
"function": {
"name": "get_time",
"description": "用于查询任意时区的时间",
"parameters": {
"type": "object",
"properties": {
"timezone": {
"type": "string",
"description": "需要查询的时区,例如:Asia/Shanghai",
"default": str(timezone),
}
},
"required": ["timezone"],
},
},
}
]
out = json.dumps(output, ensure_ascii=False)
return (out,)
if __name__ == "__main__":
print(time_tool().time("Asia/Shanghai"))