beswarm 0.2.96__py3-none-any.whl → 0.2.98__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/agents/planact.py +2 -0
- beswarm/aient/aient/architext/architext/core.py +19 -0
- beswarm/aient/aient/architext/test/test.py +25 -0
- beswarm/aient/aient/models/chatgpt.py +3 -1
- {beswarm-0.2.96.dist-info → beswarm-0.2.98.dist-info}/METADATA +1 -1
- {beswarm-0.2.96.dist-info → beswarm-0.2.98.dist-info}/RECORD +8 -8
- {beswarm-0.2.96.dist-info → beswarm-0.2.98.dist-info}/WHEEL +0 -0
- {beswarm-0.2.96.dist-info → beswarm-0.2.98.dist-info}/top_level.txt +0 -0
beswarm/agents/planact.py
CHANGED
@@ -201,6 +201,8 @@ class WorkerAgent(BaseAgent):
|
|
201
201
|
self.broker.publish(message, self.error_topic)
|
202
202
|
else:
|
203
203
|
self.broker.publish({"status": "new_message", "result": "\n✅ 工作智能体:\n" + response}, self.status_topic)
|
204
|
+
if len(self.agent.conversation["default"]) > 1 and self.agent.conversation["default"][-1].role == "user":
|
205
|
+
self.agent.conversation["default"].pop(-1)
|
204
206
|
self.broker.publish({
|
205
207
|
"conversation": self.agent.conversation["default"]
|
206
208
|
}, self.publish_topic)
|
@@ -457,6 +457,15 @@ class Message(ABC):
|
|
457
457
|
return len(self._items)
|
458
458
|
|
459
459
|
def __repr__(self): return f"Message(role='{self.role}', items={[i.name for i in self._items]})"
|
460
|
+
|
461
|
+
def __contains__(self, item: Any) -> bool:
|
462
|
+
"""Checks if a ContextProvider is in the message."""
|
463
|
+
if not isinstance(item, ContextProvider):
|
464
|
+
return False
|
465
|
+
# The `in` operator on a list checks for equality,
|
466
|
+
# and our custom __eq__ on ContextProvider handles the comparison logic.
|
467
|
+
return item in self._items
|
468
|
+
|
460
469
|
def __bool__(self) -> bool:
|
461
470
|
return bool(self._items)
|
462
471
|
def get(self, key: str, default: Any = None) -> Any:
|
@@ -717,3 +726,13 @@ class Messages:
|
|
717
726
|
|
718
727
|
def __len__(self) -> int: return len(self._messages)
|
719
728
|
def __iter__(self): return iter(self._messages)
|
729
|
+
|
730
|
+
def __contains__(self, item: Any) -> bool:
|
731
|
+
"""Checks if a Message or ContextProvider is in the collection."""
|
732
|
+
if isinstance(item, Message):
|
733
|
+
# Check for object identity
|
734
|
+
return any(item is msg for msg in self._messages)
|
735
|
+
if isinstance(item, ContextProvider):
|
736
|
+
# Check if any message contains the provider
|
737
|
+
return any(item in msg for msg in self._messages)
|
738
|
+
return False
|
@@ -1409,6 +1409,31 @@ Files: {Files(visible=True, name="files")}
|
|
1409
1409
|
# 5. 验证 provider 索引
|
1410
1410
|
self.assertIsNotNone(messages.provider(text_provider.name))
|
1411
1411
|
|
1412
|
+
async def test_zi_provider_in_message_and_messages(self):
|
1413
|
+
"""测试 `in` 操作符是否能检查 provider 是否存在于 Message 或 Messages 中"""
|
1414
|
+
# 1. 准备 providers 和 messages
|
1415
|
+
text_hi = Texts("hi")
|
1416
|
+
text_hello = Texts("hello")
|
1417
|
+
text_world = Texts("world")
|
1418
|
+
|
1419
|
+
message = UserMessage(text_hello, text_hi)
|
1420
|
+
messages_collection = Messages(SystemMessage("System"), message)
|
1421
|
+
|
1422
|
+
# 2. 测试 `in` Message
|
1423
|
+
self.assertTrue(Texts("hi") in UserMessage(Texts("hello"), Texts("hi")))
|
1424
|
+
self.assertTrue(text_hi in message)
|
1425
|
+
self.assertTrue(text_hello in message)
|
1426
|
+
self.assertFalse(text_world in message)
|
1427
|
+
|
1428
|
+
# 3. 测试 `in` Messages
|
1429
|
+
self.assertTrue(text_hi in messages_collection)
|
1430
|
+
self.assertTrue(text_hello in messages_collection)
|
1431
|
+
self.assertFalse(text_world in messages_collection)
|
1432
|
+
|
1433
|
+
# 4. 测试一个 Message 对象是否在 Messages 中
|
1434
|
+
self.assertTrue(message in messages_collection)
|
1435
|
+
self.assertFalse(UserMessage("not in collection") in messages_collection)
|
1436
|
+
|
1412
1437
|
|
1413
1438
|
# ==============================================================================
|
1414
1439
|
# 6. 演示
|
@@ -476,7 +476,9 @@ class chatgpt(BaseLLM):
|
|
476
476
|
# 删除 task_complete 跟其他工具一起调用的情况,因为 task_complete 必须单独调用
|
477
477
|
if len(function_parameter) > 1:
|
478
478
|
function_parameter = [tool_dict for tool_dict in function_parameter if tool_dict.get("function_name", "") != "task_complete"]
|
479
|
-
|
479
|
+
# 仅当存在其他工具时,才删除 get_task_result
|
480
|
+
if any(tool.get("function_name") != "get_task_result" for tool in function_parameter):
|
481
|
+
function_parameter = [tool_dict for tool_dict in function_parameter if tool_dict.get("function_name", "") != "get_task_result"]
|
480
482
|
if len(function_parameter) == 1 and function_parameter[0].get("function_name", "") == "task_complete":
|
481
483
|
raise TaskComplete(safe_get(function_parameter, 0, "parameter", "message", default="The task has been completed."))
|
482
484
|
|
@@ -6,12 +6,12 @@ beswarm/prompt.py,sha256=yuIDzFnU4nFmaZ4st_tS14W7RI_bvDDpaoTJYEuZTo4,34285
|
|
6
6
|
beswarm/taskmanager.py,sha256=2Uz_cthW9rWkQMJdzgsXAMlfN8Ni2Qj_DOq_L-p6XZc,12662
|
7
7
|
beswarm/utils.py,sha256=0J-b38P5QGT-A_38co7FjzaUNJykaskI7mbbcQ4w_68,8215
|
8
8
|
beswarm/agents/chatgroup.py,sha256=PzrmRcDKAbB7cxL16nMod_CzPosDV6bfTmXxQVuv-AQ,12012
|
9
|
-
beswarm/agents/planact.py,sha256=
|
9
|
+
beswarm/agents/planact.py,sha256=OjxnYNu-LkxF2zIf7o75QB25d-yVtD4-FgDllTV_nZM,18456
|
10
10
|
beswarm/aient/aient/__init__.py,sha256=SRfF7oDVlOOAi6nGKiJIUK6B_arqYLO9iSMp-2IZZps,21
|
11
11
|
beswarm/aient/aient/architext/architext/__init__.py,sha256=79Ih1151rfcqZdr7F8HSZSTs_iT2SKd1xCkehMsXeXs,19
|
12
|
-
beswarm/aient/aient/architext/architext/core.py,sha256=
|
12
|
+
beswarm/aient/aient/architext/architext/core.py,sha256=_o5gI5XF6e4kQo4L4x8Q1Tb7C1U0GANm24gJmvAgoXE,30546
|
13
13
|
beswarm/aient/aient/architext/test/openai_client.py,sha256=Dqtbmubv6vwF8uBqcayG0kbsiO65of7sgU2-DRBi-UM,4590
|
14
|
-
beswarm/aient/aient/architext/test/test.py,sha256=
|
14
|
+
beswarm/aient/aient/architext/test/test.py,sha256=G64knZR1rSo0hr8lZPaWWJizEq1A8RGCzcN0e9uhZEM,66729
|
15
15
|
beswarm/aient/aient/architext/test/test_save_load.py,sha256=o8DqH6gDYZkFkQy-a7blqLtJTRj5e4a-Lil48pJ0V3g,3260
|
16
16
|
beswarm/aient/aient/core/__init__.py,sha256=NxjebTlku35S4Dzr16rdSqSTWUvvwEeACe8KvHJnjPg,34
|
17
17
|
beswarm/aient/aient/core/log_config.py,sha256=kz2_yJv1p-o3lUQOwA3qh-LSc3wMHv13iCQclw44W9c,274
|
@@ -26,7 +26,7 @@ beswarm/aient/aient/core/test/test_payload.py,sha256=8jBiJY1uidm1jzL-EiK0s6UGmW9
|
|
26
26
|
beswarm/aient/aient/models/__init__.py,sha256=ZTiZgbfBPTjIPSKURE7t6hlFBVLRS9lluGbmqc1WjxQ,43
|
27
27
|
beswarm/aient/aient/models/audio.py,sha256=kRd-8-WXzv4vwvsTGwnstK-WR8--vr9CdfCZzu8y9LA,1934
|
28
28
|
beswarm/aient/aient/models/base.py,sha256=-nnihYnx-vHZMqeVO9ljjt3k4FcD3n-iMk4tT-10nRQ,7232
|
29
|
-
beswarm/aient/aient/models/chatgpt.py,sha256=
|
29
|
+
beswarm/aient/aient/models/chatgpt.py,sha256=TWU-uPGL2WfGP7CdT2IkfNh3JYYJhV00fhr2mplISp4,42899
|
30
30
|
beswarm/aient/aient/plugins/__init__.py,sha256=p3KO6Aa3Lupos4i2SjzLQw1hzQTigOAfEHngsldrsyk,986
|
31
31
|
beswarm/aient/aient/plugins/arXiv.py,sha256=yHjb6PS3GUWazpOYRMKMzghKJlxnZ5TX8z9F6UtUVow,1461
|
32
32
|
beswarm/aient/aient/plugins/config.py,sha256=TGgZ5SnNKZ8MmdznrZ-TEq7s2ulhAAwTSKH89bci3dA,7079
|
@@ -122,7 +122,7 @@ beswarm/tools/search_web.py,sha256=0fTeczXiOX_LJQGaLEGbuJtIPzofeuquGWEt3yDMtVw,1
|
|
122
122
|
beswarm/tools/subtasks.py,sha256=NHDnmUhUPgDQKBACnpgErpFJRcsH0w_Q9VsyQjNvNHA,12658
|
123
123
|
beswarm/tools/worker.py,sha256=mQ1qdrQ8MgL99byAbTvxfEByFFGN9mty3UHqHjARMQ8,2331
|
124
124
|
beswarm/tools/write_csv.py,sha256=u0Hq18Ksfheb52MVtyLNCnSDHibITpsYBPs2ub7USYA,1466
|
125
|
-
beswarm-0.2.
|
126
|
-
beswarm-0.2.
|
127
|
-
beswarm-0.2.
|
128
|
-
beswarm-0.2.
|
125
|
+
beswarm-0.2.98.dist-info/METADATA,sha256=w-1DXvjxubJhjMMScXlDXIeSfwJZj_WL2HJaGIcfCi0,3878
|
126
|
+
beswarm-0.2.98.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
127
|
+
beswarm-0.2.98.dist-info/top_level.txt,sha256=pJw4O87wvt5882smuSO6DfByJz7FJ8SxxT8h9fHCmpo,8
|
128
|
+
beswarm-0.2.98.dist-info/RECORD,,
|
File without changes
|
File without changes
|