gomyck-tools 1.4.3__py3-none-any.whl → 1.4.4__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.
ctools/ai/llm_chat.py CHANGED
@@ -109,6 +109,7 @@ class ChatSession:
109
109
  self.full_messages.append(build_message(ROLE.ASSISTANT, llm_response)) # 不能调换顺序
110
110
  await self.add_tool_call_res_2_message(last_user_input, tool_call_result)
111
111
  await self.process_tool_call_message(get_call_id, get_event_msg_func, tool_call_result)
112
+ # 工具调用, 说明没有结束对话, 要继续执行
112
113
  final_resp = False
113
114
  else:
114
115
  self.full_messages.append(build_message(ROLE.ASSISTANT, llm_response))
@@ -141,15 +142,27 @@ class ChatSession:
141
142
  if get_event_msg_func: await get_event_msg_func(get_call_id(), ROLE.ASSISTANT, self.current_message)
142
143
 
143
144
  async def process_tool_call_message(self, get_call_id, get_event_msg_func, tool_call_result):
144
- # 实时通知前端(工具调用特殊通知一次) 如果是图片结果, 就是 user 消息(必须是 user, 否则 api 报错), 否则是 system(现在统一都改成 user 了, 看看后面有没有改回 system 的必要)
145
+ # 实时通知前端(工具调用特殊通知一次, 输出的是工具返回的结果)
146
+ # 如果是图片结果, 就是 user 消息(必须是 user, 否则 api 报错), 否则是 system(现在统一都改成 user 了, 看看后面有没有改回 system 的必要)
145
147
  self.current_message = tool_call_result["result"] if res_has_img(tool_call_result) else tool_call_result
146
148
  if get_event_msg_func: await get_event_msg_func(get_call_id(), ROLE.USER, self.current_message)
147
149
 
148
150
  async def process_full_message(self, final_resp, get_call_id, get_full_msg_func):
151
+ """
152
+ 全量消息回调函数
153
+ :param final_resp: 最终响应信息
154
+ :param get_call_id: 调用 ID
155
+ :param get_full_msg_func: 回调的函数
156
+ """
149
157
  self.current_message = self.full_messages[-1]["content"]
150
158
  if get_full_msg_func: await get_full_msg_func(get_call_id(), final_resp, self.full_messages)
151
159
 
152
160
  async def add_tool_call_res_2_message(self, last_user_input, tool_call_result: dict):
161
+ """
162
+ 添加当前会话结果, 以便于用当前 chat 对象取值
163
+ :param last_user_input: 客户端最后一次输入
164
+ :param tool_call_result: 工具调用结果
165
+ """
153
166
  if type(tool_call_result) != dict: return
154
167
  response: [] = tool_call_result.get("result")
155
168
  image_content = []
ctools/ai/llm_client.py CHANGED
@@ -4,7 +4,7 @@ import os
4
4
  import httpx
5
5
 
6
6
  from ctools import sys_log, cjson, call
7
- from ctools.ai.env_config import float_env, bool_env, int_env
7
+ from ctools.util.env_config import float_env, bool_env, int_env
8
8
  from ctools.ai.llm_exception import LLMException
9
9
 
10
10
  logging.getLogger("httpcore").setLevel(logging.WARNING)
@@ -10,7 +10,7 @@ import mimetypes
10
10
  import sys
11
11
  import uuid
12
12
 
13
- from ctools.ai.env_config import bool_env
13
+ from ctools.util.env_config import bool_env
14
14
  from ctools.web.aio_web_server import get_stream_resp
15
15
 
16
16
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gomyck-tools
3
- Version: 1.4.3
3
+ Version: 1.4.4
4
4
  Summary: A tools collection for python development by hao474798383
5
5
  Author-email: gomyck <hao474798383@163.com>
6
6
  License-Expression: Apache-2.0
@@ -30,12 +30,16 @@ Requires-Dist: pyjwt==2.10.1
30
30
  Requires-Dist: cryptography==44.0.2
