aient 1.1.97__tar.gz → 1.1.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 (56) hide show
  1. {aient-1.1.97 → aient-1.1.99}/PKG-INFO +1 -1
  2. {aient-1.1.97 → aient-1.1.99}/aient/architext/architext/core.py +29 -3
  3. {aient-1.1.97 → aient-1.1.99}/aient/architext/test/test.py +55 -0
  4. {aient-1.1.97 → aient-1.1.99}/aient.egg-info/PKG-INFO +1 -1
  5. {aient-1.1.97 → aient-1.1.99}/pyproject.toml +1 -1
  6. {aient-1.1.97 → aient-1.1.99}/LICENSE +0 -0
  7. {aient-1.1.97 → aient-1.1.99}/README.md +0 -0
  8. {aient-1.1.97 → aient-1.1.99}/aient/__init__.py +0 -0
  9. {aient-1.1.97 → aient-1.1.99}/aient/architext/architext/__init__.py +0 -0
  10. {aient-1.1.97 → aient-1.1.99}/aient/architext/test/openai_client.py +0 -0
  11. {aient-1.1.97 → aient-1.1.99}/aient/architext/test/test_save_load.py +0 -0
  12. {aient-1.1.97 → aient-1.1.99}/aient/core/__init__.py +0 -0
  13. {aient-1.1.97 → aient-1.1.99}/aient/core/log_config.py +0 -0
  14. {aient-1.1.97 → aient-1.1.99}/aient/core/models.py +0 -0
  15. {aient-1.1.97 → aient-1.1.99}/aient/core/request.py +0 -0
  16. {aient-1.1.97 → aient-1.1.99}/aient/core/response.py +0 -0
  17. {aient-1.1.97 → aient-1.1.99}/aient/core/test/test_base_api.py +0 -0
  18. {aient-1.1.97 → aient-1.1.99}/aient/core/test/test_geminimask.py +0 -0
  19. {aient-1.1.97 → aient-1.1.99}/aient/core/test/test_image.py +0 -0
  20. {aient-1.1.97 → aient-1.1.99}/aient/core/test/test_payload.py +0 -0
  21. {aient-1.1.97 → aient-1.1.99}/aient/core/utils.py +0 -0
  22. {aient-1.1.97 → aient-1.1.99}/aient/models/__init__.py +0 -0
  23. {aient-1.1.97 → aient-1.1.99}/aient/models/audio.py +0 -0
  24. {aient-1.1.97 → aient-1.1.99}/aient/models/base.py +0 -0
  25. {aient-1.1.97 → aient-1.1.99}/aient/models/chatgpt.py +0 -0
  26. {aient-1.1.97 → aient-1.1.99}/aient/plugins/__init__.py +0 -0
  27. {aient-1.1.97 → aient-1.1.99}/aient/plugins/arXiv.py +0 -0
  28. {aient-1.1.97 → aient-1.1.99}/aient/plugins/config.py +0 -0
  29. {aient-1.1.97 → aient-1.1.99}/aient/plugins/excute_command.py +0 -0
  30. {aient-1.1.97 → aient-1.1.99}/aient/plugins/get_time.py +0 -0
  31. {aient-1.1.97 → aient-1.1.99}/aient/plugins/image.py +0 -0
  32. {aient-1.1.97 → aient-1.1.99}/aient/plugins/list_directory.py +0 -0
  33. {aient-1.1.97 → aient-1.1.99}/aient/plugins/read_file.py +0 -0
  34. {aient-1.1.97 → aient-1.1.99}/aient/plugins/read_image.py +0 -0
  35. {aient-1.1.97 → aient-1.1.99}/aient/plugins/readonly.py +0 -0
  36. {aient-1.1.97 → aient-1.1.99}/aient/plugins/registry.py +0 -0
  37. {aient-1.1.97 → aient-1.1.99}/aient/plugins/run_python.py +0 -0
  38. {aient-1.1.97 → aient-1.1.99}/aient/plugins/websearch.py +0 -0
  39. {aient-1.1.97 → aient-1.1.99}/aient/plugins/write_file.py +0 -0
  40. {aient-1.1.97 → aient-1.1.99}/aient/utils/__init__.py +0 -0
  41. {aient-1.1.97 → aient-1.1.99}/aient/utils/prompt.py +0 -0
  42. {aient-1.1.97 → aient-1.1.99}/aient/utils/scripts.py +0 -0
  43. {aient-1.1.97 → aient-1.1.99}/aient.egg-info/SOURCES.txt +0 -0
  44. {aient-1.1.97 → aient-1.1.99}/aient.egg-info/dependency_links.txt +0 -0
  45. {aient-1.1.97 → aient-1.1.99}/aient.egg-info/requires.txt +0 -0
  46. {aient-1.1.97 → aient-1.1.99}/aient.egg-info/top_level.txt +0 -0
  47. {aient-1.1.97 → aient-1.1.99}/setup.cfg +0 -0
  48. {aient-1.1.97 → aient-1.1.99}/test/test_Web_crawler.py +0 -0
  49. {aient-1.1.97 → aient-1.1.99}/test/test_ddg_search.py +0 -0
  50. {aient-1.1.97 → aient-1.1.99}/test/test_google_search.py +0 -0
  51. {aient-1.1.97 → aient-1.1.99}/test/test_ollama.py +0 -0
  52. {aient-1.1.97 → aient-1.1.99}/test/test_plugin.py +0 -0
  53. {aient-1.1.97 → aient-1.1.99}/test/test_search.py +0 -0
  54. {aient-1.1.97 → aient-1.1.99}/test/test_url.py +0 -0
  55. {aient-1.1.97 → aient-1.1.99}/test/test_whisper.py +0 -0
  56. {aient-1.1.97 → aient-1.1.99}/test/test_yjh.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.97
