pycoze 0.1.86__py3-none-any.whl → 0.1.87__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- pycoze/bot/agent/agent.py +1 -1
- pycoze/bot/agent/agent_types/openai_func_call_agent.py +6 -3
- pycoze/bot/agent/assistant.py +2 -2
- pycoze/bot/bot.py +8 -4
- {pycoze-0.1.86.dist-info → pycoze-0.1.87.dist-info}/METADATA +1 -1
- {pycoze-0.1.86.dist-info → pycoze-0.1.87.dist-info}/RECORD +9 -9
- {pycoze-0.1.86.dist-info → pycoze-0.1.87.dist-info}/LICENSE +0 -0
- {pycoze-0.1.86.dist-info → pycoze-0.1.87.dist-info}/WHEEL +0 -0
- {pycoze-0.1.86.dist-info → pycoze-0.1.87.dist-info}/top_level.txt +0 -0
pycoze/bot/agent/agent.py
CHANGED
@@ -34,7 +34,7 @@ def create_openai_func_call_agent_executor(
|
|
34
34
|
tools: list[BaseTool],
|
35
35
|
llm: LanguageModelLike,
|
36
36
|
system_message: str,
|
37
|
-
|
37
|
+
tool_compatibility_mode: str,
|
38
38
|
**kwargs
|
39
39
|
):
|
40
40
|
|
@@ -169,11 +169,14 @@ def create_openai_func_call_agent_executor(
|
|
169
169
|
additional_kwargs={"name": tool_call["function"]["name"]},
|
170
170
|
)
|
171
171
|
tool_messages.append(message)
|
172
|
-
if
|
172
|
+
if tool_compatibility_mode:
|
173
173
|
# HumanMessage
|
174
174
|
tool_msgs_str = repr(tool_messages)
|
175
175
|
tool_messages = [
|
176
|
-
HumanMessage(
|
176
|
+
HumanMessage(
|
177
|
+
content="The tool call is done, the result is as follows:\n"
|
178
|
+
+ tool_msgs_str
|
179
|
+
)
|
177
180
|
]
|
178
181
|
return tool_messages
|
179
182
|
|
pycoze/bot/agent/assistant.py
CHANGED
@@ -18,11 +18,11 @@ class Runnable(RunnableBinding):
|
|
18
18
|
tools: Sequence[BaseTool],
|
19
19
|
llm: LanguageModelLike,
|
20
20
|
assistant_message: str,
|
21
|
-
|
21
|
+
tool_compatibility_mode: bool
|
22
22
|
) -> None:
|
23
23
|
|
24
24
|
agent_executor = create_openai_func_call_agent_executor(
|
25
|
-
tools, llm, assistant_message,
|
25
|
+
tools, llm, assistant_message, tool_compatibility_mode
|
26
26
|
)
|
27
27
|
agent_executor = agent_executor.with_config({"recursion_limit": 50})
|
28
28
|
super().__init__(
|
pycoze/bot/bot.py
CHANGED
@@ -11,7 +11,6 @@ params = utils.arg.read_params_file()
|
|
11
11
|
llm_file = params["appPath"] + "/JsonStorage/llm.json"
|
12
12
|
with open(llm_file, "r", encoding="utf-8") as f:
|
13
13
|
cfg = json.load(f)
|
14
|
-
support_tools = not cfg["model"].startswith("yi-")
|
15
14
|
|
16
15
|
|
17
16
|
def load_role_setting(bot_setting_file: str):
|
@@ -48,9 +47,14 @@ def agent_chat(bot_setting_file, history):
|
|
48
47
|
], # 停用deepseek的工具调用标记,不然会虚构工具调用过程和结果
|
49
48
|
)
|
50
49
|
prompt = role_setting["prompt"]
|
51
|
-
if
|
50
|
+
if (
|
51
|
+
cfg["model"].startswith("deepseek")
|
52
|
+
or cfg["toolCompatibilityMode"]
|
53
|
+
and len(tools) > 0
|
54
|
+
):
|
52
55
|
prompt += """
|
53
|
-
|
56
|
+
如果不确定结果,请务必使用工具查询。
|
57
|
+
如果需要调用工具,请使用以正确markdown中的json代码格式进行结尾(务必保证json格式正确,不要出现反斜杠未转义等问题):
|
54
58
|
```json
|
55
59
|
{"name": 函数名, "parameters": 参数词典}
|
56
60
|
```
|
@@ -64,7 +68,7 @@ def agent_chat(bot_setting_file, history):
|
|
64
68
|
tools=tools,
|
65
69
|
llm=chat,
|
66
70
|
assistant_message=prompt,
|
67
|
-
|
71
|
+
tool_compatibility_mode=cfg["toolCompatibilityMode"],
|
68
72
|
)
|
69
73
|
return asyncio.run(run_agent(agent, history))
|
70
74
|
|
@@ -6,13 +6,13 @@ pycoze/ai/__init__.py,sha256=Smivpb8qbRnzWkzKRe2IxsmKP5Dh8EvngDFdkD_DVLo,73
|
|
6
6
|
pycoze/ai/comfyui.py,sha256=u75tZywkuXiOdm7XST2kBAaveJKpPvY_qTQr_TN9sXk,795
|
7
7
|
pycoze/ai/vram_reserve.py,sha256=s55Cy-Q5mTq-k5oIPbAFwCfrjatjN0QTjQxW7WBTPZI,5738
|
8
8
|
pycoze/bot/__init__.py,sha256=6HHMxDQVOyZM9dtSjQm9tjGnhj4h7CixD0JOvEwTi48,41
|
9
|
-
pycoze/bot/bot.py,sha256=
|
9
|
+
pycoze/bot/bot.py,sha256=w_ddp3IeWryUgIad-_V-SsDzGwYqZXekw5NXbYyXrkk,3041
|
10
10
|
pycoze/bot/agent/__init__.py,sha256=YR9vpkEQn1e4937r_xFPJXUCPBEJ0SFzEQDBe2x3-YA,157
|
11
|
-
pycoze/bot/agent/agent.py,sha256=
|
12
|
-
pycoze/bot/agent/assistant.py,sha256=
|
11
|
+
pycoze/bot/agent/agent.py,sha256=XMTO6s8OJpaOnymT8ZUuJxXx2ICZ3r7Ck0pHJqPPFIs,3346
|
12
|
+
pycoze/bot/agent/assistant.py,sha256=XI4w-rFfbk3qYE0tWcWoya8dz-3cA-QZ0Sanhl3DbKE,1112
|
13
13
|
pycoze/bot/agent/chat.py,sha256=kc0qgcrBSXdiMy49JwThZTV-0PAvzAhiUvbI5ILiSnU,571
|
14
14
|
pycoze/bot/agent/agent_types/__init__.py,sha256=XNvKWq9REE5Wzjm0OZi3CKIQF2UZ9PZkeUuxgFJbrfc,128
|
15
|
-
pycoze/bot/agent/agent_types/openai_func_call_agent.py,sha256=
|
15
|
+
pycoze/bot/agent/agent_types/openai_func_call_agent.py,sha256=bb6zze6lbdiZi9uSim5oWNviGm5sqLOEY6suSP_xyaI,7591
|
16
16
|
pycoze/ui/__init__.py,sha256=7xAfL2lfG7-jllPJEZUJO89xUE9sNzvo1y0WmBswjBI,458
|
17
17
|
pycoze/ui/base.py,sha256=SCXVDK7PpMaBv6ovvabHcfRq_d2AWM0BRyxpNhuJN5A,1285
|
18
18
|
pycoze/ui/color.py,sha256=cT9Ib8uNzkOKxyW0IwVj46o4LwdB1xgNCj1_Rou9d_4,854
|
@@ -21,8 +21,8 @@ pycoze/ui/ui_def.py,sha256=UhhU_yB3GV9ISbvTWT48hsHPHI250BhMILh6bu5Uioo,4206
|
|
21
21
|
pycoze/utils/__init__.py,sha256=TNJhFfY7JYdLlzuP9GvgxfNXUtbgH_NUUJSqHXCxJn4,78
|
22
22
|
pycoze/utils/arg.py,sha256=kA3KBQzXc2WlH5XbF8kfikfpqljiKaW7oY_GE4Qyffc,753
|
23
23
|
pycoze/utils/text_or_file.py,sha256=gpxZVWt2DW6YiEg_MnMuwg36VNf3TX383QD_1oZNB0Y,551
|
24
|
-
pycoze-0.1.
|
25
|
-
pycoze-0.1.
|
26
|
-
pycoze-0.1.
|
27
|
-
pycoze-0.1.
|
28
|
-
pycoze-0.1.
|
24
|
+
pycoze-0.1.87.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
|
25
|
+
pycoze-0.1.87.dist-info/METADATA,sha256=ilmNEozGi1c7Id-kP6S9J7GiLDQEOS3mvOJKeJIoGn8,719
|
26
|
+
pycoze-0.1.87.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
27
|
+
pycoze-0.1.87.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
|
28
|
+
pycoze-0.1.87.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|