aient 1.2.33__py3-none-any.whl → 1.2.35__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.
@@ -128,6 +128,11 @@ class Texts(ContextProvider):
128
128
  else:
129
129
  _name = name
130
130
  super().__init__(_name, visible=visible)
131
+ if not self._is_dynamic:
132
+ self._cached_content = self.content
133
+ # The content is cached, but it's still "stale" from the perspective
134
+ # of the async refresh cycle. Let the first refresh formalize it.
135
+ self._is_stale = True
131
136
 
132
137
  async def refresh(self):
133
138
  if self._is_dynamic:
@@ -191,6 +196,10 @@ class Tools(ContextProvider):
191
196
  def __init__(self, tools_json: Optional[List[Dict]] = None, name: str = "tools", visible: bool = True):
192
197
  super().__init__(name, visible=visible)
193
198
  self._tools_json = tools_json or []
199
+ # Pre-render and cache the content, but leave it stale for the first refresh
200
+ if self._tools_json:
201
+ self._cached_content = f"<tools>{str(self._tools_json)}</tools>"
202
+ self._is_stale = True
194
203
  def update(self, tools_json: List[Dict]):
195
204
  self._tools_json = tools_json
196
205
  self.mark_stale()
@@ -289,6 +298,9 @@ class Images(ContextProvider):
289
298
  def __init__(self, url: str, name: Optional[str] = None, visible: bool = True):
290
299
  super().__init__(name or url, visible=visible)
291
300
  self.url = url
301
+ if self.url.startswith("data:"):
302
+ self._cached_content = self.url
303
+ self._is_stale = True
292
304
  def update(self, url: str):
293
305
  self.url = url
294
306
  self.mark_stale()
@@ -1578,6 +1578,26 @@ Files: {Files(visible=True, name="files")}
1578
1578
  rendered_single = await message_single.render_latest()
1579
1579
  self.assertEqual(rendered_single['content'], "Only one.")
1580
1580
 
1581
+ async def test_zad_simple_render_without_refresh(self):
1582
+ """测试 Messages(UserMessage('hi')).render() 是否能直接同步渲染"""
1583
+ # This test checks if a simple message can be rendered synchronously
1584
+ # without an explicit `await refresh()` or `await render_latest()`.
1585
+ # Calling the synchronous render method directly on a new instance
1586
+ rendered = Messages(UserMessage("hi", Images(url="data:image/png;base64,FAKE"))).render()
1587
+
1588
+ # The current implementation will likely fail here, returning []
1589
+ self.assertEqual(len(rendered), 1)
1590
+ self.assertEqual(rendered[0]['role'], 'user')
1591
+
1592
+ # Now we expect a list for multimodal content
1593
+ content = rendered[0]['content']
1594
+ self.assertIsInstance(content, list)
1595
+ self.assertEqual(len(content), 2)
1596
+ self.assertEqual(content[0]['type'], 'text')
1597
+ self.assertEqual(content[0]['text'], 'hi')
1598
+ self.assertEqual(content[1]['type'], 'image_url')
1599
+ self.assertEqual(content[1]['image_url']['url'], "data:image/png;base64,FAKE")
1600
+
1581
1601
 
1582
1602
  # ==============================================================================
1583
1603
  # 6. 演示
aient/models/chatgpt.py CHANGED
@@ -286,7 +286,7 @@ class chatgpt(BaseLLM):
286
286
  "messages": await self.conversation[convo_id].render_latest() if pass_history else Messages(
287
287
  SystemMessage(self.system_prompt, self.conversation[convo_id].provider("files")),
288
288
  UserMessage(prompt)
289
- ),
289
+ ).render(),
290
290
  "stream": stream,
291
291
  "temperature": kwargs.get("temperature", self.temperature)
292
292
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.2.33
3
+ Version: 1.2.35
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -1,8 +1,8 @@
1
1
  aient/__init__.py,sha256=SRfF7oDVlOOAi6nGKiJIUK6B_arqYLO9iSMp-2IZZps,21
2
2
  aient/architext/architext/__init__.py,sha256=79Ih1151rfcqZdr7F8HSZSTs_iT2SKd1xCkehMsXeXs,19