31
31
  Requires-Dist: redis==5.2.1
32
32
  Requires-Dist: uvloop>=0.21.0
33
- Requires-Dist: jieba>=0.42.1
34
33
  Provides-Extra: kwc
35
34
  Requires-Dist: imageio>=2.37.0; extra == "kwc"
36
35
  Requires-Dist: wordcloud>=1.9.4; extra == "kwc"
37
36
  Requires-Dist: jieba==0.42.1; extra == "kwc"
38
37
  Requires-Dist: paddlepaddle==2.6.1; extra == "kwc"
38
+ Provides-Extra: cut
39
+ Requires-Dist: jieba==0.42.1; extra == "cut"
40
+ Requires-Dist: paddlepaddle==2.6.1; extra == "cut"
41
+ Provides-Extra: ml
42
+ Requires-Dist: scikit-learn>=1.7.1; extra == "ml"
39
43
  Dynamic: license-file
40
44
 
41
45
  # Gomyck-Tools
@@ -16,15 +16,14 @@ ctools/similar.py,sha256=ByOFaJ2AHZBe3ekoEco5miXcZP1XW7vGecH1i3dES5g,698
16
16
  ctools/sys_info.py,sha256=QynB_2nQeGUuUdqJQldtEq916gDfPBsei1OWx9GYKSI,4278
17
17
  ctools/sys_log.py,sha256=Sud91NQEVIiqiW6zffv-LrdmVKqva9ijUpdhTxrQhDA,2782
18
18
  ctools/ai/__init__.py,sha256=gTYAICILq48icnFbg0HCbsQO8PbU02EDOQ0JeMvfqTY,98
19
- ctools/ai/env_config.py,sha256=L98G9LPdpD7Yl5XbA_-KfkcA4mDunQoKiYtK5w7QR-s,1790
20
- ctools/ai/llm_chat.py,sha256=HnuejSXQrwiIn5VDjkF09W78Tki_1KCdf9fWOHGxCxA,8668
21
- ctools/ai/llm_client.py,sha256=_-lGP_mMqT26D898c_ys_XdHRse5Uqsp0nRBeQJNrzA,6176
19
+ ctools/ai/llm_chat.py,sha256=vgv1C72fv7YEGj_203L6JY_PyDszxvhrlLjLYbxuvZk,9133
20
+ ctools/ai/llm_client.py,sha256=0xHvSQoAd4PAnunyH2a-cJ9RKTkWO1cFyrnqmA1j3g0,6178
22
21
  ctools/ai/llm_exception.py,sha256=wsCVl0m53Mk7Xfug1obocAthlX0oEo4dytg1eOhWHPg,389
23
22
  ctools/ai/mcp/__init__.py,sha256=gTYAICILq48icnFbg0HCbsQO8PbU02EDOQ0JeMvfqTY,98
24
23
  ctools/ai/mcp/mcp_client.py,sha256=UU7TSMreWcSmbOVoyH02YSVzxE3peg89Z5Hifyg3RlQ,11946
25
24
  ctools/ai/tools/__init__.py,sha256=gPc-ViRgtFlfX7JUbk5wQZ3wkJ5Ylh14CIqPwa83VPs,98
26
25
  ctools/ai/tools/json_extract.py,sha256=FLrwrpYxAYQ0nvUok9OhmVQUaWhOpftDS4-uJIV3j0o,4839
27
- ctools/ai/tools/quick_tools.py,sha256=XjYHINavVkFly4sB7Q5dDkR8UpTYmUYZZpMKU80izXw,3026
26
+ ctools/ai/tools/quick_tools.py,sha256=Z0eJGEdQbEq7rNQtIO0WwEE94mbtu-JTtyehyJOwtMQ,3028
28
27
  ctools/ai/tools/think_process.py,sha256=RGU9j3_O328Byw05ILek-aMfFBczbly2RA-QRouqUjM,257