3
+ Version: 1.1.99
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -35,13 +35,30 @@ class ContentBlock:
35
35
  # 2. 上下文提供者 (带缓存)
36
36
  class ContextProvider(ABC):
37
37
  def __init__(self, name: str):
38
- self.name = name; self._cached_content: Optional[str] = None; self._is_stale: bool = True
38
+ self.name = name
39
+ self._cached_content: Optional[str] = None
40
+ self._is_stale: bool = True
41
+ self._visible: bool = True
39
42
 
40
43
  def __str__(self):
41
44
  # This allows the object to be captured when used inside an f-string.
42
45
  return _register_provider(self)
43
46
 
44
47
  def mark_stale(self): self._is_stale = True
48
+
49
+ @property
50
+ def visible(self) -> bool:
51
+ """Gets the visibility of the provider."""
52
+ return self._visible
53
+
54
+ @visible.setter
55
+ def visible(self, value: bool):
56
+ """Sets the visibility of the provider."""
57
+ if self._visible != value:
58
+ self._visible = value
59
+ # Content needs to be re-evaluated, but the source data hasn't changed,
60
+ # so just marking it stale is enough for the renderer to reconsider it.
61
+ self.mark_stale()
45
62
  async def refresh(self):
46
63
  if self._is_stale:
47
64
  self._cached_content = await self.render()
@@ -51,7 +68,8 @@ class ContextProvider(ABC):
51
68
  @abstractmethod
52
69
  def update(self, *args, **kwargs): raise NotImplementedError
53
70
  def get_content_block(self) -> Optional[ContentBlock]:
54
- if self._cached_content is not None: return ContentBlock(self.name, self._cached_content)
71
+ if self.visible and self._cached_content is not None:
72
+ return ContentBlock(self.name, self._cached_content)
55
73
  return None
56
74
 
57
75
  class Texts(ContextProvider):
@@ -84,7 +102,12 @@ class Texts(ContextProvider):
84
102
  self._is_dynamic = callable(self._text)
85
103
  self.mark_stale()
86
104
 
87
- async def render(self) -> Optional[str]:
105
+ @property
106
+ def content(self) -> Optional[str]:
107
+ """
108
+ Synchronously retrieves the raw text content as a property.
109
+ If the content is dynamic (a callable), it executes the callable.
110
+ """
88
111
  if self._is_dynamic:
