beswarm 0.1.77__py3-none-any.whl → 0.1.78__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 +1 -1
- beswarm/aient/src/aient/models/chatgpt.py +4 -0
- beswarm/aient/src/aient/plugins/excute_command.py +8 -5
- beswarm/aient/src/aient/plugins/list_directory.py +3 -3
- beswarm/aient/src/aient/plugins/run_python.py +1 -1
- beswarm/aient/src/aient/plugins/write_file.py +1 -1
- beswarm/tools/edit_file.py +13 -13
- beswarm/tools/search_arxiv.py +3 -3
- beswarm/tools/worker.py +4 -0
- {beswarm-0.1.77.dist-info → beswarm-0.1.78.dist-info}/METADATA +1 -1
- {beswarm-0.1.77.dist-info → beswarm-0.1.78.dist-info}/RECORD +13 -13
- {beswarm-0.1.77.dist-info → beswarm-0.1.78.dist-info}/WHEEL +0 -0
- {beswarm-0.1.77.dist-info → beswarm-0.1.78.dist-info}/top_level.txt +0 -0
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.
|
7
|
+
version="1.1.28",
|
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",
|
@@ -462,6 +462,10 @@ class chatgpt(BaseLLM):
|
|
462
462
|
print("full_response", full_response)
|
463
463
|
if function_parameter:
|
464
464
|
need_function_call = True
|
465
|
+
if isinstance(self.conversation[convo_id][-1]["content"], str) and \
|
466
|
+
"<tool_error>" in self.conversation[convo_id][-1]["content"]:
|
467
|
+
need_function_call = False
|
468
|
+
full_response = "接下来我需要做什么?"
|
465
469
|
else:
|
466
470
|
need_function_call = False
|
467
471
|
if self.print_log:
|
@@ -178,18 +178,21 @@ def excute_command(command):
|
|
178
178
|
# print(f"output_lines: {len(new_output_lines)}")
|
179
179
|
|
180
180
|
if process.returncode == 0:
|
181
|
-
|
181
|
+
if final_output_log.strip() == "":
|
182
|
+
return f"执行命令成功"
|
183
|
+
else:
|
184
|
+
return f"执行命令成功:\n{final_output_log.strip()}"
|
182
185
|
else:
|
183
186
|
# 如果是 PTY 模式,stderr 已经包含在 final_output_log 中
|
184
187
|
if IS_UNIX:
|
185
|
-
return f"
|
188
|
+
return f"<tool_error>执行命令失败 (退出码 {process.returncode}):\n输出/错误:\n{final_output_log}</tool_error>"
|
186
189
|
else:
|
187
|
-
return f"
|
190
|
+
return f"<tool_error>执行命令失败 (退出码 {process.returncode}):\n错误: {stderr_output}\n输出: {final_output_log}</tool_error>"
|
188
191
|
|
189
192
|
except FileNotFoundError:
|
190
|
-
return f"
|
193
|
+
return f"<tool_error>执行命令失败: 命令或程序未找到 ({command})</tool_error>"
|
191
194
|
except Exception as e:
|
192
|
-
return f"
|
195
|
+
return f"<tool_error>执行命令时发生异常: {e}</tool_error>"
|
193
196
|
|
194
197
|
if __name__ == "__main__":
|
195
198
|
# print(excute_command("ls -l && echo 'Hello, World!'"))
|
@@ -43,8 +43,8 @@ def list_directory(path="."):
|
|
43
43
|
return result
|
44
44
|
|
45
45
|
except FileNotFoundError:
|
46
|
-
return f"
|
46
|
+
return f"<tool_error>路径 '{path}' 不存在</tool_error>"
|
47
47
|
except PermissionError:
|
48
|
-
return f"
|
48
|
+
return f"<tool_error>没有权限访问路径 '{path}'</tool_error>"
|
49
49
|
except Exception as e:
|
50
|
-
return f"
|
50
|
+
return f"<tool_error>列出目录时发生错误: {e}</tool_error>"
|
@@ -53,7 +53,7 @@ Example: Requesting to write to frontend-config.json
|
|
53
53
|
with open(path, mode, encoding='utf-8') as file:
|
54
54
|
file.write(unescape_html(content))
|
55
55
|
except PermissionError as e:
|
56
|
-
return f"
|
56
|
+
return f"<tool_error>写入文件失败: {e}</tool_error>"
|
57
57
|
|
58
58
|
return f"已成功写入文件:{path}"
|
59
59
|
|
beswarm/tools/edit_file.py
CHANGED
@@ -32,18 +32,18 @@ def edit_file(file_path, diff_content, match_precision=0.9):
|
|
32
32
|
try:
|
33
33
|
# 检查文件是否存在
|
34
34
|
if not os.path.exists(file_path):
|
35
|
-
return f"
|
35
|
+
return f"<tool_error>文件 '{file_path}' 不存在</tool_error>"
|
36
36
|
|
37
37
|
# 检查是否为文件
|
38
38
|
if not os.path.isfile(file_path):
|
39
|
-
return f"
|
39
|
+
return f"<tool_error>文件 '{file_path}' 不是一个文件</tool_error>"
|
40
40
|
|
41
41
|
# 尝试读取文件的前几个字节来检测是否为二进制文件
|
42
42
|
with open(file_path, 'rb') as file:
|
43
43
|
data = file.read(1024)
|
44
44
|
# 快速检查是否可能是二进制文件
|
45
45
|
if b'\x00' in data:
|
46
|
-
return f"
|
46
|
+
return f"<tool_error>文件 '{file_path}' 可能是二进制文件,编码无法解析</tool_error>"
|
47
47
|
|
48
48
|
# 读取原文件内容
|
49
49
|
with open(file_path, 'r', encoding='utf-8') as file:
|
@@ -53,9 +53,9 @@ def edit_file(file_path, diff_content, match_precision=0.9):
|
|
53
53
|
diff_blocks = re.findall(r'<<<<<<< SEARCH\n(.*?)\n=======\n(.*?)\n>>>>>>> REPLACE', diff_content, re.DOTALL)
|
54
54
|
|
55
55
|
if not diff_blocks:
|
56
|
-
return f"
|
56
|
+
return f"<tool_error>无效的diff格式,未找到搜索和替换块</tool_error>"
|
57
57
|
if len(diff_blocks) > 1:
|
58
|
-
return f"
|
58
|
+
return f"<tool_error>只支持单次修改,`diff_content`参数中**必须只包含一个** `<<<<<<< SEARCH ... >>>>>>> REPLACE` 块,但找到了 {len(diff_blocks)} 个修改块</tool_error>"
|
59
59
|
|
60
60
|
# 记录修改次数和行数变化
|
61
61
|
edits_count = 0
|
@@ -69,7 +69,7 @@ def edit_file(file_path, diff_content, match_precision=0.9):
|
|
69
69
|
replace_block = unescape_html(replace_block)
|
70
70
|
# 检查搜索块是否为空
|
71
71
|
if not search_block.strip():
|
72
|
-
return f"
|
72
|
+
return f"<tool_error>搜索块不能为空</tool_error>"
|
73
73
|
|
74
74
|
if search_block in new_content:
|
75
75
|
# 直接替换完全匹配的块
|
@@ -88,7 +88,7 @@ def edit_file(file_path, diff_content, match_precision=0.9):
|
|
88
88
|
|
89
89
|
# 避免空搜索块
|
90
90
|
if len(search_lines) == 0:
|
91
|
-
return f"
|
91
|
+
return f"<tool_error>搜索块不能为空</tool_error>"
|
92
92
|
|
93
93
|
# 尝试找到最佳匹配位置
|
94
94
|
best_match_index = -1
|
@@ -142,18 +142,18 @@ def edit_file(file_path, diff_content, match_precision=0.9):
|
|
142
142
|
total_original_lines += original_lines
|
143
143
|
total_new_lines += new_lines
|
144
144
|
else:
|
145
|
-
error_message = f"
|
145
|
+
error_message = f"<tool_error>在文件中未找到足够匹配的代码块,最佳匹配分数为 {best_match_score:.2f},但要求为 {match_precision:.2f}。</tool_error>"
|
146
146
|
if best_match_index != -1:
|
147
147
|
start_index = max(0, best_match_index - len(search_lines))
|
148
148
|
end_index = min(len(content_lines), best_match_index + 2 * len(search_lines))
|
149
149
|
context_lines = content_lines[start_index:end_index]
|
150
150
|
context_block = '\n'.join(context_lines)
|
151
|
-
error_message += f"\n\
|
151
|
+
error_message += f"\n\nSEARCH块在原文件最佳匹配范围内的原文如下 (上下文已扩展),放在在 <real_file_content>...</real_file_content> 之间,请根据原文内容修正 diff_content 参数:\n<real_file_content>\n{context_block}\n</real_file_content>"
|
152
152
|
return error_message
|
153
153
|
|
154
154
|
# 如果没有进行任何编辑,返回错误
|
155
155
|
if edits_count == 0:
|
156
|
-
return f"
|
156
|
+
return f"<tool_error>未能应用任何diff编辑</tool_error>"
|
157
157
|
|
158
158
|
# 写入修改后的内容
|
159
159
|
with open(file_path, 'w', encoding='utf-8') as file:
|
@@ -162,16 +162,16 @@ def edit_file(file_path, diff_content, match_precision=0.9):
|
|
162
162
|
return f"成功: 文件 '{file_path}' 已更新。应用了 {edits_count} 处编辑,替换了 {total_original_lines} 行代码为 {total_new_lines} 行。"
|
163
163
|
|
164
164
|
except PermissionError:
|
165
|
-
return f"
|
165
|
+
return f"<tool_error>没有权限修改文件 '{file_path}'</tool_error>"
|
166
166
|
except UnicodeDecodeError:
|
167
|
-
return f"
|
167
|
+
return f"<tool_error>文件 '{file_path}' 不是文本文件或编码不是UTF-8,无法进行编码解析</tool_error>"
|
168
168
|
except Exception as e:
|
169
169
|
print(f"content: {content}")
|
170
170
|
print(f"file_path: {file_path}")
|
171
171
|
print(f"diff_content: {diff_content}")
|
172
172
|
import traceback
|
173
173
|
traceback.print_exc()
|
174
|
-
return f"
|
174
|
+
return f"<tool_error>编辑文件时发生错误: {e}</tool_error>"
|
175
175
|
|
176
176
|
if __name__ == "__main__":
|
177
177
|
edit_str = """
|
beswarm/tools/search_arxiv.py
CHANGED
@@ -78,7 +78,7 @@ NoProp: Training Neural Networks without Back-propagation or Forward-propagation
|
|
78
78
|
response = requests.get(base_url, params=params)
|
79
79
|
|
80
80
|
if response.status_code != 200:
|
81
|
-
return f"
|
81
|
+
return f"<tool_error>API请求失败,状态码 {response.status_code}</tool_error>"
|
82
82
|
|
83
83
|
# 解析结果(arXiv API返回的是Atom XML格式)
|
84
84
|
# 这里使用简化的解析方式,在实际使用中可能需要更复杂的XML解析
|
@@ -155,12 +155,12 @@ NoProp: Training Neural Networks without Back-propagation or Forward-propagation
|
|
155
155
|
results.append(paper_info)
|
156
156
|
|
157
157
|
if not results:
|
158
|
-
return f"
|
158
|
+
return f"<tool_error>未找到与查询'{query}'匹配的论文</tool_error>"
|
159
159
|
|
160
160
|
return results
|
161
161
|
|
162
162
|
except Exception as e:
|
163
|
-
return f"
|
163
|
+
return f"<tool_error>搜索arXiv论文时发生错误: {str(e)}</tool_error>"
|
164
164
|
|
165
165
|
if __name__ == '__main__':
|
166
166
|
# 简单的测试用例
|
beswarm/tools/worker.py
CHANGED
@@ -115,6 +115,8 @@ async def worker(goal, tools, work_dir, cache_messages=None):
|
|
115
115
|
raise Exception(f"The request body is too long, please try again.")
|
116
116
|
if "任务已完成" == next_instruction.strip():
|
117
117
|
break
|
118
|
+
if "<instructions>" in next_instruction and "</instructions>" not in next_instruction:
|
119
|
+
next_instruction = next_instruction + "</instructions>"
|
118
120
|
next_instruction = extract_xml_content(next_instruction, "instructions")
|
119
121
|
if not next_instruction:
|
120
122
|
print("\n❌ 指令智能体生成的指令不符合要求,请重新生成。")
|
@@ -241,6 +243,8 @@ async def worker_gen(goal, tools, work_dir, cache_messages=None):
|
|
241
243
|
raise Exception(f"The request body is too long, please try again.")
|
242
244
|
if "任务已完成" == next_instruction.strip():
|
243
245
|
break
|
246
|
+
if "<instructions>" in next_instruction and "</instructions>" not in next_instruction:
|
247
|
+
next_instruction = next_instruction + "</instructions>"
|
244
248
|
next_instruction = extract_xml_content(next_instruction, "instructions")
|
245
249
|
if not next_instruction:
|
246
250
|
print("\n❌ 指令智能体生成的指令不符合要求,请重新生成。")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
beswarm/__init__.py,sha256=HZjUOJtZR5QhMuDbq-wukQQn1VrBusNWai_ysGo-VVI,20
|
2
2
|
beswarm/utils.py,sha256=Z2Kuus2BLp9EHUC2ZNL9iUsb6NWnPj-MTA7SYzGyg24,1755
|
3
3
|
beswarm/aient/main.py,sha256=SiYAIgQlLJqYusnTVEJOx1WNkSJKMImhgn5aWjfroxg,3814
|
4
|
-
beswarm/aient/setup.py,sha256=
|
4
|
+
beswarm/aient/setup.py,sha256=Gq_GJudeaB2dhYFR6-KUFW40TKhARnt1_h4JlOBJ6eQ,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=
|
19
|
+
beswarm/aient/src/aient/models/chatgpt.py,sha256=9l6_7QCF4VuOWPGZiroTT-0dg1h_qze5RUQwauDw_A4,46539
|
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
|
@@ -25,17 +25,17 @@ beswarm/aient/src/aient/models/vertex.py,sha256=qVD5l1Q538xXUPulxG4nmDjXE1VoV4yu
|
|
25
25
|
beswarm/aient/src/aient/plugins/__init__.py,sha256=p3KO6Aa3Lupos4i2SjzLQw1hzQTigOAfEHngsldrsyk,986
|
26
26
|
beswarm/aient/src/aient/plugins/arXiv.py,sha256=yHjb6PS3GUWazpOYRMKMzghKJlxnZ5TX8z9F6UtUVow,1461
|
27
27
|
beswarm/aient/src/aient/plugins/config.py,sha256=QGyI9LlNaU36GUpY531o7UbTFBB39u7LfS6rrx_RTWw,7103
|
28
|
-
beswarm/aient/src/aient/plugins/excute_command.py,sha256=
|
28
|
+
beswarm/aient/src/aient/plugins/excute_command.py,sha256=XEGg1AX8U8iUBaHBqoCmZHLCpI_wQiDSmHDFvqG6ONE,10243
|
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
|
-
beswarm/aient/src/aient/plugins/list_directory.py,sha256=
|
31
|
+
beswarm/aient/src/aient/plugins/list_directory.py,sha256=V_uKkLx_fQDL5z__bSDC-PqAP-o32KmQW6Pdhx0Fx0s,1433
|
32
32
|
beswarm/aient/src/aient/plugins/read_file.py,sha256=Lv03AW-gWGzM2esos2vLTXHcceczdTqEO7_vqFT4yoY,8302
|
33
33
|
beswarm/aient/src/aient/plugins/read_image.py,sha256=4FbIiMNVFUQpNyiH5ApGSRvOD9ujcXGyuqlGTJMd7ac,4017
|
34
34
|
beswarm/aient/src/aient/plugins/readonly.py,sha256=qK5-kBM3NDH1b-otFxFHpAjV5BXEY_e7cTWBcpP7G5k,710
|
35
35
|
beswarm/aient/src/aient/plugins/registry.py,sha256=YknzhieU_8nQ3oKlUSSWDB4X7t2Jx0JnqT2Jd9Xsvfk,3574
|
36
|
-
beswarm/aient/src/aient/plugins/run_python.py,sha256=
|
36
|
+
beswarm/aient/src/aient/plugins/run_python.py,sha256=MohvdtZUTDLrHBDtJ9L2_Qu1pWAGrkbzsGmmn5tMN20,4614
|
37
37
|
beswarm/aient/src/aient/plugins/websearch.py,sha256=llxy1U0vJiNMiKvamMr4p7IruLb3nnDR4YErz8TYimc,15215
|
38
|
-
beswarm/aient/src/aient/plugins/write_file.py,sha256=
|
38
|
+
beswarm/aient/src/aient/plugins/write_file.py,sha256=7spYxloI_aUbeANEQK-oXrGPoBqSfsD7sdfMAWlNxhU,3656
|
39
39
|
beswarm/aient/src/aient/prompt/__init__.py,sha256=GBtn6-JDT8KHFCcuPpfSNE_aGddg5p4FEyMCy4BfwGs,20
|
40
40
|
beswarm/aient/src/aient/prompt/agent.py,sha256=ebHYebxbgL-WEAKUs1NPNwxlUMucF3GNNoy3eNZrtIo,29737
|
41
41
|
beswarm/aient/src/aient/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -122,15 +122,15 @@ beswarm/queries/tree-sitter-languages/scala-tags.scm,sha256=UxQjz80JIrrJ7Pm56uUn
|
|
122
122
|
beswarm/queries/tree-sitter-languages/typescript-tags.scm,sha256=OMdCeedPiA24ky82DpgTMKXK_l2ySTuF2zrQ2fJAi9E,1253
|
123
123
|
beswarm/tools/__init__.py,sha256=YXP65SJFE1dBNRlffapdd7zsB6M6tHZ6QaQykGq7KDU,1198
|
124
124
|
beswarm/tools/click.py,sha256=TygaekCXTmU3fIu6Uom7ZcyzEgYMlCC_GX-5SmWHuLI,20762
|
125
|
-
beswarm/tools/edit_file.py,sha256=
|
125
|
+
beswarm/tools/edit_file.py,sha256=iwWl7a8sTVq4vj0e1ny3H6UGcHfYnxALRGcLuk5hZS8,9155
|
126
126
|
beswarm/tools/planner.py,sha256=lguBCS6kpwNPoXQvqH-WySabVubT82iyWOkJnjt6dXw,1265
|
127
127
|
beswarm/tools/repomap.py,sha256=N09K0UgwjCN7Zjg_5TYlVsulp3n2fztYlS8twalChU8,45003
|
128
128
|
beswarm/tools/screenshot.py,sha256=u6t8FCgW5YHJ_Oc4coo8e0F3wTusWE_-H8dFh1rBq9Q,1011
|
129
|
-
beswarm/tools/search_arxiv.py,sha256=
|
129
|
+
beswarm/tools/search_arxiv.py,sha256=GpuIOYX8T0iRC-X-hmuR9AUJVn15WWZq864DaoC7BUc,8004
|
130
130
|
beswarm/tools/search_web.py,sha256=B24amOnGHnmdV_6S8bw8O2PdhZRRIDtJjg-wXcfP7dQ,11859
|
131
131
|
beswarm/tools/think.py,sha256=WLw-7jNIsnS6n8MMSYUin_f-BGLENFmnKM2LISEp0co,1760
|
132
|
-
beswarm/tools/worker.py,sha256=
|
133
|
-
beswarm-0.1.
|
134
|
-
beswarm-0.1.
|
135
|
-
beswarm-0.1.
|
136
|
-
beswarm-0.1.
|
132
|
+
beswarm/tools/worker.py,sha256=Gx_xMuqFApBLBjfyuHcpMvK76k94f89CYMRyQaPw2UU,13251
|
133
|
+
beswarm-0.1.78.dist-info/METADATA,sha256=wQJj1Fcb63MZ-fEaUb6lSRb8LxMQIs7qRKFWCWY3Xmw,3553
|
134
|
+
beswarm-0.1.78.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
135
|
+
beswarm-0.1.78.dist-info/top_level.txt,sha256=pJw4O87wvt5882smuSO6DfByJz7FJ8SxxT8h9fHCmpo,8
|
136
|
+
beswarm-0.1.78.dist-info/RECORD,,
|
File without changes
|
File without changes
|