aient 1.1.26__py3-none-any.whl → 1.1.28__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
@@ -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:
@@ -1,10 +1,9 @@
1
1
  import subprocess
2
2
  from .registry import register_tool
3
- from ..utils.scripts import sandbox
3
+ from ..utils.scripts import sandbox, unescape_html
4
4
 
5
5
  import re
6
6
  import os
7
- import html
8
7
  import select
9
8
 
10
9
  # 检查是否在 Unix-like 系统上 (pty 模块主要用于 Unix)
@@ -39,18 +38,6 @@ def compare_line(line: str) -> bool:
39
38
  # print(f"similarity: {similarity}")
40
39
  return similarity > 0.89
41
40
 
42
- def unescape_html(input_string: str) -> str:
43
- """
44
- 将字符串中的 HTML 实体(例如 &amp;)转换回其原始字符(例如 &)。
45
-
46
- Args:
47
- input_string: 包含 HTML 实体的输入字符串。
48
-
49
- Returns:
50
- 转换后的字符串。
51
- """
52
- return html.unescape(input_string)
53
-
54
41
  def get_python_executable(command: str) -> str:
55
42
  """
56
43
  获取 Python 可执行文件的路径。
@@ -191,18 +178,21 @@ def excute_command(command):
191
178
  # print(f"output_lines: {len(new_output_lines)}")
192
179
 
193
180
  if process.returncode == 0:
194
- return f"执行命令成功:\n{final_output_log}"
181
+ if final_output_log.strip() == "":
182
+ return f"执行命令成功"
183
+ else:
184
+ return f"执行命令成功:\n{final_output_log.strip()}"
195
185
  else:
196
186
  # 如果是 PTY 模式,stderr 已经包含在 final_output_log 中
197
187
  if IS_UNIX:
198
- return f"执行命令失败 (退出码 {process.returncode}):\n输出/错误:\n{final_output_log}"
188
+ return f"<tool_error>执行命令失败 (退出码 {process.returncode}):\n输出/错误:\n{final_output_log}</tool_error>"
199
189
  else:
200
- return f"执行命令失败 (退出码 {process.returncode}):\n错误: {stderr_output}\n输出: {final_output_log}"
190
+ return f"<tool_error>执行命令失败 (退出码 {process.returncode}):\n错误: {stderr_output}\n输出: {final_output_log}</tool_error>"
201
191
 
202
192
  except FileNotFoundError:
203
- return f"执行命令失败: 命令或程序未找到 ({command})"
193
+ return f"<tool_error>执行命令失败: 命令或程序未找到 ({command})</tool_error>"
204
194
  except Exception as e:
205
- return f"执行命令时发生异常: {e}"
195
+ return f"<tool_error>执行命令时发生异常: {e}</tool_error>"
206
196
 
207
197
  if __name__ == "__main__":
208
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"错误: 路径 '{path}' 不存在"
46
+ return f"<tool_error>路径 '{path}' 不存在</tool_error>"
47
47
  except PermissionError:
48
- return f"错误: 没有权限访问路径 '{path}'"
48
+ return f"<tool_error>没有权限访问路径 '{path}'</tool_error>"
49
49
  except Exception as e:
50
- return f"列出目录时发生错误: {e}"
50
+ return f"<tool_error>列出目录时发生错误: {e}</tool_error>"
@@ -129,7 +129,7 @@ if _result is not None:
129
129
 
130
130
  except Exception as e:
131
131
  logging.error(f"Error executing code: {str(e)}")
132
- return f"Error: {str(e)}"
132
+ return f"<tool_error>Error: {str(e)}</tool_error>"
133
133
 
134
134
  finally:
135
135
  try:
@@ -1,19 +1,7 @@
1
1
  from .registry import register_tool
2
+ from ..utils.scripts import unescape_html
2
3
 
3
4
  import os
4
- import html
5
-
6
- def unescape_html(input_string: str) -> str:
7
- """
8
- 将字符串中的 HTML 实体(例如 &amp;)转换回其原始字符(例如 &)。
9
-
10
- Args:
11
- input_string: 包含 HTML 实体的输入字符串。
12
-
13
- Returns:
14
- 转换后的字符串。
15
- """
16
- return html.unescape(input_string)
17
5
 
18
6
  @register_tool()
19
7
  def write_to_file(path, content, mode='w'):
@@ -65,7 +53,7 @@ Example: Requesting to write to frontend-config.json
65
53
  with open(path, mode, encoding='utf-8') as file:
66
54
  file.write(unescape_html(content))
67
55
  except PermissionError as e:
68
- return f"写入文件失败: {e}"
56
+ return f"<tool_error>写入文件失败: {e}</tool_error>"
69
57
 
70
58
  return f"已成功写入文件:{path}"
71
59
 
aient/utils/scripts.py CHANGED
@@ -202,6 +202,19 @@ def parse_tools_from_cursor_prompt(text):
202
202
  print(f"解析 JSON 时出错: {e}")
203
203
  return []
204
204
 
205
+ import html
206
+ def unescape_html(input_string: str) -> str:
207
+ """
208
+ 将字符串中的 HTML 实体(例如 &amp;)转换回其原始字符(例如 &)。
209
+
210
+ Args:
211
+ input_string: 包含 HTML 实体的输入字符串。
212
+
213
+ Returns:
214
+ 转换后的字符串。
215
+ """
216
+ return html.unescape(input_string)
217
+
205
218
  import sys
206
219
  import shlex
207
220
  import builtins
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.26
3
+ Version: 1.1.28
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=sfXqmYAiTTAa_dH2h49BZnVvjebEl99LJdQGepD2sCQ,46244
17
+ aient/models/chatgpt.py,sha256=9l6_7QCF4VuOWPGZiroTT-0dg1h_qze5RUQwauDw_A4,46539
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
@@ -23,24 +23,24 @@ aient/models/vertex.py,sha256=qVD5l1Q538xXUPulxG4nmDjXE1VoV4yuAkTCpIeJVw0,16795
23
23
  aient/plugins/__init__.py,sha256=p3KO6Aa3Lupos4i2SjzLQw1hzQTigOAfEHngsldrsyk,986
24
24
  aient/plugins/arXiv.py,sha256=yHjb6PS3GUWazpOYRMKMzghKJlxnZ5TX8z9F6UtUVow,1461
25
25
  aient/plugins/config.py,sha256=QGyI9LlNaU36GUpY531o7UbTFBB39u7LfS6rrx_RTWw,7103
26
- aient/plugins/excute_command.py,sha256=-Meu3CcC8U8Oc2lYf4OpaVQQ3YrIjBmpPEJVgONDkyI,10313
26
+ aient/plugins/excute_command.py,sha256=XEGg1AX8U8iUBaHBqoCmZHLCpI_wQiDSmHDFvqG6ONE,10243
27
27
  aient/plugins/get_time.py,sha256=Ih5XIW5SDAIhrZ9W4Qe5Hs1k4ieKPUc_LAd6ySNyqZk,654
28
28
  aient/plugins/image.py,sha256=ZElCIaZznE06TN9xW3DrSukS7U3A5_cjk1Jge4NzPxw,2072
29
- aient/plugins/list_directory.py,sha256=JZVuImecMSfEv6jLqii-0uQJ1UCsrpMNmYlwW3PEDg4,1374
29
+ aient/plugins/list_directory.py,sha256=V_uKkLx_fQDL5z__bSDC-PqAP-o32KmQW6Pdhx0Fx0s,1433
30
30
  aient/plugins/read_file.py,sha256=Lv03AW-gWGzM2esos2vLTXHcceczdTqEO7_vqFT4yoY,8302
31
31
  aient/plugins/read_image.py,sha256=4FbIiMNVFUQpNyiH5ApGSRvOD9ujcXGyuqlGTJMd7ac,4017
32
32
  aient/plugins/readonly.py,sha256=qK5-kBM3NDH1b-otFxFHpAjV5BXEY_e7cTWBcpP7G5k,710
33
33
  aient/plugins/registry.py,sha256=YknzhieU_8nQ3oKlUSSWDB4X7t2Jx0JnqT2Jd9Xsvfk,3574
34
- aient/plugins/run_python.py,sha256=dgcUwBunMuDkaSKR5bToudVzSdrXVewktDDFUz_iIOQ,4589
34
+ aient/plugins/run_python.py,sha256=MohvdtZUTDLrHBDtJ9L2_Qu1pWAGrkbzsGmmn5tMN20,4614
35
35
  aient/plugins/websearch.py,sha256=llxy1U0vJiNMiKvamMr4p7IruLb3nnDR4YErz8TYimc,15215
36
- aient/plugins/write_file.py,sha256=ndMsQhfMuobvgbFuesxb17zIk9cQIYTd9Gdr6yiiZec,3896
36
+ aient/plugins/write_file.py,sha256=7spYxloI_aUbeANEQK-oXrGPoBqSfsD7sdfMAWlNxhU,3656
37
37
  aient/prompt/__init__.py,sha256=GBtn6-JDT8KHFCcuPpfSNE_aGddg5p4FEyMCy4BfwGs,20
38
38
  aient/prompt/agent.py,sha256=ebHYebxbgL-WEAKUs1NPNwxlUMucF3GNNoy3eNZrtIo,29737
39
39
  aient/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
40
  aient/utils/prompt.py,sha256=UcSzKkFE4-h_1b6NofI6xgk3GoleqALRKY8VBaXLjmI,11311
41
- aient/utils/scripts.py,sha256=l8_NrwIRYxvzxPFg-vSJz120swdnxxGfgBcQRogJ4nI,36154
42
- aient-1.1.26.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
43
- aient-1.1.26.dist-info/METADATA,sha256=CAiFkA5V7mMkXr5LvzzEL8pko1NEEcfOTnfUPN5g9yI,4968
44
- aient-1.1.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
- aient-1.1.26.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
46
- aient-1.1.26.dist-info/RECORD,,
41
+ aient/utils/scripts.py,sha256=JVR6oNxYc9NnfQL0PGsL8QuhG43dwg0-rPS8NR_pyBM,36461
42
+ aient-1.1.28.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
43
+ aient-1.1.28.dist-info/METADATA,sha256=rsd1SRNSieT3WfswVg7WT7biuCkPNgiyhBAEKoQKbO4,4968
44
+ aient-1.1.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
+ aient-1.1.28.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
46
+ aient-1.1.28.dist-info/RECORD,,
File without changes