29
28
  ctools/ai/tools/tool_use_xml_parse.py,sha256=xZkxbXoOR5o_mEaUgKfD6oMGsc0BVxNJk5FO4_uvQ_4,1430
30
29
  ctools/ai/tools/xml_extract.py,sha256=u1HZFCbMDwmNAvSPBia6-7H3WoRHN6oUQ8wGG5A2WHw,234
@@ -66,6 +65,7 @@ ctools/util/cftp.py,sha256=ESLFNW7yfRYD4e_c777Gmm4jf9Vks4waGe_TKncgxMQ,2485
66
65
  ctools/util/cklock.py,sha256=uS1g8H7jtQ5dINKe-k23osQ1sjvZSZrkXGwH6qKcgNo,3234
67
66
  ctools/util/compile_util.py,sha256=Nybh3vnkurIKnPnubdYzigjnzFu4GaTMKPvqFdibxmE,510
68
67
  ctools/util/config_util.py,sha256=FBacCqQ1kPtRl1VEz0IsAuxI0zdpqUiuBv11G8kiDLE,1230
68
+ ctools/util/env_config.py,sha256=L98G9LPdpD7Yl5XbA_-KfkcA4mDunQoKiYtK5w7QR-s,1790
69
69
  ctools/util/html_soup.py,sha256=rnr8M3gn3gQGo-wNaNFXDjdzp8AAkv9o4yqfIIfO-zw,1567
70
70
  ctools/util/http_util.py,sha256=cx0FRnPLFdJ0mF9UYphl40SZj68fqG30Q0udku9hZIE,769
71
71
  ctools/util/image_process.py,sha256=nqJOi2p8wLe8wRsfkH99MyEYSjE9i4fthxBJwrrZVB8,835
@@ -81,8 +81,8 @@ ctools/web/ctoken.py,sha256=WaB29kqGlKAh21aUw5avl2h8AgLD1aESw8KCpqaN5nM,2539
81
81
  ctools/web/download_util.py,sha256=v0JTXiED1bvoWFfwfd-LD5s7_aoRQ0lCkaGwSnSp7WI,1954
82
82
  ctools/web/params_util.py,sha256=eJDV3PSq-ZHb8UZf6xqs8kOhbyZzits1H9yPoUBIDXg,828
83
83
  ctools/web/upload_util.py,sha256=z1QQCi4SFx08jrAQH5-Y_ShiM4MghuD_5Qz6V9KK_4U,1076
84
- gomyck_tools-1.4.3.dist-info/licenses/LICENSE,sha256=X25ypfH9E6VTht2hcO8k7LCSdHUcoG_ALQt80jdYZfY,547
85
- gomyck_tools-1.4.3.dist-info/METADATA,sha256=8QMLyPlLz6WepCoRUmDfsKaQ-ieZCrqJi1tluZ9ImVk,1513
86
- gomyck_tools-1.4.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
87
- gomyck_tools-1.4.3.dist-info/top_level.txt,sha256=-MiIH9FYRVKp1i5_SVRkaI-71WmF1sZSRrNWFU9ls3s,7
88
- gomyck_tools-1.4.3.dist-info/RECORD,,
84
+ gomyck_tools-1.4.4.dist-info/licenses/LICENSE,sha256=X25ypfH9E6VTht2hcO8k7LCSdHUcoG_ALQt80jdYZfY,547
85
+ gomyck_tools-1.4.4.dist-info/METADATA,sha256=Wf6cm8gljbYlOnwo1crpG8Q4EdvWQgX8MW-RhEiB460,1669
86
+ gomyck_tools-1.4.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
87
+ gomyck_tools-1.4.4.dist-info/top_level.txt,sha256=-MiIH9FYRVKp1i5_SVRkaI-71WmF1sZSRrNWFU9ls3s,7
88
+ gomyck_tools-1.4.4.dist-info/RECORD,,
File without changes