pycoze 0.1.88__py3-none-any.whl → 0.1.89__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
pycoze/ai/vram_reserve.py CHANGED
@@ -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.free", "--format=csv,noheader,nounits"],
45
+ ["nvidia-smi", "--query-gpu=memory.total", "--format=csv,noheader,nounits"],
46
46
  stdout=subprocess.PIPE,
47
47
  text=True,
48
48
  )
49
- free_memory = result.stdout.strip().split("\n")
50
- total_free_memory = 0
51
- for mem in free_memory:
49
+ total_memory_list = result.stdout.strip().split("\n")
50
+ total_memory = 0
51
+ for mem in total_memory_list:
52
52
  try:
53
- total_free_memory += float(mem)
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("deepseek的bug: name 和 paremeters 模式")
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycoze
3
- Version: 0.1.88
3
+ Version: 0.1.89
4
4
  Summary: Package for pycoze only!
5
5
  Author: Yuan Jie Xiong
6
6
  Author-email: aiqqqqqqq@qq.com
@@ -3,8 +3,7 @@ pycoze/module.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  pycoze/access/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  pycoze/access/tool_for_bot.py,sha256=Nv6XlxcqaLaMVQNDkpcthlqaSxyfHoOfWiTScQXO22Y,2656
5
5
  pycoze/ai/__init__.py,sha256=Smivpb8qbRnzWkzKRe2IxsmKP5Dh8EvngDFdkD_DVLo,73
6
- pycoze/ai/comfyui.py,sha256=u75tZywkuXiOdm7XST2kBAaveJKpPvY_qTQr_TN9sXk,795
7
- pycoze/ai/vram_reserve.py,sha256=s55Cy-Q5mTq-k5oIPbAFwCfrjatjN0QTjQxW7WBTPZI,5738
6
+ pycoze/ai/vram_reserve.py,sha256=zjRFxTJDfWlyd3xSJTkB4sdfsahsOijyCY_MEIotMbw,4731
8
7
  pycoze/bot/__init__.py,sha256=6HHMxDQVOyZM9dtSjQm9tjGnhj4h7CixD0JOvEwTi48,41
9
8
  pycoze/bot/bot.py,sha256=w_ddp3IeWryUgIad-_V-SsDzGwYqZXekw5NXbYyXrkk,3041
10
9
  pycoze/bot/agent/__init__.py,sha256=YR9vpkEQn1e4937r_xFPJXUCPBEJ0SFzEQDBe2x3-YA,157
@@ -12,7 +11,7 @@ pycoze/bot/agent/agent.py,sha256=XMTO6s8OJpaOnymT8ZUuJxXx2ICZ3r7Ck0pHJqPPFIs,334
12
11
  pycoze/bot/agent/assistant.py,sha256=XI4w-rFfbk3qYE0tWcWoya8dz-3cA-QZ0Sanhl3DbKE,1112
13
12
  pycoze/bot/agent/chat.py,sha256=kc0qgcrBSXdiMy49JwThZTV-0PAvzAhiUvbI5ILiSnU,571
14
13
  pycoze/bot/agent/agent_types/__init__.py,sha256=XNvKWq9REE5Wzjm0OZi3CKIQF2UZ9PZkeUuxgFJbrfc,128
15
- pycoze/bot/agent/agent_types/openai_func_call_agent.py,sha256=bb6zze6lbdiZi9uSim5oWNviGm5sqLOEY6suSP_xyaI,7591
14
+ pycoze/bot/agent/agent_types/openai_func_call_agent.py,sha256=nqyHEZVSqxFlfjraeWJ1up4IGZFZSaZB2rlzhVheKbw,6877
16
15
  pycoze/ui/__init__.py,sha256=7xAfL2lfG7-jllPJEZUJO89xUE9sNzvo1y0WmBswjBI,458
17
16
  pycoze/ui/base.py,sha256=SCXVDK7PpMaBv6ovvabHcfRq_d2AWM0BRyxpNhuJN5A,1285
18
17
  pycoze/ui/color.py,sha256=cT9Ib8uNzkOKxyW0IwVj46o4LwdB1xgNCj1_Rou9d_4,854
@@ -21,8 +20,8 @@ pycoze/ui/ui_def.py,sha256=UhhU_yB3GV9ISbvTWT48hsHPHI250BhMILh6bu5Uioo,4206
21
20
  pycoze/utils/__init__.py,sha256=TNJhFfY7JYdLlzuP9GvgxfNXUtbgH_NUUJSqHXCxJn4,78
22
21
  pycoze/utils/arg.py,sha256=kA3KBQzXc2WlH5XbF8kfikfpqljiKaW7oY_GE4Qyffc,753
23
22
  pycoze/utils/text_or_file.py,sha256=gpxZVWt2DW6YiEg_MnMuwg36VNf3TX383QD_1oZNB0Y,551
24
- pycoze-0.1.88.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
25
- pycoze-0.1.88.dist-info/METADATA,sha256=4myvqfGb4LLUlX-GmFtIWTWlhRouTw64gQLfm4eWfvE,719
26
- pycoze-0.1.88.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
27
- pycoze-0.1.88.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
28
- pycoze-0.1.88.dist-info/RECORD,,
23
+ pycoze-0.1.89.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
24
+ pycoze-0.1.89.dist-info/METADATA,sha256=vpuL_fkJtMzFx7So1MwT3eftwVbeRMQdYnNQJ96Ecbk,719
25
+ pycoze-0.1.89.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
26
+ pycoze-0.1.89.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
27
+ pycoze-0.1.89.dist-info/RECORD,,
pycoze/ai/comfyui.py DELETED
@@ -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