aient 1.0.97__tar.gz → 1.0.99__tar.gz

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.
Files changed (79) hide show
  1. {aient-1.0.97/src/aient.egg-info → aient-1.0.99}/PKG-INFO +1 -1
  2. {aient-1.0.97 → aient-1.0.99}/setup.py +1 -1
  3. {aient-1.0.97 → aient-1.0.99}/src/aient/models/chatgpt.py +0 -2
  4. {aient-1.0.97 → aient-1.0.99}/src/aient/prompt/agent.py +33 -25
  5. {aient-1.0.97 → aient-1.0.99}/src/aient/utils/scripts.py +16 -6
  6. {aient-1.0.97 → aient-1.0.99/src/aient.egg-info}/PKG-INFO +1 -1
  7. {aient-1.0.97 → aient-1.0.99}/LICENSE +0 -0
  8. {aient-1.0.97 → aient-1.0.99}/MANIFEST.in +0 -0
  9. {aient-1.0.97 → aient-1.0.99}/README.md +0 -0
  10. {aient-1.0.97 → aient-1.0.99}/setup.cfg +0 -0
  11. {aient-1.0.97 → aient-1.0.99}/src/aient/__init__.py +0 -0
  12. {aient-1.0.97 → aient-1.0.99}/src/aient/core/.git +0 -0
  13. {aient-1.0.97 → aient-1.0.99}/src/aient/core/.gitignore +0 -0
  14. {aient-1.0.97 → aient-1.0.99}/src/aient/core/__init__.py +0 -0
  15. {aient-1.0.97 → aient-1.0.99}/src/aient/core/log_config.py +0 -0
  16. {aient-1.0.97 → aient-1.0.99}/src/aient/core/models.py +0 -0
  17. {aient-1.0.97 → aient-1.0.99}/src/aient/core/request.py +0 -0
  18. {aient-1.0.97 → aient-1.0.99}/src/aient/core/response.py +0 -0
  19. {aient-1.0.97 → aient-1.0.99}/src/aient/core/test/test_base_api.py +0 -0
  20. {aient-1.0.97 → aient-1.0.99}/src/aient/core/test/test_geminimask.py +0 -0
  21. {aient-1.0.97 → aient-1.0.99}/src/aient/core/test/test_image.py +0 -0
  22. {aient-1.0.97 → aient-1.0.99}/src/aient/core/test/test_payload.py +0 -0
  23. {aient-1.0.97 → aient-1.0.99}/src/aient/core/utils.py +0 -0
  24. {aient-1.0.97 → aient-1.0.99}/src/aient/models/__init__.py +0 -0
  25. {aient-1.0.97 → aient-1.0.99}/src/aient/models/audio.py +0 -0
  26. {aient-1.0.97 → aient-1.0.99}/src/aient/models/base.py +0 -0
  27. {aient-1.0.97 → aient-1.0.99}/src/aient/models/claude.py +0 -0
  28. {aient-1.0.97 → aient-1.0.99}/src/aient/models/duckduckgo.py +0 -0
  29. {aient-1.0.97 → aient-1.0.99}/src/aient/models/gemini.py +0 -0
  30. {aient-1.0.97 → aient-1.0.99}/src/aient/models/groq.py +0 -0
  31. {aient-1.0.97 → aient-1.0.99}/src/aient/models/vertex.py +0 -0
  32. {aient-1.0.97 → aient-1.0.99}/src/aient/plugins/__init__.py +0 -0
  33. {aient-1.0.97 → aient-1.0.99}/src/aient/plugins/arXiv.py +0 -0
  34. {aient-1.0.97 → aient-1.0.99}/src/aient/plugins/config.py +0 -0
  35. {aient-1.0.97 → aient-1.0.99}/src/aient/plugins/excute_command.py +0 -0
  36. {aient-1.0.97 → aient-1.0.99}/src/aient/plugins/get_time.py +0 -0
  37. {aient-1.0.97 → aient-1.0.99}/src/aient/plugins/image.py +0 -0
  38. {aient-1.0.97 → aient-1.0.99}/src/aient/plugins/list_directory.py +0 -0
  39. {aient-1.0.97 → aient-1.0.99}/src/aient/plugins/read_file.py +0 -0
  40. {aient-1.0.97 → aient-1.0.99}/src/aient/plugins/registry.py +0 -0
  41. {aient-1.0.97 → aient-1.0.99}/src/aient/plugins/run_python.py +0 -0
  42. {aient-1.0.97 → aient-1.0.99}/src/aient/plugins/websearch.py +0 -0
  43. {aient-1.0.97 → aient-1.0.99}/src/aient/plugins/write_file.py +0 -0
  44. {aient-1.0.97 → aient-1.0.99}/src/aient/prompt/__init__.py +0 -0
  45. {aient-1.0.97 → aient-1.0.99}/src/aient/utils/__init__.py +0 -0
  46. {aient-1.0.97 → aient-1.0.99}/src/aient/utils/prompt.py +0 -0
  47. {aient-1.0.97 → aient-1.0.99}/src/aient.egg-info/SOURCES.txt +0 -0
  48. {aient-1.0.97 → aient-1.0.99}/src/aient.egg-info/dependency_links.txt +0 -0
  49. {aient-1.0.97 → aient-1.0.99}/src/aient.egg-info/requires.txt +0 -0
  50. {aient-1.0.97 → aient-1.0.99}/src/aient.egg-info/top_level.txt +0 -0
  51. {aient-1.0.97 → aient-1.0.99}/test/test.py +0 -0
  52. {aient-1.0.97 → aient-1.0.99}/test/test_API.py +0 -0
  53. {aient-1.0.97 → aient-1.0.99}/test/test_Deepbricks.py +0 -0
  54. {aient-1.0.97 → aient-1.0.99}/test/test_Web_crawler.py +0 -0
  55. {aient-1.0.97 → aient-1.0.99}/test/test_aiwaves.py +0 -0
  56. {aient-1.0.97 → aient-1.0.99}/test/test_aiwaves_arxiv.py +0 -0
  57. {aient-1.0.97 → aient-1.0.99}/test/test_ask_gemini.py +0 -0
  58. {aient-1.0.97 → aient-1.0.99}/test/test_class.py +0 -0
  59. {aient-1.0.97 → aient-1.0.99}/test/test_claude.py +0 -0
  60. {aient-1.0.97 → aient-1.0.99}/test/test_claude_zh_char.py +0 -0
  61. {aient-1.0.97 → aient-1.0.99}/test/test_ddg_search.py +0 -0
  62. {aient-1.0.97 → aient-1.0.99}/test/test_download_pdf.py +0 -0
  63. {aient-1.0.97 → aient-1.0.99}/test/test_gemini.py +0 -0
  64. {aient-1.0.97 → aient-1.0.99}/test/test_get_token_dict.py +0 -0
  65. {aient-1.0.97 → aient-1.0.99}/test/test_google_search.py +0 -0
  66. {aient-1.0.97 → aient-1.0.99}/test/test_jieba.py +0 -0
  67. {aient-1.0.97 → aient-1.0.99}/test/test_json.py +0 -0
  68. {aient-1.0.97 → aient-1.0.99}/test/test_logging.py +0 -0
  69. {aient-1.0.97 → aient-1.0.99}/test/test_ollama.py +0 -0
  70. {aient-1.0.97 → aient-1.0.99}/test/test_plugin.py +0 -0
  71. {aient-1.0.97 → aient-1.0.99}/test/test_py_run.py +0 -0
  72. {aient-1.0.97 → aient-1.0.99}/test/test_requests.py +0 -0
  73. {aient-1.0.97 → aient-1.0.99}/test/test_search.py +0 -0
  74. {aient-1.0.97 → aient-1.0.99}/test/test_tikitoken.py +0 -0
  75. {aient-1.0.97 → aient-1.0.99}/test/test_token.py +0 -0
  76. {aient-1.0.97 → aient-1.0.99}/test/test_url.py +0 -0
  77. {aient-1.0.97 → aient-1.0.99}/test/test_whisper.py +0 -0
  78. {aient-1.0.97 → aient-1.0.99}/test/test_wildcard.py +0 -0
  79. {aient-1.0.97 → aient-1.0.99}/test/test_yjh.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.0.97
