aient 1.2.16__tar.gz → 1.2.18__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 (56) hide show
  1. {aient-1.2.16 → aient-1.2.18}/PKG-INFO +1 -1
  2. {aient-1.2.16 → aient-1.2.18}/aient/architext/architext/core.py +37 -19
  3. {aient-1.2.16 → aient-1.2.18}/aient/architext/test/test.py +23 -0
  4. {aient-1.2.16 → aient-1.2.18}/aient/models/chatgpt.py +3 -0
  5. {aient-1.2.16 → aient-1.2.18}/aient.egg-info/PKG-INFO +1 -1
  6. {aient-1.2.16 → aient-1.2.18}/pyproject.toml +1 -1
  7. {aient-1.2.16 → aient-1.2.18}/LICENSE +0 -0
  8. {aient-1.2.16 → aient-1.2.18}/README.md +0 -0
  9. {aient-1.2.16 → aient-1.2.18}/aient/__init__.py +0 -0
  10. {aient-1.2.16 → aient-1.2.18}/aient/architext/architext/__init__.py +0 -0
  11. {aient-1.2.16 → aient-1.2.18}/aient/architext/test/openai_client.py +0 -0
  12. {aient-1.2.16 → aient-1.2.18}/aient/architext/test/test_save_load.py +0 -0
  13. {aient-1.2.16 → aient-1.2.18}/aient/core/__init__.py +0 -0
  14. {aient-1.2.16 → aient-1.2.18}/aient/core/log_config.py +0 -0
  15. {aient-1.2.16 → aient-1.2.18}/aient/core/models.py +0 -0
  16. {aient-1.2.16 → aient-1.2.18}/aient/core/request.py +0 -0
  17. {aient-1.2.16 → aient-1.2.18}/aient/core/response.py +0 -0
  18. {aient-1.2.16 → aient-1.2.18}/aient/core/test/test_base_api.py +0 -0
  19. {aient-1.2.16 → aient-1.2.18}/aient/core/test/test_geminimask.py +0 -0
  20. {aient-1.2.16 → aient-1.2.18}/aient/core/test/test_image.py +0 -0
  21. {aient-1.2.16 → aient-1.2.18}/aient/core/test/test_payload.py +0 -0
  22. {aient-1.2.16 → aient-1.2.18}/aient/core/utils.py +0 -0
  23. {aient-1.2.16 → aient-1.2.18}/aient/models/__init__.py +0 -0
  24. {aient-1.2.16 → aient-1.2.18}/aient/models/audio.py +0 -0
  25. {aient-1.2.16 → aient-1.2.18}/aient/models/base.py +0 -0
  26. {aient-1.2.16 → aient-1.2.18}/aient/plugins/__init__.py +0 -0
  27. {aient-1.2.16 → aient-1.2.18}/aient/plugins/arXiv.py +0 -0
  28. {aient-1.2.16 → aient-1.2.18}/aient/plugins/config.py +0 -0
  29. {aient-1.2.16 → aient-1.2.18}/aient/plugins/excute_command.py +0 -0
  30. {aient-1.2.16 → aient-1.2.18}/aient/plugins/get_time.py +0 -0
  31. {aient-1.2.16 → aient-1.2.18}/aient/plugins/image.py +0 -0
  32. {aient-1.2.16 → aient-1.2.18}/aient/plugins/list_directory.py +0 -0
  33. {aient-1.2.16 → aient-1.2.18}/aient/plugins/read_file.py +0 -0
  34. {aient-1.2.16 → aient-1.2.18}/aient/plugins/read_image.py +0 -0
  35. {aient-1.2.16 → aient-1.2.18}/aient/plugins/readonly.py +0 -0
  36. {aient-1.2.16 → aient-1.2.18}/aient/plugins/registry.py +0 -0
  37. {aient-1.2.16 → aient-1.2.18}/aient/plugins/run_python.py +0 -0
  38. {aient-1.2.16 → aient-1.2.18}/aient/plugins/websearch.py +0 -0
  39. {aient-1.2.16 → aient-1.2.18}/aient/plugins/write_file.py +0 -0
  40. {aient-1.2.16 → aient-1.2.18}/aient/utils/__init__.py +0 -0
  41. {aient-1.2.16 → aient-1.2.18}/aient/utils/prompt.py +0 -0
  42. {aient-1.2.16 → aient-1.2.18}/aient/utils/scripts.py +0 -0
  43. {aient-1.2.16 → aient-1.2.18}/aient.egg-info/SOURCES.txt +0 -0
  44. {aient-1.2.16 → aient-1.2.18}/aient.egg-info/dependency_links.txt +0 -0
  45. {aient-1.2.16 → aient-1.2.18}/aient.egg-info/requires.txt +0 -0
  46. {aient-1.2.16 → aient-1.2.18}/aient.egg-info/top_level.txt +0 -0
  47. {aient-1.2.16 → aient-1.2.18}/setup.cfg +0 -0
  48. {aient-1.2.16 → aient-1.2.18}/test/test_Web_crawler.py +0 -0
  49. {aient-1.2.16 → aient-1.2.18}/test/test_ddg_search.py +0 -0
  50. {aient-1.2.16 → aient-1.2.18}/test/test_google_search.py +0 -0
  51. {aient-1.2.16 → aient-1.2.18}/test/test_ollama.py +0 -0
  52. {aient-1.2.16 → aient-1.2.18}/test/test_plugin.py +0 -0
  53. {aient-1.2.16 → aient-1.2.18}/test/test_search.py +0 -0
  54. {aient-1.2.16 → aient-1.2.18}/test/test_url.py +0 -0
  55. {aient-1.2.16 → aient-1.2.18}/test/test_whisper.py +0 -0
  56. {aient-1.2.16 → aient-1.2.18}/test/test_yjh.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.2.16