89
112
  # Ensure dynamic content returns a string, even if empty
90
113
  result = self._text()
@@ -92,6 +115,9 @@ class Texts(ContextProvider):
92
115
  # Ensure static content returns a string, even if empty
93
116
  return self._text if self._text is not None else ""
94
117
 
118
+ async def render(self) -> Optional[str]:
119
+ return self.content
120
+
95
121
  class Tools(ContextProvider):
96
122
  def __init__(self, tools_json: Optional[List[Dict]] = None, name: str = "tools"):
97
123
  super().__init__(name)
@@ -998,6 +998,61 @@ Current time: {Texts(lambda: datetime.now().strftime("%Y-%m-%d %H:%M:%S"))}
998
998
  # 验证两次渲染的时间戳不同
999
999
  self.assertNotEqual(time1_str_part, time2_str_part, "f-string 中的动态 lambda 内容在两次渲染之间应该更新")
1000
1000
 
1001
+ def test_z6_direct_content_access(self):
1002
+ """测试通过 .content 属性直接访问 Texts 内容"""
1003
+ # 1. 测试静态内容
1004
+ static_text = Texts("Hello, Architext!")
1005
+ self.assertEqual(static_text.content, "Hello, Architext!")
1006
+
1007
+ # 2. 测试动态内容
1008
+ from datetime import datetime
1009
+ current_time_str = datetime.now().isoformat()
1010
+ dynamic_text = Texts(lambda: current_time_str)
1011
+ self.assertEqual(dynamic_text.content, current_time_str)
1012
+
1013
+ # 3. 测试更新后的内容访问
1014
+ static_text.update("Updated content.")
1015
+ self.assertEqual(static_text.content, "Updated content.")
1016
+
1017
+ # 4. 测试 None 和空字符串
1018
+ none_text = Texts(name="none_text") # Provide a name when text is None
1019
+ self.assertEqual(none_text.content, "")
1020
+
1021
+ empty_text = Texts("")
1022
+ self.assertEqual(empty_text.content, "")
1023
+
1024
+ async def test_z7_provider_visibility(self):
1025
+ """测试 provider 的可见性标志是否能正常工作"""
1026
+ # 1. 初始化 provider,visible 默认为 True
1027
+ text_provider = Texts("Hello, World!", name="greeting")
1028
+ self.assertTrue(text_provider.visible)
1029
+
1030
+ messages = Messages(SystemMessage(text_provider))
1031
+
1032
+ # 2. 初始渲染,内容应该可见
1033
+ rendered_visible = await messages.render_latest()
1034
+ self.assertEqual(len(rendered_visible), 1)
1035
+ self.assertEqual(rendered_visible[0]['content'], "Hello, World!")
1036
+
1037
+ # 3. 设置为不可见
1038
+ provider = messages.provider("greeting")
1039
+ provider.visible = False
1040
+ self.assertFalse(provider.visible)
1041
+
1042
+ # 4. 再次渲染,内容应该消失
1043
+ # 因为 visibility 变化会 mark_stale,所以需要 render_latest
1044
+ rendered_invisible = await messages.render_latest()
1045
+ self.assertEqual(len(rendered_invisible), 0, "设置为不可见后,消息应该不被渲染")
1046
+
1047
+ # 5. 再次设置为可见
1048
+ provider.visible = True
1049
+ self.assertTrue(provider.visible)
1050
+
1051
+ # 6. 渲染,内容应该再次出现
1052
+ rendered_visible_again = await messages.render_latest()
1053
+ self.assertEqual(len(rendered_visible_again), 1)
1054
+ self.assertEqual(rendered_visible_again[0]['content'], "Hello, World!")
1055
+
1001
1056
 
1002
1057
  # ==============================================================================
1003
1058
  # 6. 演示
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.97
3
+ Version: 1.1.99
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.1.97"
3
+ version = "1.1.99"
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
File without changes