aient 1.1.92__tar.gz → 1.1.94__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.92 → aient-1.1.94}/PKG-INFO +1 -1
  2. {aient-1.1.92 → aient-1.1.94}/aient/architext/architext/core.py +25 -6
  3. {aient-1.1.92 → aient-1.1.94}/aient/architext/test/test.py +80 -0
  4. {aient-1.1.92 → aient-1.1.94}/aient.egg-info/PKG-INFO +1 -1
  5. {aient-1.1.92 → aient-1.1.94}/pyproject.toml +1 -1
  6. {aient-1.1.92 → aient-1.1.94}/LICENSE +0 -0
  7. {aient-1.1.92 → aient-1.1.94}/README.md +0 -0
  8. {aient-1.1.92 → aient-1.1.94}/aient/__init__.py +0 -0
  9. {aient-1.1.92 → aient-1.1.94}/aient/architext/architext/__init__.py +0 -0
  10. {aient-1.1.92 → aient-1.1.94}/aient/architext/test/openai_client.py +0 -0
  11. {aient-1.1.92 → aient-1.1.94}/aient/architext/test/test_save_load.py +0 -0
  12. {aient-1.1.92 → aient-1.1.94}/aient/core/__init__.py +0 -0
  13. {aient-1.1.92 → aient-1.1.94}/aient/core/log_config.py +0 -0
  14. {aient-1.1.92 → aient-1.1.94}/aient/core/models.py +0 -0
  15. {aient-1.1.92 → aient-1.1.94}/aient/core/request.py +0 -0
  16. {aient-1.1.92 → aient-1.1.94}/aient/core/response.py +0 -0
  17. {aient-1.1.92 → aient-1.1.94}/aient/core/test/test_base_api.py +0 -0
  18. {aient-1.1.92 → aient-1.1.94}/aient/core/test/test_geminimask.py +0 -0
  19. {aient-1.1.92 → aient-1.1.94}/aient/core/test/test_image.py +0 -0
  20. {aient-1.1.92 → aient-1.1.94}/aient/core/test/test_payload.py +0 -0
  21. {aient-1.1.92 → aient-1.1.94}/aient/core/utils.py +0 -0
  22. {aient-1.1.92 → aient-1.1.94}/aient/models/__init__.py +0 -0
  23. {aient-1.1.92 → aient-1.1.94}/aient/models/audio.py +0 -0
  24. {aient-1.1.92 → aient-1.1.94}/aient/models/base.py +0 -0
  25. {aient-1.1.92 → aient-1.1.94}/aient/models/chatgpt.py +0 -0
  26. {aient-1.1.92 → aient-1.1.94}/aient/plugins/__init__.py +0 -0
  27. {aient-1.1.92 → aient-1.1.94}/aient/plugins/arXiv.py +0 -0
  28. {aient-1.1.92 → aient-1.1.94}/aient/plugins/config.py +0 -0
  29. {aient-1.1.92 → aient-1.1.94}/aient/plugins/excute_command.py +0 -0
  30. {aient-1.1.92 → aient-1.1.94}/aient/plugins/get_time.py +0 -0
  31. {aient-1.1.92 → aient-1.1.94}/aient/plugins/image.py +0 -0
  32. {aient-1.1.92 → aient-1.1.94}/aient/plugins/list_directory.py +0 -0
  33. {aient-1.1.92 → aient-1.1.94}/aient/plugins/read_file.py +0 -0
  34. {aient-1.1.92 → aient-1.1.94}/aient/plugins/read_image.py +0 -0
  35. {aient-1.1.92 → aient-1.1.94}/aient/plugins/readonly.py +0 -0
  36. {aient-1.1.92 → aient-1.1.94}/aient/plugins/registry.py +0 -0
  37. {aient-1.1.92 → aient-1.1.94}/aient/plugins/run_python.py +0 -0
  38. {aient-1.1.92 → aient-1.1.94}/aient/plugins/websearch.py +0 -0
  39. {aient-1.1.92 → aient-1.1.94}/aient/plugins/write_file.py +0 -0
  40. {aient-1.1.92 → aient-1.1.94}/aient/utils/__init__.py +0 -0
  41. {aient-1.1.92 → aient-1.1.94}/aient/utils/prompt.py +0 -0
  42. {aient-1.1.92 → aient-1.1.94}/aient/utils/scripts.py +0 -0
  43. {aient-1.1.92 → aient-1.1.94}/aient.egg-info/SOURCES.txt +0 -0
  44. {aient-1.1.92 → aient-1.1.94}/aient.egg-info/dependency_links.txt +0 -0
  45. {aient-1.1.92 → aient-1.1.94}/aient.egg-info/requires.txt +0 -0
  46. {aient-1.1.92 → aient-1.1.94}/aient.egg-info/top_level.txt +0 -0
  47. {aient-1.1.92 → aient-1.1.94}/setup.cfg +0 -0
  48. {aient-1.1.92 → aient-1.1.94}/test/test_Web_crawler.py +0 -0
  49. {aient-1.1.92 → aient-1.1.94}/test/test_ddg_search.py +0 -0
  50. {aient-1.1.92 → aient-1.1.94}/test/test_google_search.py +0 -0
  51. {aient-1.1.92 → aient-1.1.94}/test/test_ollama.py +0 -0
  52. {aient-1.1.92 → aient-1.1.94}/test/test_plugin.py +0 -0
  53. {aient-1.1.92 → aient-1.1.94}/test/test_search.py +0 -0
  54. {aient-1.1.92 → aient-1.1.94}/test/test_url.py +0 -0
  55. {aient-1.1.92 → aient-1.1.94}/test/test_whisper.py +0 -0
  56. {aient-1.1.92 → aient-1.1.94}/test/test_yjh.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.92
