pycoze 0.1.253__tar.gz → 0.1.255__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pycoze-0.1.253 → pycoze-0.1.255}/PKG-INFO +1 -1
- pycoze-0.1.255/pycoze/ai/__init__.py +14 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/ai/llm/__init__.py +9 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/ai/vram_reserve.py +1 -1
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/bot/__init__.py +2 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/bot/agent/agent_types/openai_func_call_agent.py +0 -1
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/bot/agent_chat.py +2 -2
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/bot/bot.py +0 -1
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/reference/bot.py +1 -1
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/reference/tool.py +1 -1
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/reference/workflow.py +2 -2
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/ui/__init__.py +28 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/ui/base.py +1 -1
- pycoze-0.1.255/pycoze/utils/__init__.py +5 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/utils/arg.py +0 -2
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/utils/env.py +6 -2
- pycoze-0.1.255/pycoze/utils/socket.py +72 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze.egg-info/PKG-INFO +1 -1
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze.egg-info/SOURCES.txt +1 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/setup.py +1 -1
- pycoze-0.1.253/pycoze/ai/__init__.py +0 -2
- pycoze-0.1.253/pycoze/utils/__init__.py +0 -3
- {pycoze-0.1.253 → pycoze-0.1.255}/LICENSE +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/README.md +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/__init__.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/ai/llm/chat.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/ai/llm/text_to_image_prompt.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/ai/llm/think.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/bot/agent/__init__.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/bot/agent/agent.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/bot/agent/agent_types/__init__.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/bot/agent/agent_types/const.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/bot/agent/assistant.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/bot/agent/chat.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/reference/__init__.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/reference/lib.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/ui/color.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/ui/typ.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/ui/ui_def.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze/utils/text_or_file.py +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze.egg-info/dependency_links.txt +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/pycoze.egg-info/top_level.txt +0 -0
- {pycoze-0.1.253 → pycoze-0.1.255}/setup.cfg +0 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
from .vram_reserve import reserve_vram, reserve_vram_retry, unreserve_vram
|
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
|
+
]
|
@@ -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'
|
@@ -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)
|
@@ -8,7 +8,7 @@ from .lib import ChangeDirectoryAndPath, ModuleManager, wrapped_func
|
|
8
8
|
from pycoze import utils
|
9
9
|
|
10
10
|
|
11
|
-
params = utils.
|
11
|
+
params = utils.params
|
12
12
|
|
13
13
|
def ref_tools(tool_id, as_agent_tool=False, workspace_path=None):
|
14
14
|
if workspace_path is None:
|
@@ -4,11 +4,11 @@ import importlib
|
|
4
4
|
from langchain.agents import tool as to_agent_tool
|
5
5
|
import types
|
6
6
|
import langchain_core
|
7
|
-
from .lib import
|
7
|
+
from .lib import ModuleManager, wrapped_func
|
8
8
|
from pycoze import utils
|
9
9
|
|
10
10
|
|
11
|
-
params = utils.
|
11
|
+
params = utils.params
|
12
12
|
|
13
13
|
def _ref_workflows(workflow_id, as_agent_tool=False, workspace_path=None):
|
14
14
|
if workspace_path is None:
|
@@ -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
|
+
]
|
@@ -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
|
+
|
@@ -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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|