aient 1.1.11__py3-none-any.whl → 1.1.12__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.
aient/models/chatgpt.py CHANGED
@@ -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>"
aient/utils/scripts.py CHANGED
@@ -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))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.11
3
+ Version: 1.1.12
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -14,7 +14,7 @@ aient/core/test/test_payload.py,sha256=8jBiJY1uidm1jzL-EiK0s6UGmW9XkdsuuKFGrwFhF
14
14
  aient/models/__init__.py,sha256=ouNDNvoBBpIFrLsk09Q_sq23HR0GbLAKfGLIFmfEuXE,219
15
15
  aient/models/audio.py,sha256=kRd-8-WXzv4vwvsTGwnstK-WR8--vr9CdfCZzu8y9LA,1934
16
16
  aient/models/base.py,sha256=z-Z0pJfTN2x0cuwfvu0BdMRY9O-RmLwHEnBIJN1x4Fg,6719
17
- aient/models/chatgpt.py,sha256=6SuMfV8n0pBOaKN3WGqhPc53_LHBdyOECQgVsHscso8,46169
17
+ aient/models/chatgpt.py,sha256=sfXqmYAiTTAa_dH2h49BZnVvjebEl99LJdQGepD2sCQ,46244
18
18
  aient/models/claude.py,sha256=JezghW7y0brl4Y5qiSHvnYR5prQCFywX4RViHt39pGI,26037
19
19
  aient/models/duckduckgo.py,sha256=1l7vYCs9SG5SWPCbcl7q6pCcB5AUF_r-a4l9frz3Ogo,8115
20
20
  aient/models/gemini.py,sha256=chGLc-8G_DAOxr10HPoOhvVFW1RvMgHd6mt--VyAW98,14730
@@ -27,8 +27,8 @@ aient/plugins/excute_command.py,sha256=A3WmfZboEikU1EHvtMWhBv-xHxCyMxbDddQ982I_8
27
27
  aient/plugins/get_time.py,sha256=Ih5XIW5SDAIhrZ9W4Qe5Hs1k4ieKPUc_LAd6ySNyqZk,654
28
28
  aient/plugins/image.py,sha256=ZElCIaZznE06TN9xW3DrSukS7U3A5_cjk1Jge4NzPxw,2072
29
29
  aient/plugins/list_directory.py,sha256=JZVuImecMSfEv6jLqii-0uQJ1UCsrpMNmYlwW3PEDg4,1374
30
- aient/plugins/read_file.py,sha256=-RRmaj-rSl8y--5VKnxCsZ1YQHe75OhnqvsDRLJyujM,8412
31
- aient/plugins/read_image.py,sha256=goBnpmnmu753pQBkEROTo1ZaGE23fx5WJVr8T8z4598,2577
30
+ aient/plugins/read_file.py,sha256=Lv03AW-gWGzM2esos2vLTXHcceczdTqEO7_vqFT4yoY,8302
31
+ aient/plugins/read_image.py,sha256=jFu8MGCPWg19YOG-STWH3pqacf94F17i_4JaJu1XWLs,2704
32
32
  aient/plugins/registry.py,sha256=YknzhieU_8nQ3oKlUSSWDB4X7t2Jx0JnqT2Jd9Xsvfk,3574
33
33
  aient/plugins/run_python.py,sha256=dgcUwBunMuDkaSKR5bToudVzSdrXVewktDDFUz_iIOQ,4589
34
34
  aient/plugins/websearch.py,sha256=llxy1U0vJiNMiKvamMr4p7IruLb3nnDR4YErz8TYimc,15215
@@ -37,9 +37,9 @@ aient/prompt/__init__.py,sha256=GBtn6-JDT8KHFCcuPpfSNE_aGddg5p4FEyMCy4BfwGs,20
37
37
  aient/prompt/agent.py,sha256=y2GETN6ScC5yQVs75VFfzm4YUWzblbqLYz0Sy6JnPRw,24950
38
38
  aient/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  aient/utils/prompt.py,sha256=UcSzKkFE4-h_1b6NofI6xgk3GoleqALRKY8VBaXLjmI,11311
40
- aient/utils/scripts.py,sha256=ATxP7VZvIngYiRB6XgjP1lQHovKzXhpWL3QpsJtZYi8,27245
41
- aient-1.1.11.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
42
- aient-1.1.11.dist-info/METADATA,sha256=KlUS47nF_hR_qUuD1wINWwMevIwyzemtM0PUCgTWCkg,4968
43
- aient-1.1.11.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
44
- aient-1.1.11.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
45
- aient-1.1.11.dist-info/RECORD,,
40
+ aient/utils/scripts.py,sha256=wutPtgbs-WXo5AACLpnCJaRQBOSKXWNnsf2grbYDzyQ,29098
41
+ aient-1.1.12.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
42
+ aient-1.1.12.dist-info/METADATA,sha256=Qw9hW21BsAFZHELCET7zEMTFUvvCaJv0r2WBgJmZM-I,4968
43
+ aient-1.1.12.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
44
+ aient-1.1.12.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
45
+ aient-1.1.12.dist-info/RECORD,,
File without changes