3
+ Version: 1.0.99
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
4
4
 
5
5
  setup(
6
6
  name="aient",
7
- version="1.0.97",
7
+ version="1.0.99",
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",
@@ -439,8 +439,6 @@ class chatgpt(BaseLLM):
439
439
  if function_parameter:
440
440
  invalid_tools = [tool_dict for tool_dict in function_parameter if tool_dict.get("function_name", "") not in self.plugins.keys()]
441
441
  function_parameter = [tool_dict for tool_dict in function_parameter if tool_dict.get("function_name", "") in self.plugins.keys()]
442
- for tool_dict in invalid_tools:
443
- full_response = full_response + f"\n\nFunction: {tool_dict.get('function_name', '')} does not exist! I must use existing functions. I need to try again."
444
442
  if self.print_log and invalid_tools:
445
443
  print("invalid_tools", invalid_tools)
446
444
  print("function_parameter", function_parameter)
@@ -71,15 +71,19 @@ Answer the user's request using the relevant tool(s), if they are available. Che
71
71
 
72
72
  You have tools at your disposal to solve the coding task. Follow these rules regarding tool calls:
73
73
 
74
- Tool uses are formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure:
74
+ Tool uses are formatted using XML-style tags.
75
+ The **actual name of the tool** (e.g., `read_file`, `edit_file`) must be used as the main XML tag.
76
+ Do **NOT** use literal placeholder strings like `<tool_name>`, `<parameter1_name>`, or `<tool_name1>` as actual XML tags. These are for illustration only. Always use the specific tool name and its defined parameter names.
75
77
 
76
- <tool_name>
77
- <parameter1_name>value1</parameter1_name>
78
- <parameter2_name>value2</parameter2_name>
78
+ Here's how to structure a single tool call. Replace `actual_tool_name_here` with the specific tool's name, and `parameter_name` with actual parameter names for that tool:
79
+
80
+ <actual_tool_name_here>
81
+ <parameter_name>value</parameter_name>
82
+ <another_parameter_name>another_value</another_parameter_name>
79
83
  ...
80
- </tool_name>
84
+ </actual_tool_name_here>
81
85
 
82
- For example:
86
+ For example, to use the `read_file` tool:
83
87
 
84
88
  <read_file>
85
89
  <file_path>
@@ -87,18 +91,18 @@ For example:
87
91
  </file_path>
88
92
  </read_file>
89
93
 
90
- you can call multiple tools in one turn, for example:
94
+ If you need to call multiple tools in one turn, list each tool call's XML structure sequentially. For example:
91
95
 
92
- <tool_name1>
96
+ <actual_tool_name1_here>
93
97
  <parameter1_name>value1</parameter1_name>
94
98
  ...
95
- </tool_name1>
99
+ </actual_tool_name1_here>
96
100
 
97
101
  ...
98
- <tool_name2>
102
+ <actual_tool_name2_here>
99
103
  <parameter1_name>value1</parameter1_name>
100
104
  ...
101
- </tool_name2>
105
+ </actual_tool_name2_here>
102
106
 
103
107
  When calling tools in parallel, multiple different or the same tools can be invoked simultaneously. 你可以同时执行这两个或者多个操作。
104
108
 
@@ -161,34 +165,36 @@ instruction_system_prompt = """
161
165
 
162
166
  工具使用规范如下:
163
167
 
164
- Tool uses are formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure:
168
+ Tool uses are formatted using XML-style tags.
169
+ The **actual name of the tool** (e.g., `read_file`, `edit_file`) must be used as the main XML tag.
170
+ Do **NOT** use literal placeholder strings like `<tool_name>`, `<parameter1_name>`, or `<tool_name1>` as actual XML tags. These are for illustration only. Always use the specific tool name and its defined parameter names.
165
171
 
166
- <tool_name>
167
- <parameter1_name>value1</parameter1_name>
168
- <parameter2_name>value2</parameter2_name>
172
+ Here's how to structure a single tool call. Replace `actual_tool_name_here` with the specific tool's name, and `parameter_name` with actual parameter names for that tool:
173
+
174
+ <actual_tool_name_here>
175
+ <parameter_name>value</parameter_name>
176
+ <another_parameter_name>another_value</another_parameter_name>
169
177
  ...
170
- </tool_name>
178
+ </actual_tool_name_here>
171
179
 
172
- For example:
180
+ For example, to use the `read_file` tool:
173
181
 
174
182
  <read_file>
175
- <file_path>
176
- /path/to/file.txt
177
- </file_path>
183
+ <file_path>/path/to/file.txt</file_path>
178
184
  </read_file>
179
185
 
180
- you can call multiple tools in one turn, for example:
186
+ If you need to call multiple tools in one turn, list each tool call's XML structure sequentially. For example:
181
187
 
182
- <tool_name1>
188
+ <actual_tool_name1_here>
183
189
  <parameter1_name>value1</parameter1_name>
184
190
  ...
185
- </tool_name1>
191
+ </actual_tool_name1_here>
186
192
 
187
193
  ...
188
- <tool_name2>
194
+ <actual_tool_name2_here>
189
195
  <parameter1_name>value1</parameter1_name>
190
196
  ...
191
- </tool_name2>
197
+ </actual_tool_name2_here>
192
198
 
193
199
  When calling tools in parallel, multiple different or the same tools can be invoked simultaneously.
194
200
 
@@ -211,7 +217,9 @@ git clone https://github.com/username/project-name.git
211
217
  </excute_command>
212
218
 
213
219
  工作智能体仅可以使用如下工具:
220
+ <tools>
214
221
  {tools_list}
222
+ </tools>
215
223
  """
216
224
 
217
225
  cursor_prompt = """
@@ -413,13 +413,15 @@ class XmlMatcher(Generic[R]):
413
413
  self._update(chunk)
414
414
  return self._pop()
415
415
 
416
- def parse_function_xml(xml_content: str) -> List[Dict[str, Any]]:
416
+ def parse_function_xml(xml_content: str, check_line_start: bool = True) -> List[Dict[str, Any]]:
417
417
  """
418
418
  解析XML格式的函数调用信息,转换为字典数组格式
419
419
  只解析倒数两层XML标签,忽略更高层级的XML标签
420
+ 当 check_line_start 为 True 时,只解析行首的XML标签。
420
421
 
421
422
  参数:
422
423
  xml_content: 包含一个或多个函数调用的XML字符串
424
+ check_line_start: 布尔值,指示是否只解析行首的XML标签
423
425
 
424
426
  返回:
425
427
  包含所有函数调用信息的字典数组,每个字典包含函数名和参数
@@ -434,6 +436,14 @@ def parse_function_xml(xml_content: str) -> List[Dict[str, Any]]:
434
436
  if tag_start == -1:
435
437
  break # 没有找到更多的标签
436
438
 
439
+ # 新增:如果 check_line_start 为 True,检查标签是否在行首
440
+ # 如果 '<' 不在行首 (即 tag_start > 0 且其前一个字符不是换行符),
441
+ # 则将其视为普通文本的一部分,移动 position 并继续搜索
442
+ if check_line_start:
443
+ if tag_start > 0 and xml_content[tag_start - 1] != '\n':
444
+ position = tag_start + 1 # 从 '<' 之后继续搜索
445
+ continue
446
+
437
447
  # 检查是否是XML标签的开始(不是闭合标签)
438
448
  if tag_start + 1 < len(xml_content) and xml_content[tag_start + 1] == '/':
439
449
  # 这是一个结束标签,跳过
@@ -476,8 +486,8 @@ def parse_function_xml(xml_content: str) -> List[Dict[str, Any]]:
476
486
 
477
487
  # 如果是普通辅助标签(如tool_call),则在其内部寻找函数调用
478
488
  if tag_name in ["tool_call", "function_call", "tool", "function"]:
479
- # 递归处理内部内容
480
- nested_functions = parse_function_xml(tag_inner_content)
489
+ # 递归处理内部内容,此时不再检查行首条件
490
+ nested_functions = parse_function_xml(tag_inner_content, check_line_start=False)
481
491
  result_functions.extend(nested_functions)
482
492
  else:
483
493
  # 将当前标签作为函数名,解析其内部标签作为参数
@@ -646,7 +656,7 @@ def convert_functions_to_xml(functions_list):
646
656
 
647
657
  if __name__ == "__main__":
648
658
 
649
- # 运行本文件:python -m aient.utils.scripts
659
+ # 运行本文件:python -m beswarm.aient.src.aient.utils.scripts
650
660
  os.system("clear")
651
661
  test_xml = """
652
662
  ✅ 好的,我现在读取 `README.md` 文件。
@@ -656,6 +666,7 @@ if __name__ == "__main__":
656
666
  </read_file>
657
667
  </tool_call>好的,我现在读取 `README.md` 文件。
658
668
  """
669
+ test_xml = """首先使用read_file工具读取论文内容,然后使用excute_command工具克隆代码仓库到本地。\n```xml\n<read_file>\n<file_path>/Users/yanyuming/Downloads/GitHub/OceanSynthesis/papers/2412.06410v1.pdf</file_path>\n</read_file>\n\n<excute_command>\n<command>git clone https://github.com/bartbussmann/BatchTopK.git</command>\n</excute_command>\n```"""
659
670
  test_xml = """
660
671
  ✅ 好的,我现在读取 `README.md` 文件。
661
672
  <read_file>
@@ -670,8 +681,7 @@ if __name__ == "__main__":
670
681
  <file_path>README.md</file_path>
671
682
  </read_file>
672
683
  </tool_call>
673
- 好的,我现在读取 `README.md` 文件。
684
+ 好的,我现在读取 `README.md` 文件。`<answer> </answer>`
674
685
  """
675
686
 
676
- test_xml = """首先使用read_file工具读取论文内容,然后使用excute_command工具克隆代码仓库到本地。\n```xml\n<read_file>\n<file_path>/Users/yanyuming/Downloads/GitHub/OceanSynthesis/papers/2412.06410v1.pdf</file_path>\n</read_file>\n\n<excute_command>\n<command>git clone https://github.com/bartbussmann/BatchTopK.git</command>\n</excute_command>\n```"""
677
687
  print(parse_function_xml(test_xml))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.0.97
3
+ Version: 1.0.99
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes