hjxdl 0.1.42__py3-none-any.whl → 0.1.44__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hdl/_version.py +2 -2
- hdl/models/utils.py +7 -7
- hdl/utils/desc/func_desc.py +3 -3
- hdl/utils/desc/template.py +1 -1
- hdl/utils/llm/chat.py +27 -2
- {hjxdl-0.1.42.dist-info → hjxdl-0.1.44.dist-info}/METADATA +1 -1
- {hjxdl-0.1.42.dist-info → hjxdl-0.1.44.dist-info}/RECORD +9 -9
- {hjxdl-0.1.42.dist-info → hjxdl-0.1.44.dist-info}/WHEEL +0 -0
- {hjxdl-0.1.42.dist-info → hjxdl-0.1.44.dist-info}/top_level.txt +0 -0
hdl/_version.py
CHANGED
hdl/models/utils.py
CHANGED
@@ -49,10 +49,10 @@ def load_model(
|
|
49
49
|
init_args = checkpoint['init_args']
|
50
50
|
assert model_name is not None
|
51
51
|
model = MODEL_DICT[model_name](**init_args)
|
52
|
-
model.load_state_dict(
|
53
|
-
checkpoint['model_state_dict'],
|
52
|
+
model.load_state_dict(
|
53
|
+
checkpoint['model_state_dict'],
|
54
54
|
)
|
55
|
-
|
55
|
+
|
56
56
|
elif isinstance(model, nn.DataParallel):
|
57
57
|
state_dict = checkpoint['model_state_dict']
|
58
58
|
from collections import OrderedDict
|
@@ -66,10 +66,10 @@ def load_model(
|
|
66
66
|
new_state_dict[k] = v
|
67
67
|
model.load_state_dict(new_state_dict)
|
68
68
|
else:
|
69
|
-
model.load_state_dict(
|
70
|
-
checkpoint['model_state_dict'],
|
69
|
+
model.load_state_dict(
|
70
|
+
checkpoint['model_state_dict'],
|
71
71
|
)
|
72
|
-
|
72
|
+
|
73
73
|
if optimizer is not None:
|
74
74
|
optimizer.load_state_dict(checkpoint['optimizer_state_dict'])
|
75
75
|
epoch = checkpoint.get('epoch', 0)
|
@@ -80,4 +80,4 @@ def load_model(
|
|
80
80
|
else:
|
81
81
|
model.eval()
|
82
82
|
|
83
|
-
return model, optimizer, epoch, loss
|
83
|
+
return model, optimizer, epoch, loss
|
hdl/utils/desc/func_desc.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
FN_DESC = {
|
2
2
|
"get_weather": """
|
3
3
|
## 函数名:get_weather
|
4
|
-
|
4
|
+
描述:只有在用户询问一个城市的天气时,调用此工具获得此城市的天气信息
|
5
5
|
参数:
|
6
6
|
# city (str): 城市名
|
7
7
|
返回值 (str):天气信息
|
@@ -17,7 +17,7 @@ FN_DESC = {
|
|
17
17
|
""",
|
18
18
|
"get_datetime_by_cityname": """
|
19
19
|
## 函数名:get_datetime_by_cityname
|
20
|
-
|
20
|
+
描述:只有在用户询问一个城市当前的日期或时间时,调用此工具可以获得此城市当前的日期和时间
|
21
21
|
参数:
|
22
22
|
# city (str): 城市名
|
23
23
|
返回值 (str):这个城市当前所在时区的日期和时间
|
@@ -33,7 +33,7 @@ FN_DESC = {
|
|
33
33
|
""",
|
34
34
|
"web_search_text": """
|
35
35
|
## 函数名:web_search_text
|
36
|
-
|
36
|
+
描述:在用户明确要联网查询回答他的问题时,调用此工具可以获得该问题联网搜索的相关内容,若用户的提问中没有提到“联网查询”,则不要调用此工具
|
37
37
|
参数:
|
38
38
|
# query_text (str): 从用户提的问题中获取,用于在网络中搜索信息
|
39
39
|
# max_results (int, optional): 搜索条目的最大数目,若用户指定了数目,则使用用户指定的数目,若用户提问中没有指定,你需要在下面的json中"max_results"这一项指定为数值3。
|
hdl/utils/desc/template.py
CHANGED
@@ -6,7 +6,7 @@ FN_TEMPLATE = """
|
|
6
6
|
"function_name":需要要调用的函数的名称。
|
7
7
|
"params":函数所需的参数,一般为字符串,注意字符串要在双引号 "" 之间。
|
8
8
|
|
9
|
-
|
9
|
+
若不需要调用函数,或提供的函数无法解决用户的问题时,或没有达到下文中相关函数描述的触发条件时,则返回如下字典,并且不应包含其他多余文字,避免出现格式化问题:
|
10
10
|
{
|
11
11
|
"function_name": null
|
12
12
|
}
|
hdl/utils/llm/chat.py
CHANGED
@@ -87,6 +87,15 @@ def chat_oai_invoke(
|
|
87
87
|
return response.choices[0].message.content
|
88
88
|
|
89
89
|
def run_tool_with_kwargs(tool, func_kwargs):
|
90
|
+
"""Run the specified tool with the provided keyword arguments.
|
91
|
+
|
92
|
+
Args:
|
93
|
+
tool (callable): The tool to be executed.
|
94
|
+
func_kwargs (dict): The keyword arguments to be passed to the tool.
|
95
|
+
|
96
|
+
Returns:
|
97
|
+
The result of executing the tool with the provided keyword arguments.
|
98
|
+
"""
|
90
99
|
return tool(**func_kwargs)
|
91
100
|
|
92
101
|
class OpenAI_M():
|
@@ -231,7 +240,15 @@ class OpenAI_M():
|
|
231
240
|
return self.invoke(prompt_final, **kwargs)
|
232
241
|
|
233
242
|
def get_decision(self, prompt: str, **kwargs: t.Any):
|
234
|
-
|
243
|
+
"""Get decision based on the given prompt.
|
244
|
+
|
245
|
+
Args:
|
246
|
+
prompt (str): The prompt for decision making.
|
247
|
+
**kwargs: Additional keyword arguments for decision making.
|
248
|
+
|
249
|
+
Returns:
|
250
|
+
str: The decision dictionary string.
|
251
|
+
"""
|
235
252
|
prompt_final = FN_TEMPLATE
|
236
253
|
for tool in self.tools:
|
237
254
|
prompt_final += self.tool_desc.get(tool.__name__, "")
|
@@ -241,7 +258,15 @@ class OpenAI_M():
|
|
241
258
|
return decision_dict_str
|
242
259
|
|
243
260
|
def get_tool_result(self, prompt: str, **kwargs: t.Any):
|
244
|
-
|
261
|
+
"""Get the result of a tool based on the decision made.
|
262
|
+
|
263
|
+
Args:
|
264
|
+
prompt (str): The prompt to make a decision.
|
265
|
+
**kwargs: Additional keyword arguments.
|
266
|
+
|
267
|
+
Returns:
|
268
|
+
str: The result of the tool.
|
269
|
+
"""
|
245
270
|
decision_dict_str = self.get_decision(prompt, **kwargs)
|
246
271
|
try:
|
247
272
|
decision_dict = json.loads(decision_dict_str)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
hdl/__init__.py,sha256=GffnD0jLJdhkd-vo989v40N90sQbofkayRBwxc6TVhQ,72
|
2
|
-
hdl/_version.py,sha256=
|
2
|
+
hdl/_version.py,sha256=IIqs5uWJ8FFsWjDm6cFCsir1SFd1NDSs1R-SbdEIUJQ,413
|
3
3
|
hdl/args/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
hdl/args/loss_args.py,sha256=s7YzSdd7IjD24rZvvOrxLLFqMZQb9YylxKeyelSdrTk,70
|
5
5
|
hdl/controllers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -108,7 +108,7 @@ hdl/models/model_dict.py,sha256=uRh13nch7rab3DajnDR_usp_1R0b37WUgNoiqOobk-s,402
|
|
108
108
|
hdl/models/norm_flows.py,sha256=nROlAaToUOtqi99_BPe6rlPHpUS38YFAtDll1xmGv5U,830
|
109
109
|
hdl/models/optim_dict.py,sha256=xvefZwCGebIXhRLSbcoGa3WVUWW2kEEm0Gsgp8Q9SQw,231
|
110
110
|
hdl/models/rxn.py,sha256=6MEkzjWEgWgl14EkdprvVtycX1q-xlYnXekM1ROKFL0,1557
|
111
|
-
hdl/models/utils.py,sha256=
|
111
|
+
hdl/models/utils.py,sha256=LgeZhsGw3_VAjgMFB9vGamIFoe9UAHM21xhDIRA8vtE,2210
|
112
112
|
hdl/ops/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
113
113
|
hdl/ops/utils.py,sha256=GIe95pJYVqOQQ91ELb1tfogVFzGg2VJdQmIFX8aHeyM,1053
|
114
114
|
hdl/optims/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -122,12 +122,12 @@ hdl/utils/database_tools/connect.py,sha256=KUnVG-8raifEJ_N0b3c8LkTTIfn9NIyw8LX6q
|
|
122
122
|
hdl/utils/database_tools/datetime.py,sha256=xqE2xNiOpADzX-R8_bM0bioJRF3Ay9Jp1CAG6dy6uVI,1202
|
123
123
|
hdl/utils/database_tools/web.py,sha256=vZJYWA02QbyUUMGLDX710cexn7RlfWeHa8YwK3UsDZ0,1934
|
124
124
|
hdl/utils/desc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
125
|
-
hdl/utils/desc/func_desc.py,sha256=
|
126
|
-
hdl/utils/desc/template.py,sha256=
|
125
|
+
hdl/utils/desc/func_desc.py,sha256=wjGAfMPmpj_iSNJvi6vpRBDIuQGF318aL44wRdz8TK0,1719
|
126
|
+
hdl/utils/desc/template.py,sha256=K45KX6LwHXW-VcPa5jUJRUDmUQMX0-zSi3tXUHlyMG8,1235
|
127
127
|
hdl/utils/general/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
128
128
|
hdl/utils/general/glob.py,sha256=8-RCnt6L297wMIfn34ZAMCsGCZUjHG3MGglGZI1cX0g,491
|
129
129
|
hdl/utils/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
130
|
-
hdl/utils/llm/chat.py,sha256=
|
130
|
+
hdl/utils/llm/chat.py,sha256=Yo4moFbRk0y4XN7GkLvoQD9p-8XgR-mVj9LcYFGv-PE,10749
|
131
131
|
hdl/utils/llm/embs.py,sha256=Tf0FOYrOFZp7qQpEPiSCXzlgyHH0X9HVTUtsup74a9E,7174
|
132
132
|
hdl/utils/llm/extract.py,sha256=2sK_WJzmYIc8iuWaM9DA6Nw3_6q1O4lJ5pKpcZo-bBA,6512
|
133
133
|
hdl/utils/llm/llama_chat.py,sha256=watcHGOaz-bv3x-yDucYlGk5f8FiqfFhwWogrl334fk,4387
|
@@ -135,7 +135,7 @@ hdl/utils/schedulers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
|
|
135
135
|
hdl/utils/schedulers/norm_lr.py,sha256=bDwCmdEK-WkgxQMFBiMuchv8Mm7C0-GZJ6usm-PQk14,4461
|
136
136
|
hdl/utils/weather/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
137
137
|
hdl/utils/weather/weather.py,sha256=k11o6wM15kF8b9NMlEfrg68ak-SfSYLN3nOOflFUv-I,4381
|
138
|
-
hjxdl-0.1.
|
139
|
-
hjxdl-0.1.
|
140
|
-
hjxdl-0.1.
|
141
|
-
hjxdl-0.1.
|
138
|
+
hjxdl-0.1.44.dist-info/METADATA,sha256=Ax6NueiUU7GZifaDxk2uti5gMBfSoXLTqyrdZw_-xMc,737
|
139
|
+
hjxdl-0.1.44.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
|
140
|
+
hjxdl-0.1.44.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
|
141
|
+
hjxdl-0.1.44.dist-info/RECORD,,
|
File without changes
|
File without changes
|