3
+ Version: 1.2.18
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -672,30 +672,48 @@ class Messages:
672
672
  return Messages(*self._messages[index])
673
673
  return self._messages[index]
674
674
 
675
- def __setitem__(self, index: slice, value: 'Messages'):
676
- if not isinstance(index, slice) or not isinstance(value, Messages):
677
- raise TypeError("Unsupported operand type(s) for slice assignment")
675
+ def __setitem__(self, index: Union[int, slice], value: Union[Message, 'Messages']):
676
+ if isinstance(index, int):
677
+ if not isinstance(value, Message):
678
+ raise TypeError("When assigning to an index, the value must be a Message.")
678
679
 
679
- # Basic slice assignment logic.
680
- # A more robust implementation would handle step and negative indices.
681
- start, stop, step = index.indices(len(self._messages))
680
+ if not (-len(self._messages) <= index < len(self._messages)):
681
+ raise IndexError("Messages assignment index out of range")
682
682
 
683
- if step != 1:
684
- raise ValueError("Slice assignment with step is not supported.")
685
-
686
- # Remove old providers from the index
687
- for i in range(start, stop):
688
- for provider in self._messages[i].provider():
683
+ # Get old message to remove its providers
684
+ old_message = self._messages[index]
685
+ for provider in old_message.provider():
689
686
  self._notify_provider_removed(provider)
690
687
 
691
- # Replace the slice in the list
692
- self._messages[start:stop] = value._messages
688
+ # Assign new message
689
+ self._messages[index] = value
690
+ value._parent_messages = self
691
+ for provider in value.provider():
692
+ self._notify_provider_added(provider, value)
693
+
694
+ elif isinstance(index, slice):
695
+ if not isinstance(value, Messages):
696
+ raise TypeError("When assigning to a slice, the value must be a Messages object.")
693
697
 
694
- # Add new providers to the index and set parent
695
- for msg in value:
696
- msg._parent_messages = self
697
- for provider in msg.provider():
698
- self._notify_provider_added(provider, msg)
698
+ start, stop, step = index.indices(len(self._messages))
699
+ if step != 1:
700
+ raise ValueError("Slice assignment with step is not supported.")
701
+
702
+ # Remove old providers from the index
703
+ for i in range(start, stop):
704
+ for provider in self._messages[i].provider():
705
+ self._notify_provider_removed(provider)
706
+
707
+ # Replace the slice in the list
708
+ self._messages[start:stop] = value._messages
709
+
710
+ # Add new providers to the index and set parent
711
+ for msg in value:
712
+ msg._parent_messages = self
713
+ for provider in msg.provider():
714
+ self._notify_provider_added(provider, msg)
715
+ else:
716
+ raise TypeError("Unsupported operand type(s) for assignment")
699
717
 
700
718
  def __len__(self) -> int: return len(self._messages)
701
719
  def __iter__(self): return iter(self._messages)
@@ -1386,6 +1386,29 @@ Files: {Files(visible=True, name="files")}
1386
1386
  if os.path.exists(test_file):
1387
1387
  os.remove(test_file)
1388
1388
 
1389
+ async def test_zh_provider_plus_message_assignment(self):
1390
+ """测试 ContextProvider + Message 的结果可以赋值回 Messages 列表"""
1391
+ # 1. 准备 provider 和 messages
1392
+ text_provider = Texts("Prefix text.")
1393
+ messages = Messages(
1394
+ UserMessage("Initial user message.")
1395
+ )
1396
+
1397
+ # 2. 执行操作
1398
+ # 这行代码在修改 __setitem__ 之前应该会失败
1399
+ messages[0] = text_provider + messages[0]
1400
+
1401
+ # 3. 验证结果
1402
+ self.assertEqual(len(messages), 1)
1403
+ self.assertEqual(len(messages[0]), 2) # Now UserMessage has two providers
1404
+
1405
+ # 4. 验证内容
1406
+ rendered = await messages.render_latest()
1407
+ self.assertEqual(rendered[0]['content'], "Prefix text.Initial user message.")
1408
+
1409
+ # 5. 验证 provider 索引
1410
+ self.assertIsNotNone(messages.provider(text_provider.name))
1411
+
1389
1412
 
1390
1413
  # ==============================================================================
1391
1414
  # 6. 演示
@@ -586,6 +586,9 @@ class chatgpt(BaseLLM):
586
586
  if tool_name == "read_file" and "<tool_error>" not in tool_response:
587
587
  self.conversation[convo_id].provider("files").update(tool_info['parameter']["file_path"], tool_response)
588
588
  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>.")
589
+ if tool_name == "get_knowledge_graph_tree" and "<tool_error>" not in tool_response:
590
+ self.conversation[convo_id].provider("knowledge_graph").visible = True
591
+ all_responses.append(f"[{tool_name}({tool_args}) Result]:\n\nGet knowledge graph tree successfully! The knowledge graph tree has been updated in the tag <knowledge_graph_tree>.")
589
592
  elif tool_name == "write_to_file" and "<tool_error>" not in tool_response:
590
593
  all_responses.append(f"[{tool_name} Result]:\n\n{tool_response}")
591
594
  elif tool_name == "read_image" and "<tool_error>" not in tool_response:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.2.16
3
+ Version: 1.2.18
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aient"
3
- version = "1.2.16"
3
+ version = "1.2.18"
4
4
  description = "Aient: The Awakening of Agent."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
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