3
+ Version: 1.1.94
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -6,7 +6,7 @@ import hashlib
6
6
  import mimetypes
7
7
  from dataclasses import dataclass
8
8
  from abc import ABC, abstractmethod
9
- from typing import List, Dict, Any, Optional, Union
9
+ from typing import List, Dict, Any, Optional, Union, Callable
10
10
 
11
11
  # 1. 核心数据结构: ContentBlock
12
12
  @dataclass
@@ -32,20 +32,39 @@ class ContextProvider(ABC):
32
32
  return None
33
33
 
34
34
  class Texts(ContextProvider):
35
- def __init__(self, text: str, name: Optional[str] = None):
35
+ def __init__(self, text: Optional[Union[str, Callable[[], str]]] = None, name: Optional[str] = None):
36
+ if text is None and name is None:
37
+ raise ValueError("Either 'text' or 'name' must be provided.")
38
+
36
39
  self._text = text
40
+ self._is_dynamic = callable(self._text)
41
+
37
42
  if name is None:
38
- h = hashlib.sha1(self._text.encode()).hexdigest()
39
- _name = f"text_{h[:8]}"
43
+ if self._is_dynamic:
44
+ import uuid
45
+ _name = f"dynamic_text_{uuid.uuid4().hex[:8]}"
46
+ else:
47
+ # Handle the case where text is None during initialization
48
+ h = hashlib.sha1(self._text.encode() if self._text else b'').hexdigest()
49
+ _name = f"text_{h[:8]}"
40
50
  else:
41
51
  _name = name
42
52
  super().__init__(_name)
43
53
 
44
- def update(self, text: str):
54
+ async def refresh(self):
55
+ if self._is_dynamic:
56
+ self._is_stale = True
57
+ await super().refresh()
58
+
59
+ def update(self, text: Union[str, Callable[[], str]]):
45
60
  self._text = text
61
+ self._is_dynamic = callable(self._text)
46
62
  self.mark_stale()
47
63
 
48
- async def render(self) -> str: return self._text
64
+ async def render(self) -> Optional[str]:
65
+ if self._is_dynamic:
66
+ return self._text()
67
+ return self._text
49
68
 
50
69
  class Tools(ContextProvider):
51
70
  def __init__(self, tools_json: List[Dict]): super().__init__("tools"); self._tools_json = tools_json
@@ -819,6 +819,86 @@ class TestContextManagement(unittest.IsolatedAsyncioTestCase):
819
819
  if os.path.exists(test_file):
