pycoze 0.1.87__tar.gz → 0.1.89__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pycoze-0.1.87 → pycoze-0.1.89}/PKG-INFO +1 -1
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/ai/vram_reserve.py +6 -32
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/bot/agent/agent_types/openai_func_call_agent.py +1 -16
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze.egg-info/PKG-INFO +1 -1
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze.egg-info/SOURCES.txt +0 -1
- {pycoze-0.1.87 → pycoze-0.1.89}/setup.py +1 -1
- pycoze-0.1.87/pycoze/ai/comfyui.py +0 -33
- {pycoze-0.1.87 → pycoze-0.1.89}/LICENSE +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/README.md +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/__init__.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/access/__init__.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/access/tool_for_bot.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/ai/__init__.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/bot/__init__.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/bot/agent/__init__.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/bot/agent/agent.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/bot/agent/agent_types/__init__.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/bot/agent/assistant.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/bot/agent/chat.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/bot/bot.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/module.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/ui/__init__.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/ui/base.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/ui/color.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/ui/typ.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/ui/ui_def.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/utils/__init__.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/utils/arg.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze/utils/text_or_file.py +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze.egg-info/dependency_links.txt +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/pycoze.egg-info/top_level.txt +0 -0
- {pycoze-0.1.87 → pycoze-0.1.89}/setup.cfg +0 -0
@@ -42,44 +42,18 @@ def get_vram_resources():
|
|
42
42
|
try:
|
43
43
|
# 使用nvidia-smi命令获取VRAM信息
|
44
44
|
result = subprocess.run(
|
45
|
-
["nvidia-smi", "--query-gpu=memory.
|
45
|
+
["nvidia-smi", "--query-gpu=memory.total", "--format=csv,noheader,nounits"],
|
46
46
|
stdout=subprocess.PIPE,
|
47
47
|
text=True,
|
48
48
|
)
|
49
|
-
|
50
|
-
|
51
|
-
for mem in
|
49
|
+
total_memory_list = result.stdout.strip().split("\n")
|
50
|
+
total_memory = 0
|
51
|
+
for mem in total_memory_list:
|
52
52
|
try:
|
53
|
-
|
53
|
+
total_memory += float(mem)
|
54
54
|
except:
|
55
55
|
pass
|
56
|
-
|
57
|
-
# 获取正在使用VRAM的进程信息
|
58
|
-
process_result = subprocess.run(
|
59
|
-
[
|
60
|
-
"nvidia-smi",
|
61
|
-
"--query-compute-apps=pid,process_name,used_memory",
|
62
|
-
"--format=csv,noheader,nounits",
|
63
|
-
],
|
64
|
-
stdout=subprocess.PIPE,
|
65
|
-
text=True,
|
66
|
-
)
|
67
|
-
process_info = process_result.stdout.strip().split("\n")
|
68
|
-
|
69
|
-
# 过滤掉进程名中包含"python"的进程
|
70
|
-
python_memory_usage = 0.0
|
71
|
-
for process in process_info:
|
72
|
-
pid, process_name, used_memory = process.split(", ")
|
73
|
-
if "python" in process_name.lower():
|
74
|
-
try:
|
75
|
-
python_memory_usage += float(used_memory)
|
76
|
-
except:
|
77
|
-
pass
|
78
|
-
print("total_free_vram_memory: ", total_free_memory)
|
79
|
-
print("python_vram_memory_usage: ", python_memory_usage)
|
80
|
-
# 计算排除python进程后的总空闲内存
|
81
|
-
total_free_memory -= python_memory_usage
|
82
|
-
return round(total_free_memory / 1024, 2)
|
56
|
+
return round(total_memory / 1024, 2)
|
83
57
|
except Exception as e:
|
84
58
|
print(f"Error getting VRAM resources: {e}")
|
85
59
|
return 0.0
|
@@ -64,23 +64,8 @@ def create_openai_func_call_agent_executor(
|
|
64
64
|
last_message = messages[-1]
|
65
65
|
if last_message.content.strip().endswith("```"):
|
66
66
|
last_message.content = last_message.content + "\n\n" # 避免影响阅读
|
67
|
-
# if not last_message.tool_calls:
|
68
|
-
# if (
|
69
|
-
# "接下来我将" in last_message.content
|
70
|
-
# or "接下来,我将" in last_message.content
|
71
|
-
# ):
|
72
|
-
# print("deepseek的bug: “接下来我将” 模式,使用a_delay_function骗过llm")
|
73
|
-
# last_message.additional_kwargs["tool_calls"] = (
|
74
|
-
# last_message.tool_calls
|
75
|
-
# ) = [
|
76
|
-
# {
|
77
|
-
# "function": {"name": "a_delay_function", "arguments": "{}"},
|
78
|
-
# "id": random.randint(0, 1000000),
|
79
|
-
# }
|
80
|
-
# ]
|
81
|
-
# return "continue"
|
82
67
|
if '"name"' in last_message.content and '"parameters":' in last_message.content:
|
83
|
-
print("
|
68
|
+
print("name 和 paremeters 模式")
|
84
69
|
all_json = get_all_markdown_json(last_message.content)
|
85
70
|
tool_calls = []
|
86
71
|
for tool_call in all_json:
|
@@ -1,33 +0,0 @@
|
|
1
|
-
from .vram_reserve import reserve_vram_retry, release_vram
|
2
|
-
|
3
|
-
|
4
|
-
class ComfyUI:
|
5
|
-
def __init__(self, file_path):
|
6
|
-
self.file_path = file_path
|
7
|
-
|
8
|
-
def load(self):
|
9
|
-
reserve_vram_retry(20) # 20GB VRAM
|
10
|
-
with open(self.file_path, "r") as file:
|
11
|
-
return file.read()
|
12
|
-
|
13
|
-
def __exit__(self, exc_type, exc_value, traceback):
|
14
|
-
clear_memory()
|
15
|
-
return None
|
16
|
-
|
17
|
-
def unload(self):
|
18
|
-
clear_memory()
|
19
|
-
return None
|
20
|
-
|
21
|
-
|
22
|
-
def clear_memory():
|
23
|
-
import requests
|
24
|
-
import json
|
25
|
-
|
26
|
-
release_vram()
|
27
|
-
|
28
|
-
url = "http://127.0.0.1:8188/free"
|
29
|
-
data = {"unload_models": True, "free_memory": False}
|
30
|
-
response = requests.post(
|
31
|
-
url, data=json.dumps(data), headers={"Content-Type": "application/json"}
|
32
|
-
)
|
33
|
-
return response.status_code, response.text
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|