pycoze 0.1.253__py3-none-any.whl → 0.1.254__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- pycoze/ai/__init__.py +12 -0
- pycoze/ai/llm/__init__.py +9 -0
- pycoze/ai/vram_reserve.py +1 -1
- pycoze/bot/__init__.py +2 -0
- pycoze/bot/agent/agent_types/openai_func_call_agent.py +0 -1
- pycoze/bot/agent_chat.py +2 -2
- pycoze/bot/bot.py +0 -1
- pycoze/ui/__init__.py +28 -0
- pycoze/utils/__init__.py +3 -1
- pycoze/utils/arg.py +0 -2
- pycoze/utils/env.py +6 -2
- pycoze/utils/socket.py +72 -0
- {pycoze-0.1.253.dist-info → pycoze-0.1.254.dist-info}/METADATA +1 -1
- {pycoze-0.1.253.dist-info → pycoze-0.1.254.dist-info}/RECORD +17 -16
- {pycoze-0.1.253.dist-info → pycoze-0.1.254.dist-info}/LICENSE +0 -0
- {pycoze-0.1.253.dist-info → pycoze-0.1.254.dist-info}/WHEEL +0 -0
- {pycoze-0.1.253.dist-info → pycoze-0.1.254.dist-info}/top_level.txt +0 -0
pycoze/ai/__init__.py
CHANGED
@@ -1,2 +1,14 @@
|
|
1
1
|
from .vram_reserve import reserve_vram, reserve_vram_retry, unreserve_vram
|
2
2
|
from .llm import chat, chat_stream, extract, yes_or_no, extract_code, text_to_image_prompt
|
3
|
+
|
4
|
+
__all__ = [
|
5
|
+
reserve_vram,
|
6
|
+
reserve_vram_retry,
|
7
|
+
unreserve_vram,
|
8
|
+
chat,
|
9
|
+
chat_stream,
|
10
|
+
extract,
|
11
|
+
yes_or_no,
|
12
|
+
extract_code,
|
13
|
+
text_to_image_prompt
|
14
|
+
]
|
pycoze/ai/llm/__init__.py
CHANGED
pycoze/ai/vram_reserve.py
CHANGED
pycoze/bot/__init__.py
CHANGED
@@ -106,7 +106,6 @@ def create_openai_func_call_agent_executor(
|
|
106
106
|
if last_message.content.strip().endswith("```"):
|
107
107
|
last_message.content = last_message.content + "\n\n" # 避免影响阅读
|
108
108
|
tools = get_tools(last_message)
|
109
|
-
print("tools", tools)
|
110
109
|
if last_message.tool_calls or tools:
|
111
110
|
return 'continue'
|
112
111
|
return 'end'
|
pycoze/bot/agent_chat.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import json
|
2
2
|
from langchain_openai import ChatOpenAI
|
3
|
-
from .agent import run_agent, Runnable,
|
3
|
+
from .agent import run_agent, Runnable,CHAT_DATA, clear_chat_data
|
4
4
|
import asyncio
|
5
5
|
from pycoze import utils
|
6
6
|
from pycoze.reference.bot import ref_bot
|
@@ -100,7 +100,7 @@ async def agent_chat(bot_setting_file, history):
|
|
100
100
|
assistant_message=prompt,
|
101
101
|
tool_compatibility_mode=cfg["toolCompatibilityMode"],
|
102
102
|
)
|
103
|
-
params = utils.
|
103
|
+
params = utils.params
|
104
104
|
if "interruptFile" in params:
|
105
105
|
interrupt_file_path = params["interruptFile"]
|
106
106
|
result = await run_with_interrupt_check(agent, history, cfg["toolCompatibilityMode"], interrupt_file_path)
|
pycoze/bot/bot.py
CHANGED
pycoze/ui/__init__.py
CHANGED
@@ -25,3 +25,31 @@ from .ui_def import (
|
|
25
25
|
seed,
|
26
26
|
button
|
27
27
|
)
|
28
|
+
|
29
|
+
__all__ = [
|
30
|
+
get_ui,
|
31
|
+
get_ui_text,
|
32
|
+
label,
|
33
|
+
number,
|
34
|
+
text,
|
35
|
+
textarea,
|
36
|
+
password,
|
37
|
+
tool,
|
38
|
+
color,
|
39
|
+
checkbox,
|
40
|
+
single_select,
|
41
|
+
multi_select,
|
42
|
+
single_file_select,
|
43
|
+
multi_file_select,
|
44
|
+
single_folder_select,
|
45
|
+
multi_folder_select,
|
46
|
+
folder_tree,
|
47
|
+
single_image_select,
|
48
|
+
multi_image_select,
|
49
|
+
single_audio_select,
|
50
|
+
multi_audio_select,
|
51
|
+
single_video_select,
|
52
|
+
multi_video_select,
|
53
|
+
seed,
|
54
|
+
button
|
55
|
+
]
|
pycoze/utils/__init__.py
CHANGED
pycoze/utils/arg.py
CHANGED
pycoze/utils/env.py
CHANGED
@@ -13,9 +13,13 @@ def read_params_file():
|
|
13
13
|
print(e)
|
14
14
|
return params
|
15
15
|
|
16
|
+
|
17
|
+
params = read_params_file()
|
18
|
+
|
19
|
+
|
16
20
|
def read_json_file(filename):
|
17
|
-
params = read_params_file()
|
18
21
|
json_file = os.path.join(params['appPath'], 'JsonStorage', filename)
|
19
22
|
with open(json_file, encoding='utf-8') as f:
|
20
23
|
return json.load(f)
|
21
|
-
|
24
|
+
|
25
|
+
|
pycoze/utils/socket.py
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
import socket
|
2
|
+
import json
|
3
|
+
import uuid
|
4
|
+
|
5
|
+
|
6
|
+
tcp_port = read_arg("tcp_port")
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
class TcpSocket:
|
11
|
+
def __init__(self):
|
12
|
+
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
13
|
+
self.socket.connect(("localhost", int(tcp_port)))
|
14
|
+
self.is_connected = True
|
15
|
+
|
16
|
+
def post(self, subject, message):
|
17
|
+
subject = "python-event:" + subject
|
18
|
+
message = message.copy()
|
19
|
+
message["subject"] = subject
|
20
|
+
message = json.dumps(message)
|
21
|
+
message_bytes = message.encode()
|
22
|
+
message_length = len(message_bytes)
|
23
|
+
message_length_bytes = message_length.to_bytes(4, byteorder='big')
|
24
|
+
|
25
|
+
self.socket.sendall(message_length_bytes + message_bytes)
|
26
|
+
|
27
|
+
def recv(self):
|
28
|
+
# 接收消息长度
|
29
|
+
message_length_bytes = self.socket.recv(4)
|
30
|
+
message_length = int.from_bytes(message_length_bytes, byteorder='big')
|
31
|
+
# 初始化接收到的消息
|
32
|
+
message = b''
|
33
|
+
# 循环接收直到收到完整的消息
|
34
|
+
while len(message) < message_length:
|
35
|
+
# 接收剩余的消息
|
36
|
+
chunk = self.socket.recv(message_length - len(message))
|
37
|
+
if not chunk: # 如果没有接收到数据,则断开连接
|
38
|
+
raise RuntimeError("Socket connection broken")
|
39
|
+
message += chunk
|
40
|
+
message = json.loads(message.decode())
|
41
|
+
return message
|
42
|
+
|
43
|
+
def post_and_recv_result(self, subject, message):
|
44
|
+
message = message.copy()
|
45
|
+
message["uid"] = str(uuid.uuid4())
|
46
|
+
socket_subscribe(subject + ":" + message["uid"]) # 先订阅,再发送,防止消息丢失
|
47
|
+
self.post(subject, message)
|
48
|
+
ret_val = self.recv()
|
49
|
+
result = ret_val["result"] if "result" in ret_val else None # 传输时,可能会丢失result字段,因此需要判断
|
50
|
+
return result
|
51
|
+
|
52
|
+
def close(self):
|
53
|
+
if self.is_connected:
|
54
|
+
self.is_connected = False
|
55
|
+
|
56
|
+
def __del__(self):
|
57
|
+
# 垃圾回收时自动关闭socket
|
58
|
+
if self.is_connected:
|
59
|
+
self.close()
|
60
|
+
|
61
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
62
|
+
# with 语句块结束时自动触发的
|
63
|
+
if self.is_connected:
|
64
|
+
self.close()
|
65
|
+
|
66
|
+
|
67
|
+
socket = TcpSocket()
|
68
|
+
|
69
|
+
def socket_subscribe(subject: str):
|
70
|
+
subject = "python-event:" + subject
|
71
|
+
socket.post(subject, {"subscribe": subject})
|
72
|
+
return socket
|
@@ -1,36 +1,37 @@
|
|
1
1
|
pycoze/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
pycoze/ai/__init__.py,sha256=
|
3
|
-
pycoze/ai/vram_reserve.py,sha256=
|
4
|
-
pycoze/ai/llm/__init__.py,sha256=
|
2
|
+
pycoze/ai/__init__.py,sha256=amfVImcuiRRnGbmOjIqjXKiuH1H3zZPHOrJue2dEB8U,355
|
3
|
+
pycoze/ai/vram_reserve.py,sha256=DRxKzqf89fLAts0DzU8e19z9kecIF8OdMkQnJlCKZV0,4244
|
4
|
+
pycoze/ai/llm/__init__.py,sha256=5_AnOrzXI2V6ZZsLUWW1v5ATRWmJy53JLN9jfSZQXCg,249
|
5
5
|
pycoze/ai/llm/chat.py,sha256=izriC7nCp5qeJRqcUVQBVqTHiH6MJS77ROzGBJufdNI,5133
|
6
6
|
pycoze/ai/llm/text_to_image_prompt.py,sha256=0bx2C_YRvjAo7iphHGp1-pmGKsKqwur7dM0t3SiA8kA,3398
|
7
7
|
pycoze/ai/llm/think.py,sha256=sUgTBdGzcZtL3r-Wx8M3lDuVUmDVz8g3qC0VU8uiKAI,5143
|
8
|
-
pycoze/bot/__init__.py,sha256=
|
9
|
-
pycoze/bot/agent_chat.py,sha256=
|
10
|
-
pycoze/bot/bot.py,sha256=
|
8
|
+
pycoze/bot/__init__.py,sha256=JxnRoCCqx_LFyVb3pLu0qYCsH8ZLuAaMXAtvVUuCHuE,78
|
9
|
+
pycoze/bot/agent_chat.py,sha256=ARXXsIVCTpmBojz2C4BR69nB0QhM6gkEngL3iq34JPo,4178
|
10
|
+
pycoze/bot/bot.py,sha256=_qmUTZ09FmRLifHrW5stDZWGVK6yuMEMBC3fmeYJnqk,844
|
11
11
|
pycoze/bot/agent/__init__.py,sha256=3wE8_FFQS8j2BY-g9Cr-onV0POEvDRZaw_NCzpqrNus,265
|
12
12
|
pycoze/bot/agent/agent.py,sha256=chUgNZh6v6375L_Y2dBEAaLJyfmw4SygYjVVrDN8VIk,3548
|
13
13
|
pycoze/bot/agent/assistant.py,sha256=5LIgPIVVzx6uIOWT5S_XDDyPPjPHRBBNpIU3GiOkVHc,1186
|
14
14
|
pycoze/bot/agent/chat.py,sha256=mubOCAHvA6VtyE6N40elI6KrP6A69uB_G6ihE3G_Vi4,860
|
15
15
|
pycoze/bot/agent/agent_types/__init__.py,sha256=zmU2Kmrv5mCdfg-QlPn2H6pWxbGeq8s7YTqLhpzJC6k,179
|
16
16
|
pycoze/bot/agent/agent_types/const.py,sha256=BfUKPrhAHREoMLHuFNG2bCIEkC1-f7K0LEqNg4RwiRE,70
|
17
|
-
pycoze/bot/agent/agent_types/openai_func_call_agent.py,sha256=
|
17
|
+
pycoze/bot/agent/agent_types/openai_func_call_agent.py,sha256=6aKnUQDINyUaCW24oa9Qjkm5w3ctZ6lxAgcE4m9YHwE,6701
|
18
18
|
pycoze/reference/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
19
|
pycoze/reference/bot.py,sha256=BDflTV3zYoZqWnJpD5lMM_1vU_5b20M3XiFt1p-RHWM,2427
|
20
20
|
pycoze/reference/lib.py,sha256=0xQJTLTHedGzQBsjuTFNBVqYc4-8Yl65gGCrAhWyOX8,2155
|
21
21
|
pycoze/reference/tool.py,sha256=9OxHawxjkh6S8eAOlGNrbfhkk5oRlRc7LBpnV6RmhYI,1722
|
22
22
|
pycoze/reference/workflow.py,sha256=xIxv4EAeIR663bRfXkLhgBC0OhfMs5RdfvdORI80CoQ,2068
|
23
|
-
pycoze/ui/__init__.py,sha256=
|
23
|
+
pycoze/ui/__init__.py,sha256=uaXet23wUk64TcZjpBX8qOx4aUhwA_ucrmcxy7Q4Qr4,929
|
24
24
|
pycoze/ui/base.py,sha256=sbBZGMUtlosWHQJpxMULa1bGByeSlcldtE9QXNyiJmM,1093
|
25
25
|
pycoze/ui/color.py,sha256=cT9Ib8uNzkOKxyW0IwVj46o4LwdB1xgNCj1_Rou9d_4,854
|
26
26
|
pycoze/ui/typ.py,sha256=NpT0FrbHvByOszBZMFtroRp7I7pN-38tYz_zPOPejF4,1723
|
27
27
|
pycoze/ui/ui_def.py,sha256=lGWZGpzRoegP34D562PvK0EJHrmVZrlHW1JjsIG9A9Q,4521
|
28
|
-
pycoze/utils/__init__.py,sha256=
|
29
|
-
pycoze/utils/arg.py,sha256=
|
30
|
-
pycoze/utils/env.py,sha256=
|
28
|
+
pycoze/utils/__init__.py,sha256=6bQ3erQHKVOUk4ylyC-6PCASbAV0pYFQfC_f1KqkbUw,191
|
29
|
+
pycoze/utils/arg.py,sha256=jop1tBfe5hYkHW1NSpCeaZBEznkgguBscj_7M2dWfrs,503
|
30
|
+
pycoze/utils/env.py,sha256=5pWlXfM1F5ZU9hhv1rHlDEanjEW5wf0nbyez9bNRqqA,559
|
31
|
+
pycoze/utils/socket.py,sha256=CpyyC-zgibi_GvTeHP14VlqIfC7QuRE6BNbQH3Hb45c,2370
|
31
32
|
pycoze/utils/text_or_file.py,sha256=gpxZVWt2DW6YiEg_MnMuwg36VNf3TX383QD_1oZNB0Y,551
|
32
|
-
pycoze-0.1.
|
33
|
-
pycoze-0.1.
|
34
|
-
pycoze-0.1.
|
35
|
-
pycoze-0.1.
|
36
|
-
pycoze-0.1.
|
33
|
+
pycoze-0.1.254.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
|
34
|
+
pycoze-0.1.254.dist-info/METADATA,sha256=hD65Lc7e26JX0Th3OYDX8OFcJPZcQCR90fy9doVnkno,699
|
35
|
+
pycoze-0.1.254.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
36
|
+
pycoze-0.1.254.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
|
37
|
+
pycoze-0.1.254.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|