3
- aient/architext/architext/core.py,sha256=KHzc6ly4vNYie2kRfPokDGhfTz3CvntuiSd-XyE3cAM,32502
3
+ aient/architext/architext/core.py,sha256=XKMYDLdaTP6OWmNZLEF-b24KVDkMeM-xyVptmpXoBsU,33112
4
4
  aient/architext/test/openai_client.py,sha256=Dqtbmubv6vwF8uBqcayG0kbsiO65of7sgU2-DRBi-UM,4590
5
- aient/architext/test/test.py,sha256=9OQ12qAs81Ce6KCKXQx4Re0P9VjNuTF4rZRcTRstJVw,72868
5
+ aient/architext/test/test.py,sha256=jxmEfZaeJWh3dq0f67TBTPMgT0FMK7eiTs9XcyAtFFg,73944
6
6
  aient/architext/test/test_save_load.py,sha256=o8DqH6gDYZkFkQy-a7blqLtJTRj5e4a-Lil48pJ0V3g,3260
7
7
  aient/core/__init__.py,sha256=NxjebTlku35S4Dzr16rdSqSTWUvvwEeACe8KvHJnjPg,34
8
8
  aient/core/log_config.py,sha256=kz2_yJv1p-o3lUQOwA3qh-LSc3wMHv13iCQclw44W9c,274
@@ -17,7 +17,7 @@ aient/core/test/test_payload.py,sha256=8jBiJY1uidm1jzL-EiK0s6UGmW9XkdsuuKFGrwFhF
17
17
  aient/models/__init__.py,sha256=ZTiZgbfBPTjIPSKURE7t6hlFBVLRS9lluGbmqc1WjxQ,43
18
18
  aient/models/audio.py,sha256=FNW4lxG1IhxOU7L8mvcbaeC1nXk_lpUZQlg9ijQ0h_Q,1937
19
19
  aient/models/base.py,sha256=HWIGfa2A7OTccvHK0wG1-UlHB-yaWRC7hbi4oR1Mu1Y,7228
20
- aient/models/chatgpt.py,sha256=eeZ-hK0U50MyXnan-pRXADvMnydgNtKOCQdSqKfHC6M,43565
20
+ aient/models/chatgpt.py,sha256=cRz_6ocQbEoXREAlr9HteddfIRicE0c8lV_fnWhTXcA,43574
21
21
  aient/plugins/__init__.py,sha256=p3KO6Aa3Lupos4i2SjzLQw1hzQTigOAfEHngsldrsyk,986
22
22
  aient/plugins/arXiv.py,sha256=yHjb6PS3GUWazpOYRMKMzghKJlxnZ5TX8z9F6UtUVow,1461
23
23
  aient/plugins/config.py,sha256=TGgZ5SnNKZ8MmdznrZ-TEq7s2ulhAAwTSKH89bci3dA,7079
@@ -35,8 +35,8 @@ aient/plugins/write_file.py,sha256=Jt8fOEwqhYiSWpCbwfAr1xoi_BmFnx3076GMhuL06uI,3
35
35
  aient/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
36
  aient/utils/prompt.py,sha256=ZvGAt_ImJ_CGbDnWgpsWskfSV5fCkpFKRpNQjYL7M7s,11100
37
37
  aient/utils/scripts.py,sha256=Q0tS7E9AmdikO7GeDBd_3Ii5opXHCvKjDGqHsXen6_A,40622
38
- aient-1.2.33.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
39
- aient-1.2.33.dist-info/METADATA,sha256=Sq5S-JuLRFvQ_Qv69V24o7hAokFm4nldoMXx8WeuOcA,4842
40
- aient-1.2.33.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
41
- aient-1.2.33.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
42
- aient-1.2.33.dist-info/RECORD,,
38
+ aient-1.2.35.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
39
+ aient-1.2.35.dist-info/METADATA,sha256=Gi2MON1pLGbUcWLcKsE9bdI_3yKomVlbvoOAdWVgDCI,4842
40
+ aient-1.2.35.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
41
+ aient-1.2.35.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
42
+ aient-1.2.35.dist-info/RECORD,,
File without changes