aient 1.2.5__py3-none-any.whl → 1.2.6__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.
- aient/architext/architext/core.py +11 -1
- aient/architext/test/test.py +24 -0
- {aient-1.2.5.dist-info → aient-1.2.6.dist-info}/METADATA +1 -1
- {aient-1.2.5.dist-info → aient-1.2.6.dist-info}/RECORD +7 -7
- {aient-1.2.5.dist-info → aient-1.2.6.dist-info}/WHEEL +0 -0
- {aient-1.2.5.dist-info → aient-1.2.6.dist-info}/licenses/LICENSE +0 -0
- {aient-1.2.5.dist-info → aient-1.2.6.dist-info}/top_level.txt +0 -0
@@ -360,7 +360,17 @@ class Message(ABC):
|
|
360
360
|
if self._parent_messages:
|
361
361
|
self._parent_messages._notify_provider_added(item, self)
|
362
362
|
|
363
|
-
def provider(self) -> List[ContextProvider]:
|
363
|
+
def provider(self, name: Optional[str] = None) -> Optional[Union[ContextProvider, ProviderGroup, List[ContextProvider]]]:
|
364
|
+
if name is None:
|
365
|
+
return self._items
|
366
|
+
|
367
|
+
named_providers = [p for p in self._items if hasattr(p, 'name') and p.name == name]
|
368
|
+
|
369
|
+
if not named_providers:
|
370
|
+
return None
|
371
|
+
if len(named_providers) == 1:
|
372
|
+
return named_providers[0]
|
373
|
+
return ProviderGroup(named_providers)
|
364
374
|
|
365
375
|
def __add__(self, other):
|
366
376
|
if isinstance(other, str):
|
aient/architext/test/test.py
CHANGED
@@ -1158,6 +1158,30 @@ Current time: {Texts(lambda: datetime.now().strftime("%Y-%m-%d %H:%M:%S"))}
|
|
1158
1158
|
with self.assertRaises(IndexError):
|
1159
1159
|
_ = mess[2]
|
1160
1160
|
|
1161
|
+
async def test_zb_message_provider_by_name(self):
|
1162
|
+
"""测试是否可以通过名称从 Message 对象中获取 provider"""
|
1163
|
+
# 1. 创建一个包含命名 provider 的 Message
|
1164
|
+
message = UserMessage(
|
1165
|
+
Texts("Some instruction", name="instruction"),
|
1166
|
+
Tools([{"name": "a_tool"}], name="tools"),
|
1167
|
+
Texts("Another instruction", name="instruction")
|
1168
|
+
)
|
1169
|
+
|
1170
|
+
# 2. 测试获取单个 provider
|
1171
|
+
tools_provider = message.provider("tools")
|
1172
|
+
self.assertIsInstance(tools_provider, Tools)
|
1173
|
+
self.assertEqual(tools_provider.name, "tools")
|
1174
|
+
|
1175
|
+
# 3. 测试获取多个同名 provider
|
1176
|
+
instruction_providers = message.provider("instruction")
|
1177
|
+
self.assertIsInstance(instruction_providers, ProviderGroup)
|
1178
|
+
self.assertEqual(len(instruction_providers), 2)
|
1179
|
+
self.assertTrue(all(isinstance(p, Texts) for p in instruction_providers))
|
1180
|
+
|
1181
|
+
# 4. 测试获取不存在的 provider
|
1182
|
+
non_existent_provider = message.provider("non_existent")
|
1183
|
+
self.assertIsNone(non_existent_provider)
|
1184
|
+
|
1161
1185
|
# ==============================================================================
|
1162
1186
|
# 6. 演示
|
1163
1187
|
# ==============================================================================
|
@@ -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=
|
3
|
+
aient/architext/architext/core.py,sha256=A1ZeZSJwcdl-svYA12uD2qSlU-wfNTVWvpSg8AF8_Gk,26015
|
4
4
|
aient/architext/test/openai_client.py,sha256=Dqtbmubv6vwF8uBqcayG0kbsiO65of7sgU2-DRBi-UM,4590
|
5
|
-
aient/architext/test/test.py,sha256=
|
5
|
+
aient/architext/test/test.py,sha256=trVHo2we0W8RN-0QNvP3sJ3yUpe08-34Ae_ZVNZJHdE,56378
|
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
|
@@ -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=UcSzKkFE4-h_1b6NofI6xgk3GoleqALRKY8VBaXLjmI,11311
|
37
37
|
aient/utils/scripts.py,sha256=VqtK4RFEx7KxkmcqG3lFDS1DxoNlFFGErEjopVcc8IE,40974
|
38
|
-
aient-1.2.
|
39
|
-
aient-1.2.
|
40
|
-
aient-1.2.
|
41
|
-
aient-1.2.
|
42
|
-
aient-1.2.
|
38
|
+
aient-1.2.6.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
|
39
|
+
aient-1.2.6.dist-info/METADATA,sha256=aKQPqRvoFl1kd5GXFxOziGdeRhNAZDL8ksFspWdljoo,4841
|
40
|
+
aient-1.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
41
|
+
aient-1.2.6.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
|
42
|
+
aient-1.2.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|