beswarm 0.3.2__py3-none-any.whl → 0.3.3__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.
- beswarm/aient/aient/architext/architext/core.py +12 -0
- beswarm/aient/aient/architext/test/test.py +20 -0
- beswarm/aient/aient/models/chatgpt.py +8 -4
- {beswarm-0.3.2.dist-info → beswarm-0.3.3.dist-info}/METADATA +1 -1
- {beswarm-0.3.2.dist-info → beswarm-0.3.3.dist-info}/RECORD +8 -8
- {beswarm-0.3.2.dist-info → beswarm-0.3.3.dist-info}/WHEEL +0 -0
- {beswarm-0.3.2.dist-info → beswarm-0.3.3.dist-info}/entry_points.txt +0 -0
- {beswarm-0.3.2.dist-info → beswarm-0.3.3.dist-info}/top_level.txt +0 -0
@@ -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. 演示
|
@@ -125,8 +125,12 @@ class chatgpt(BaseLLM):
|
|
125
125
|
else:
|
126
126
|
# 如果没有提供 logger,创建一个默认的,它只会打印到控制台
|
127
127
|
self.logger = logging.getLogger("chatgpt_default")
|
128
|
+
self.logger.propagate = False
|
128
129
|
if not self.logger.handlers: # 防止重复添加 handler
|
129
|
-
|
130
|
+
handler = logging.StreamHandler()
|
131
|
+
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
132
|
+
handler.setFormatter(formatter)
|
133
|
+
self.logger.addHandler(handler)
|
130
134
|
self.logger.setLevel(logging.INFO if print_log else logging.WARNING)
|
131
135
|
|
132
136
|
# 注册和处理传入的工具
|
@@ -282,7 +286,7 @@ class chatgpt(BaseLLM):
|
|
282
286
|
"messages": await self.conversation[convo_id].render_latest() if pass_history else Messages(
|
283
287
|
SystemMessage(self.system_prompt, self.conversation[convo_id].provider("files")),
|
284
288
|
UserMessage(prompt)
|
285
|
-
),
|
289
|
+
).render(),
|
286
290
|
"stream": stream,
|
287
291
|
"temperature": kwargs.get("temperature", self.temperature)
|
288
292
|
}
|
@@ -688,7 +692,7 @@ class chatgpt(BaseLLM):
|
|
688
692
|
# 准备会话
|
689
693
|
self.system_prompt = system_prompt or self.system_prompt
|
690
694
|
if convo_id not in self.conversation or pass_history <= 2:
|
691
|
-
self.reset(convo_id=convo_id, system_prompt=system_prompt)
|
695
|
+
self.reset(convo_id=convo_id, system_prompt=self.system_prompt)
|
692
696
|
self.add_to_conversation(prompt, role, convo_id=convo_id, function_name=function_name, total_tokens=total_tokens, function_arguments=function_arguments, pass_history=pass_history, function_call_id=function_call_id)
|
693
697
|
|
694
698
|
# 获取请求体
|
@@ -945,7 +949,7 @@ class chatgpt(BaseLLM):
|
|
945
949
|
"""
|
946
950
|
self.system_prompt = system_prompt or self.system_prompt
|
947
951
|
self.conversation[convo_id] = Messages(
|
948
|
-
SystemMessage(
|
952
|
+
SystemMessage(self.system_prompt, self.conversation[convo_id].provider("files")),
|
949
953
|
)
|
950
954
|
self.tokens_usage[convo_id] = 0
|
951
955
|
self.current_tokens[convo_id] = 0
|
@@ -10,9 +10,9 @@ beswarm/agents/chatgroup.py,sha256=PzrmRcDKAbB7cxL16nMod_CzPosDV6bfTmXxQVuv-AQ,1
|
|
10
10
|
beswarm/agents/planact.py,sha256=wYIyrAsBY6Z_Hc8rx76vbfUTsagqYFIBOfPi43ze708,18361
|
11
11
|
beswarm/aient/aient/__init__.py,sha256=SRfF7oDVlOOAi6nGKiJIUK6B_arqYLO9iSMp-2IZZps,21
|
12
12
|
beswarm/aient/aient/architext/architext/__init__.py,sha256=79Ih1151rfcqZdr7F8HSZSTs_iT2SKd1xCkehMsXeXs,19
|
13
|
-
beswarm/aient/aient/architext/architext/core.py,sha256=
|
13
|
+
beswarm/aient/aient/architext/architext/core.py,sha256=XKMYDLdaTP6OWmNZLEF-b24KVDkMeM-xyVptmpXoBsU,33112
|
14
14
|
beswarm/aient/aient/architext/test/openai_client.py,sha256=Dqtbmubv6vwF8uBqcayG0kbsiO65of7sgU2-DRBi-UM,4590
|
15
|
-
beswarm/aient/aient/architext/test/test.py,sha256=
|
15
|
+
beswarm/aient/aient/architext/test/test.py,sha256=jxmEfZaeJWh3dq0f67TBTPMgT0FMK7eiTs9XcyAtFFg,73944
|
16
16
|
beswarm/aient/aient/architext/test/test_save_load.py,sha256=o8DqH6gDYZkFkQy-a7blqLtJTRj5e4a-Lil48pJ0V3g,3260
|
17
17
|
beswarm/aient/aient/core/__init__.py,sha256=NxjebTlku35S4Dzr16rdSqSTWUvvwEeACe8KvHJnjPg,34
|
18
18
|
beswarm/aient/aient/core/log_config.py,sha256=kz2_yJv1p-o3lUQOwA3qh-LSc3wMHv13iCQclw44W9c,274
|
@@ -27,7 +27,7 @@ beswarm/aient/aient/core/test/test_payload.py,sha256=8jBiJY1uidm1jzL-EiK0s6UGmW9
|
|
27
27
|
beswarm/aient/aient/models/__init__.py,sha256=ZTiZgbfBPTjIPSKURE7t6hlFBVLRS9lluGbmqc1WjxQ,43
|
28
28
|
beswarm/aient/aient/models/audio.py,sha256=FNW4lxG1IhxOU7L8mvcbaeC1nXk_lpUZQlg9ijQ0h_Q,1937
|
29
29
|
beswarm/aient/aient/models/base.py,sha256=HWIGfa2A7OTccvHK0wG1-UlHB-yaWRC7hbi4oR1Mu1Y,7228
|
30
|
-
beswarm/aient/aient/models/chatgpt.py,sha256=
|
30
|
+
beswarm/aient/aient/models/chatgpt.py,sha256=cRz_6ocQbEoXREAlr9HteddfIRicE0c8lV_fnWhTXcA,43574
|
31
31
|
beswarm/aient/aient/plugins/__init__.py,sha256=p3KO6Aa3Lupos4i2SjzLQw1hzQTigOAfEHngsldrsyk,986
|
32
32
|
beswarm/aient/aient/plugins/arXiv.py,sha256=yHjb6PS3GUWazpOYRMKMzghKJlxnZ5TX8z9F6UtUVow,1461
|
33
33
|
beswarm/aient/aient/plugins/config.py,sha256=TGgZ5SnNKZ8MmdznrZ-TEq7s2ulhAAwTSKH89bci3dA,7079
|
@@ -121,8 +121,8 @@ beswarm/tools/search_web.py,sha256=0fTeczXiOX_LJQGaLEGbuJtIPzofeuquGWEt3yDMtVw,1
|
|
121
121
|
beswarm/tools/subtasks.py,sha256=NHDnmUhUPgDQKBACnpgErpFJRcsH0w_Q9VsyQjNvNHA,12658
|
122
122
|
beswarm/tools/worker.py,sha256=mQ1qdrQ8MgL99byAbTvxfEByFFGN9mty3UHqHjARMQ8,2331
|
123
123
|
beswarm/tools/write_csv.py,sha256=u0Hq18Ksfheb52MVtyLNCnSDHibITpsYBPs2ub7USYA,1466
|
124
|
-
beswarm-0.3.
|
125
|
-
beswarm-0.3.
|
126
|
-
beswarm-0.3.
|
127
|
-
beswarm-0.3.
|
128
|
-
beswarm-0.3.
|
124
|
+
beswarm-0.3.3.dist-info/METADATA,sha256=hOAbWEDzDcl3ihVRJam3X0Tkbt91fsK-Nitu3JPceKA,3877
|
125
|
+
beswarm-0.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
126
|
+
beswarm-0.3.3.dist-info/entry_points.txt,sha256=URK7Y4PDzBgxIecQnxsWTu4O-eaFa1CoAcNTWh5R7LM,45
|
127
|
+
beswarm-0.3.3.dist-info/top_level.txt,sha256=pJw4O87wvt5882smuSO6DfByJz7FJ8SxxT8h9fHCmpo,8
|
128
|
+
beswarm-0.3.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|