beswarm 0.1.55__py3-none-any.whl → 0.1.57__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.
beswarm/aient/setup.py CHANGED
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
4
4
 
5
5
  setup(
6
6
  name="aient",
7
- version="1.1.11",
7
+ version="1.1.12",
8
8
  description="Aient: The Awakening of Agent.",
9
9
  long_description=Path.open(Path("README.md"), encoding="utf-8").read(),
10
10
  long_description_content_type="text/markdown",
@@ -558,12 +558,12 @@ class chatgpt(BaseLLM):
558
558
  tool_response = chunk.replace("function_response:", "")
559
559
  else:
560
560
  yield chunk
561
- if tool_name == "read_file" and "<read_file error>" not in tool_response:
561
+ if tool_name == "read_file" and "<tool_error>" not in tool_response:
562
562
  self.latest_file_content[tool_info['parameter']["file_path"]] = tool_response
563
563
  all_responses.append(f"[{tool_name}({tool_args}) Result]:\n\nRead file successfully! The file content has been updated in the tag <latest_file_content>.")
564
- elif tool_name == "write_to_file":
564
+ elif tool_name == "write_to_file" and "<tool_error>" not in tool_response:
565
565
  all_responses.append(f"[{tool_name} Result]:\n\n{tool_response}")
566
- elif tool_name == "read_image":
566
+ elif tool_name == "read_image" and "<tool_error>" not in tool_response:
567
567
  tool_info["base64_image"] = tool_response
568
568
  all_responses.append(f"[{tool_name}({tool_args}) Result]:\n\nRead image successfully!")
569
569
  else:
@@ -51,11 +51,11 @@ Examples:
51
51
  try:
52
52
  # 检查文件是否存在
53
53
  if not os.path.exists(file_path):
54
- return f"<read_file error>文件 '{file_path}' 不存在</read_file error>"
54
+ return f"<tool_error>文件 '{file_path}' 不存在</tool_error>"
55
55
 
56
56
  # 检查是否为文件
57
57
  if not os.path.isfile(file_path):
58
- return f"<read_file error>'{file_path}' 不是一个文件</read_file error>"
58
+ return f"<tool_error>'{file_path}' 不是一个文件</tool_error>"
59
59
 
60
60
  # 检查文件扩展名
61
61
  if file_path.lower().endswith('.pdf'):
@@ -64,7 +64,7 @@ Examples:
64
64
 
65
65
  # 如果提取结果为空
66
66
  if not text_content:
67
- return f"<read_file error>无法从 '{file_path}' 提取文本内容</read_file error>"
67
+ return f"<tool_error>无法从 '{file_path}' 提取文本内容</tool_error>"
68
68
  elif file_path.lower().endswith('.ipynb'):
69
69
  try:
70
70
  with open(file_path, 'r', encoding='utf-8') as file:
@@ -96,9 +96,9 @@ Examples:
96
96
 
97
97
  text_content = json.dumps(notebook_content, indent=2, ensure_ascii=False)
98
98
  except json.JSONDecodeError:
99
- return f"<read_file error>文件 '{file_path}' 不是有效的JSON格式 (IPython Notebook)。</read_file error>"
99
+ return f"<tool_error>文件 '{file_path}' 不是有效的JSON格式 (IPython Notebook)。</tool_error>"
100
100
  except Exception as e:
101
- return f"<read_file error>处理IPython Notebook文件 '{file_path}' 时发生错误: {e}</read_file error>"
101
+ return f"<tool_error>处理IPython Notebook文件 '{file_path}' 时发生错误: {e}</tool_error>"
102
102
  else:
103
103
  # 更新:修改通用文件读取逻辑以支持多种编码
104
104
  # 这部分替换了原有的 else 块内容
@@ -152,25 +152,25 @@ Examples:
152
152
  elif primary_encoding_to_try: # 如果有检测结果但置信度低
153
153
  detected_str_part = f"低置信度检测编码 '{primary_encoding_to_try}' (置信度 {confidence:.2f}), "
154
154
 
155
- return f"<read_file error>文件 '{file_path}' 无法解码。已尝试: {detected_str_part}UTF-8, UTF-16。</read_file error>"
155
+ return f"<tool_error>文件 '{file_path}' 无法解码。已尝试: {detected_str_part}UTF-8, UTF-16。</tool_error>"
156
156
 
157
157
  except FileNotFoundError:
158
158
  # 此处不太可能触发 FileNotFoundError,因为函数开头已有 os.path.exists 检查
159
- return f"<read_file error>文件 '{file_path}' 在读取过程中未找到。</read_file error>"
159
+ return f"<tool_error>文件 '{file_path}' 在读取过程中未找到。</tool_error>"
160
160
  except Exception as e:
161
161
  # 捕获在此块中可能发生的其他错误,例如未被早期检查捕获的文件读取问题
162
- return f"<read_file error>处理通用文件 '{file_path}' 时发生错误: {e}</read_file error>"
162
+ return f"<tool_error>处理通用文件 '{file_path}' 时发生错误: {e}</tool_error>"
163
163
 
164
164
  # 返回文件内容
165
165
  return text_content
166
166
 
167
167
  except PermissionError:
168
- return f"<read_file error>没有权限访问文件 '{file_path}'</read_file error>"
168
+ return f"<tool_error>没有权限访问文件 '{file_path}'</tool_error>"
169
169
  except UnicodeDecodeError:
170
170
  # 更新:修改全局 UnicodeDecodeError 错误信息使其更通用
171
- return f"<read_file error>文件 '{file_path}' 包含无法解码的字符 (UnicodeDecodeError)。</read_file error>"
171
+ return f"<tool_error>文件 '{file_path}' 包含无法解码的字符 (UnicodeDecodeError)。</tool_error>"
172
172
  except Exception as e:
173
- return f"<read_file error>读取文件时发生错误: {e}</read_file error>"
173
+ return f"<tool_error>读取文件时发生错误: {e}</tool_error>"
174
174
 
175
175
  if __name__ == "__main__":
176
176
  # python -m beswarm.aient.src.aient.plugins.read_file
@@ -19,17 +19,17 @@ def read_image(image_path: str):
19
19
  try:
20
20
  # 检查路径是否存在
21
21
  if not os.path.exists(image_path):
22
- return f"错误: 图片路径 '{image_path}' 不存在。"
22
+ return f"<tool_error>图片路径 '{image_path}' 不存在。</tool_error>"
23
23
  # 检查是否为文件
24
24
  if not os.path.isfile(image_path):
25
- return f"错误: 路径 '{image_path}' 不是一个有效的文件 (可能是一个目录)"
25
+ return f"<tool_error>路径 '{image_path}' 不是一个有效的文件 (可能是一个目录)。</tool_error>"
26
26
 
27
27
  # 尝试猜测MIME类型
28
28
  mime_type, _ = mimetypes.guess_type(image_path) # encoding 变量通常不需要
29
29
 
30
30
  if not mime_type or not mime_type.startswith('image/'):
31
31
  # 如果mimetypes无法识别,或者不是图片类型
32
- return f"错误: 文件 '{image_path}' 的MIME类型无法识别为图片 (检测到: {mime_type})。请确保文件是常见的图片格式 (e.g., PNG, JPG, GIF, WEBP)"
32
+ return f"<tool_error>文件 '{image_path}' 的MIME类型无法识别为图片 (检测到: {mime_type})。请确保文件是常见的图片格式 (e.g., PNG, JPG, GIF, WEBP)。</tool_error>"
33
33
 
34
34
  with open(image_path, "rb") as image_file:
35
35
  image_data = image_file.read()
@@ -45,10 +45,10 @@ def read_image(image_path: str):
45
45
  except FileNotFoundError:
46
46
  # 这个异常通常由 open() 抛出,如果 os.path.exists 通过但文件在读取前被删除
47
47
  # 或者路径检查逻辑未能完全覆盖所有情况 (理论上不应发生)
48
- return f"错误: 图片路径 '{image_path}' 未找到 (可能在检查后被删除或移动)"
48
+ return f"<tool_error>图片路径 '{image_path}' 未找到 (可能在检查后被删除或移动)。</tool_error>"
49
49
  except PermissionError:
50
- return f"错误: 没有权限访问图片路径 '{image_path}'"
50
+ return f"<tool_error>没有权限访问图片路径 '{image_path}'。</tool_error>"
51
51
  except IOError as e: # 例如文件损坏无法读取,或磁盘问题
52
- return f"错误: 读取图片 '{image_path}' 时发生 I/O 错误: {e}"
52
+ return f"<tool_error>读取图片 '{image_path}' 时发生 I/O 错误: {e}</tool_error>"
53
53
  except Exception as e:
54
- return f"读取图片 '{image_path}' 时发生未知错误: {e}"
54
+ return f"<tool_error>读取图片 '{image_path}' 时发生未知错误: {e}</tool_error>"
@@ -693,6 +693,53 @@ if __name__ == "__main__":
693
693
  </read_file>
694
694
  </tool_call>
695
695
  好的,我现在读取 `README.md` 文件。`<answer> </answer>`
696
+ """
697
+ test_xml = """
698
+ 好的,我来报告上一组指令的执行结果:
699
+
700
+ 1. **创建日志目录 `/root/ctm-server/ctm_tinyimagenet_logs_v5_drastic_reduction`**:
701
+ <excute_command>
702
+ <command>mkdir -p /root/ctm-server/ctm_tinyimagenet_logs_v5_drastic_reduction</command>
703
+ </excute_command>
704
+ *(我需要等待这个命令的实际执行结果才能确认。假设它会成功,因为 `mkdir -p` 通常不会失败。)*
705
+
706
+ 2. **执行第五次实验的训练命令**:
707
+ <excute_command>
708
+ <command>python /root/ctm-server/continuous-thought-machines/tasks/image_classification/train.py \
709
+ --model ctm \
710
+ --dataset tinyimagenet \
711
+ --data_root /root/ctm-server/tiny-imagenet-200 \
712
+ --batch_size 1024 \
713
+ --training_iterations 10000 \
714
+ --device 0 \
715
+ --log_dir /root/ctm-server/ctm_tinyimagenet_logs_v5_drastic_reduction \
716
+ --save_every 1000 \
717
+ --track_every 200 \
718
+ --num_workers_train 2 \
719
+ --d_model 128 \
720
+ --iterations 10 \
721
+ --d_input 64 \
722
+ --heads 1 \
723
+ --synapse_depth 1 \
724
+ --n_synch_out 128 \
725
+ --n_synch_action 128 \
726
+ --memory_length 8 \
727
+ --backbone_type resnet18-1 \
728
+ --positional_embedding_type none \
729
+ --dropout 0.5 \
730
+ --weight_decay 1e-3 \
731
+ --use_amp</command>
732
+ </excute_command>
733
+ *(我需要等待这个训练命令的实际执行结果来确认训练是否完成。训练通常需要一些时间。)*
734
+
735
+ 在上述两个 `excute_command` 的结果返回后,并且如果训练确认已完成,我将执行下一步:
736
+
737
+ 3. **读取第五次实验的准确率图像**:
738
+ <read_image>
739
+ <image_path>/root/ctm-server/ctm_tinyimagenet_logs_v5_drastic_reduction/accuracies.png</image_path>
740
+ </read_image>
741
+
742
+ 请提供前两个 `excute_command` 的执行结果。
696
743
  """
697
744
 
698
745
  print(parse_function_xml(test_xml))
@@ -157,4 +157,24 @@ def edit_file(file_path, diff_content, match_precision=0.8):
157
157
  except UnicodeDecodeError:
158
158
  return f"错误: 文件 '{file_path}' 不是文本文件或编码不是UTF-8,无法进行编码解析"
159
159
  except Exception as e:
160
- return f"编辑文件时发生错误: {e}"
160
+ print(f"content: {content}")
161
+ print(f"file_path: {file_path}")
162
+ print(f"diff_content: {diff_content}")
163
+ import traceback
164
+ traceback.print_exc()
165
+ return f"编辑文件时发生错误: {e}"
166
+
167
+ if __name__ == "__main__":
168
+ edit_str = """
169
+ <<<<<<< SEARCH
170
+ parser.add_argument('--dataset', type=str, default='cifar10', choices=['cifar10', 'cifar100', 'imagenet'], help="Dataset to use.")
171
+ =======
172
+ parser.add_argument('--dataset', type=str, default='cifar10', choices=['cifar10', 'cifar100', 'imagenet', 'tinyimagenet'], help="Dataset to use.")
173
+ >>>>>>> REPLACE
174
+ """
175
+
176
+ file_path = "train.py"
177
+ # 编辑文件时发生错误: '>' not supported between instances of 'str' and 'float'
178
+ print(edit_file(file_path, edit_str))
179
+
180
+ # python -m beswarm.tools.edit_file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: beswarm
3
- Version: 0.1.55
3
+ Version: 0.1.57
4
4
  Summary: MAS
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -58,12 +58,12 @@ arXiv:2502.14831v2 和 arXiv:2503.10618v2 的 渐进式 VAE 训练方法有一
58
58
  找到每一个数学概念对应的代码实现。整理成文档保存到本地。
59
59
  ```
60
60
 
61
- ```
61
+ ```bash
62
62
  docker buildx build --platform linux/amd64,linux/arm64 -t yym68686/beswarm:latest --push .
63
63
  docker pull yym68686/beswarm
64
64
  ```
65
65
 
66
- ```
66
+ ```bash
67
67
  cd ~/Downloads/GitHub/beswarm && docker run --rm \
68
68
  --env-file .env \
69
69
  -v ./work:/app/work beswarm \
@@ -72,7 +72,7 @@ cd ~/Downloads/GitHub/beswarm && docker run --rm \
72
72
 
73
73
  测试 docker 是否可以用 GPU:
74
74
 
75
- ```
75
+ ```bash
76
76
  docker run --gpus all -it --rm --entrypoint nvidia-smi yym68686/beswarm
77
77
 
78
78
  docker run -it --rm --entrypoint cat yym68686/beswarm /app/beswarm/aient/src/aient/models/chatgpt.py
@@ -80,7 +80,7 @@ docker run -it --rm --entrypoint cat yym68686/beswarm /app/beswarm/aient/src/aie
80
80
 
81
81
  服务器安装
82
82
 
83
- ```
83
+ ```bash
84
84
  pip install pipx
85
85
  pipx ensurepath
86
86
  source ~/.bashrc
@@ -1,7 +1,7 @@
1
1
  beswarm/__init__.py,sha256=HZjUOJtZR5QhMuDbq-wukQQn1VrBusNWai_ysGo-VVI,20
2
2
  beswarm/utils.py,sha256=AdDCcqAIIKQEMl7PfryVgeT9G5sHe7QNsZnrvmTGA8E,283
3
3
  beswarm/aient/main.py,sha256=SiYAIgQlLJqYusnTVEJOx1WNkSJKMImhgn5aWjfroxg,3814
4
- beswarm/aient/setup.py,sha256=ulEgZGvqjNW3md1BsZe2Yzx4lkJymyIfc3tSA11u2AQ,487
4
+ beswarm/aient/setup.py,sha256=6ygixQucKMW9S7_9BHl6IsJJN8lqDYcuKC1wOPsrzp8,487
5
5
  beswarm/aient/src/aient/__init__.py,sha256=SRfF7oDVlOOAi6nGKiJIUK6B_arqYLO9iSMp-2IZZps,21
6
6
  beswarm/aient/src/aient/core/__init__.py,sha256=NxjebTlku35S4Dzr16rdSqSTWUvvwEeACe8KvHJnjPg,34
7
7
  beswarm/aient/src/aient/core/log_config.py,sha256=kz2_yJv1p-o3lUQOwA3qh-LSc3wMHv13iCQclw44W9c,274
@@ -16,7 +16,7 @@ beswarm/aient/src/aient/core/test/test_payload.py,sha256=8jBiJY1uidm1jzL-EiK0s6U
16
16
  beswarm/aient/src/aient/models/__init__.py,sha256=ouNDNvoBBpIFrLsk09Q_sq23HR0GbLAKfGLIFmfEuXE,219
17
17
  beswarm/aient/src/aient/models/audio.py,sha256=kRd-8-WXzv4vwvsTGwnstK-WR8--vr9CdfCZzu8y9LA,1934
18
18
  beswarm/aient/src/aient/models/base.py,sha256=z-Z0pJfTN2x0cuwfvu0BdMRY9O-RmLwHEnBIJN1x4Fg,6719
19
- beswarm/aient/src/aient/models/chatgpt.py,sha256=6SuMfV8n0pBOaKN3WGqhPc53_LHBdyOECQgVsHscso8,46169
19
+ beswarm/aient/src/aient/models/chatgpt.py,sha256=sfXqmYAiTTAa_dH2h49BZnVvjebEl99LJdQGepD2sCQ,46244
20
20
  beswarm/aient/src/aient/models/claude.py,sha256=JezghW7y0brl4Y5qiSHvnYR5prQCFywX4RViHt39pGI,26037
21
21
  beswarm/aient/src/aient/models/duckduckgo.py,sha256=1l7vYCs9SG5SWPCbcl7q6pCcB5AUF_r-a4l9frz3Ogo,8115
22
22
  beswarm/aient/src/aient/models/gemini.py,sha256=chGLc-8G_DAOxr10HPoOhvVFW1RvMgHd6mt--VyAW98,14730
@@ -29,8 +29,8 @@ beswarm/aient/src/aient/plugins/excute_command.py,sha256=A3WmfZboEikU1EHvtMWhBv-
29
29
  beswarm/aient/src/aient/plugins/get_time.py,sha256=Ih5XIW5SDAIhrZ9W4Qe5Hs1k4ieKPUc_LAd6ySNyqZk,654
30
30
  beswarm/aient/src/aient/plugins/image.py,sha256=ZElCIaZznE06TN9xW3DrSukS7U3A5_cjk1Jge4NzPxw,2072
31
31
  beswarm/aient/src/aient/plugins/list_directory.py,sha256=JZVuImecMSfEv6jLqii-0uQJ1UCsrpMNmYlwW3PEDg4,1374
32
- beswarm/aient/src/aient/plugins/read_file.py,sha256=-RRmaj-rSl8y--5VKnxCsZ1YQHe75OhnqvsDRLJyujM,8412
33
- beswarm/aient/src/aient/plugins/read_image.py,sha256=goBnpmnmu753pQBkEROTo1ZaGE23fx5WJVr8T8z4598,2577
32
+ beswarm/aient/src/aient/plugins/read_file.py,sha256=Lv03AW-gWGzM2esos2vLTXHcceczdTqEO7_vqFT4yoY,8302
33
+ beswarm/aient/src/aient/plugins/read_image.py,sha256=jFu8MGCPWg19YOG-STWH3pqacf94F17i_4JaJu1XWLs,2704
34
34
  beswarm/aient/src/aient/plugins/registry.py,sha256=YknzhieU_8nQ3oKlUSSWDB4X7t2Jx0JnqT2Jd9Xsvfk,3574
35
35
  beswarm/aient/src/aient/plugins/run_python.py,sha256=dgcUwBunMuDkaSKR5bToudVzSdrXVewktDDFUz_iIOQ,4589
36
36
  beswarm/aient/src/aient/plugins/websearch.py,sha256=llxy1U0vJiNMiKvamMr4p7IruLb3nnDR4YErz8TYimc,15215
@@ -39,7 +39,7 @@ beswarm/aient/src/aient/prompt/__init__.py,sha256=GBtn6-JDT8KHFCcuPpfSNE_aGddg5p
39
39
  beswarm/aient/src/aient/prompt/agent.py,sha256=y2GETN6ScC5yQVs75VFfzm4YUWzblbqLYz0Sy6JnPRw,24950
40
40
  beswarm/aient/src/aient/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  beswarm/aient/src/aient/utils/prompt.py,sha256=UcSzKkFE4-h_1b6NofI6xgk3GoleqALRKY8VBaXLjmI,11311
42
- beswarm/aient/src/aient/utils/scripts.py,sha256=ATxP7VZvIngYiRB6XgjP1lQHovKzXhpWL3QpsJtZYi8,27245
42
+ beswarm/aient/src/aient/utils/scripts.py,sha256=wutPtgbs-WXo5AACLpnCJaRQBOSKXWNnsf2grbYDzyQ,29098
43
43
  beswarm/aient/test/chatgpt.py,sha256=Hvl7FuDt1c74N5TVBmhErOPvJbJJzA7FNp5VoZM4u30,4957
44
44
  beswarm/aient/test/claude.py,sha256=IyB4qI1eJLwlSfDNSnt2FhbQWYyBighHUjJxEXc3osQ,1095
45
45
  beswarm/aient/test/test.py,sha256=rldnoLQdtRR8IKFSIzTti7eIK2MpPMoi9gL5qD8_K44,29
@@ -122,14 +122,14 @@ beswarm/queries/tree-sitter-languages/typescript-tags.scm,sha256=OMdCeedPiA24ky8
122
122
  beswarm/tools/UIworker.py,sha256=1sEC76VGFwo48lSx6KOvhJwhgBj7UWAHAAH9BG_lp-M,6439
123
123
  beswarm/tools/__init__.py,sha256=jOfYY4EYkwmz-FTJGrI1CyaIYkGWsmGzZBGsoupeX9M,1088
124
124
  beswarm/tools/click.py,sha256=TygaekCXTmU3fIu6Uom7ZcyzEgYMlCC_GX-5SmWHuLI,20762
125
- beswarm/tools/edit_file.py,sha256=hfpLaE4ekDiAya0Le0fJuYa-xUefWHLTxc3F6zGZd7M,6912
125
+ beswarm/tools/edit_file.py,sha256=xlAD0HB_xM0yZYc0eJwLE-9mAkywXa2UQPNHzG1OaW4,7664
126
126
  beswarm/tools/planner.py,sha256=lguBCS6kpwNPoXQvqH-WySabVubT82iyWOkJnjt6dXw,1265
127
127
  beswarm/tools/repomap.py,sha256=CwvwoN5Swr42EzrORTTeV8MMb7mPviy4a4b0fxBu50k,40828
128
128
  beswarm/tools/search_arxiv.py,sha256=9slwBemXjEqrd7-YgVmyMijPXlkhZCybEDRVhWVQ9B0,7937
129
129
  beswarm/tools/search_web.py,sha256=B24amOnGHnmdV_6S8bw8O2PdhZRRIDtJjg-wXcfP7dQ,11859
130
130
  beswarm/tools/think.py,sha256=WLw-7jNIsnS6n8MMSYUin_f-BGLENFmnKM2LISEp0co,1760
131
131
  beswarm/tools/worker.py,sha256=b-FvSEP27-zMYNcqaQeVBoWxaSf2cX_7_1p1GAF6h04,6191
132
- beswarm-0.1.55.dist-info/METADATA,sha256=zYcsCjxq2DQCq_sax7vYE0k1Axqj7vDFH0Q2Ylw3KxY,3537
133
- beswarm-0.1.55.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
134
- beswarm-0.1.55.dist-info/top_level.txt,sha256=pJw4O87wvt5882smuSO6DfByJz7FJ8SxxT8h9fHCmpo,8
135
- beswarm-0.1.55.dist-info/RECORD,,
132
+ beswarm-0.1.57.dist-info/METADATA,sha256=FdjwXDGhJw1_43unl9YjSFbzl8jB5Pu-g0KX_Hn_TNA,3553
133
+ beswarm-0.1.57.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
134
+ beswarm-0.1.57.dist-info/top_level.txt,sha256=pJw4O87wvt5882smuSO6DfByJz7FJ8SxxT8h9fHCmpo,8
135
+ beswarm-0.1.57.dist-info/RECORD,,