820
820
  os.remove(test_file)
821
821
 
822
+ async def test_z_dynamic_texts_provider(self):
823
+ """测试 Texts provider 是否支持可调用对象以实现动态内容"""
824
+ import time
825
+ from datetime import datetime
826
+
827
+ # 1. 使用 lambda 函数创建一个动态的 Texts provider
828
+ # 每次调用 render 时,它都应该返回当前时间
829
+ dynamic_text_provider = Texts(lambda: datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
830
+ messages = Messages(UserMessage(dynamic_text_provider))
831
+
832
+ # 2. 第一次渲染
833
+ rendered1 = await messages.render_latest()
834
+ time1_str = rendered1[0]['content']
835
+ self.assertIsNotNone(time1_str)
836
+
837
+ # 3. 等待一秒钟
838
+ time.sleep(1)
839
+
840
+ # 4. 第二次渲染,并期望内容已更新
841
+ rendered2 = await messages.render_latest()
842
+ time2_str = rendered2[0]['content']
843
+ self.assertIsNotNone(time2_str)
844
+
845
+ # 5. 验证两次渲染的时间戳不同
846
+ self.assertNotEqual(time1_str, time2_str, "动态 Texts provider 的内容在两次渲染之间应该更新")
847
+
848
+ async def test_z2_dynamic_texts_with_prefix(self):
849
+ """测试动态 Texts provider 包含静态前缀时也能正确更新"""
850
+ import time
851
+ from datetime import datetime
852
+ import platform
853
+
854
+ # 1. 创建一个包含静态前缀和动态内容的 provider
855
+ # 正确的用法是将整个表达式放入 lambda
856
+ dynamic_provider = Texts(lambda: f"平台信息:{platform.platform()}, 时间:{datetime.now().isoformat()}")
857
+ messages = Messages(UserMessage(dynamic_provider))
858
+
859
+ # 2. 第一次渲染
860
+ rendered1 = await messages.render_latest()
861
+ content1 = rendered1[0]['content']
862
+ self.assertIn("平台信息:", content1)
863
+
864
+ # 3. 等待一秒
865
+ time.sleep(1)
866
+
867
+ # 4. 第二次渲染
868
+ rendered2 = await messages.render_latest()
869
+ content2 = rendered2[0]['content']
870
+ self.assertIn("平台信息:", content2)
871
+
872
+ # 5. 验证两次内容不同(因为时间戳变了)
873
+ self.assertNotEqual(content1, content2, "包含静态前缀的动态 provider 内容应该更新")
874
+
875
+ async def test_z3_deferred_text_update_via_provider(self):
876
+ """测试 Texts(name=...) 初始化, 然后通过 provider 更新内容"""
877
+ # This test is expected to fail with a TypeError on the next line
878
+ # because the current Texts.__init__ requires 'text'.
879
+ deferred_text_provider = Texts(name="deferred_content")
880
+
881
+ messages = Messages(UserMessage(deferred_text_provider))
882
+
883
+ # Initial render: with no text, it should probably render to an empty string.
884
+ # If there's no content, the message itself might not be rendered.
885
+ # Let's assume an empty provider results in the message not rendering.
886
+ await deferred_text_provider.refresh()
887
+ self.assertIsNone(deferred_text_provider.get_content_block())
888
+
889
+ rendered_initial = await messages.render_latest()
890
+ self.assertEqual(len(rendered_initial), 0)
891
+
892
+ # 3. Get provider and update content
893
+ provider = messages.provider("deferred_content")
894
+ self.assertIsNotNone(provider)
895
+ provider.update("This is the new content.")
896
+
897
+ # 4. Re-render and validate
898
+ rendered_updated = await messages.render_latest()
899
+ self.assertEqual(len(rendered_updated), 1)
900
+ self.assertEqual(rendered_updated[0]['content'], "This is the new content.")
901
+
822
902
 
823
903
  # ==============================================================================
824
904
  # 6. 演示
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.92
3
+ Version: 1.1.94
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.92"
3
+ version = "1.1.94"
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