beswarm 0.2.46__py3-none-any.whl → 0.2.48__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.

Potentially problematic release.


This version of beswarm might be problematic. Click here for more details.

beswarm/agents/planact.py CHANGED
@@ -38,13 +38,16 @@ class BaseAgent:
38
38
 
39
39
  self._subscription = self.broker.subscribe(self.handle_message, [self.listen_topic, self.error_topic])
40
40
 
41
+ self.graph_tree = None
42
+
41
43
  async def handle_message(self, message: Dict):
42
44
  """Process incoming messages. Must be implemented by subclasses."""
43
45
  raise NotImplementedError
44
46
 
45
47
  def handle_graph_update(self, message: Dict):
46
48
  """Handle graph update messages."""
47
- raise NotImplementedError
49
+ if message.get("message") == "graph_updated":
50
+ self.graph_tree = message.get("graph")
48
51
 
49
52
  def dispose(self):
50
53
  """Cancels the subscription and cleans up resources."""
@@ -60,7 +63,6 @@ class InstructionAgent(BaseAgent):
60
63
  self.last_instruction = None
61
64
  self.agent = chatgpt(**self.config)
62
65
 
63
- self.graph_tree = None
64
66
  self.goal_diff = None
65
67
 
66
68
  if self.cache_messages and isinstance(self.cache_messages, list) and len(self.cache_messages) > 1:
@@ -73,11 +75,6 @@ class InstructionAgent(BaseAgent):
73
75
  changed_lines.append(line)
74
76
  self.goal_diff = '\n'.join(changed_lines).strip()
75
77
 
76
- def handle_graph_update(self, message: Dict):
77
- """Handle graph update messages."""
78
- if message.get("message") == "graph_updated":
79
- self.graph_tree = message.get("graph")
80
-
81
78
  def get_conversation_history(self, raw_conversation_history: List[Dict]):
82
79
  conversation_history = copy.deepcopy(raw_conversation_history)
83
80
 
@@ -179,8 +176,8 @@ class InstructionAgent(BaseAgent):
179
176
 
180
177
  class WorkerAgent(BaseAgent):
181
178
  """Executes instructions and publishes results to a message broker."""
182
- def __init__(self, goal: str, tools_json: List, agent_config: Dict, work_dir: str, cache_messages: Union[bool, List[Dict]], broker: MessageBroker, listen_topic: str, publish_topic: str, status_topic: str):
183
- super().__init__(goal, tools_json, agent_config, work_dir, cache_messages, broker, listen_topic, publish_topic, status_topic)
179
+ def __init__(self, goal: str, tools_json: List, agent_config: Dict, work_dir: str, cache_messages: Union[bool, List[Dict]], broker: MessageBroker, listen_topic: str, publish_topic: str, status_topic: str, graph_update_topic: str):
180
+ super().__init__(goal, tools_json, agent_config, work_dir, cache_messages, broker, listen_topic, publish_topic, status_topic, graph_update_topic)
184
181
 
185
182
  if self.cache_messages and isinstance(self.cache_messages, list) and len(self.cache_messages) > 1:
186
183
  first_user_message = replace_xml_content(self.cache_messages[1]["content"], "goal", goal)
@@ -197,6 +194,12 @@ class WorkerAgent(BaseAgent):
197
194
  }, self.publish_topic)
198
195
  return
199
196
 
197
+ for index, raw_message in enumerate(self.agent.conversation["default"]):
198
+ if raw_message.get("content") and isinstance(raw_message["content"], str) \
199
+ and "<knowledge_graph_tree>" in raw_message["content"] and self.graph_tree:
200
+ raw_message["content"] = replace_xml_content(raw_message["content"], "knowledge_graph_tree", self.graph_tree)
201
+ self.agent.conversation["default"][index] = raw_message
202
+
200
203
  instruction = message["instruction"]
201
204
  if "find_and_click_element" in json.dumps(self.tools_json):
202
205
  instruction = await get_current_screen_image_message(instruction)
@@ -312,6 +315,7 @@ class BrokerWorker:
312
315
  goal=self.goal, tools_json=self.tools_json, agent_config=worker_agent_config, work_dir=self.work_dir, cache_messages=self.cache_messages,
313
316
  broker=self.broker, listen_topic=self.INSTRUCTION_TOPIC,
314
317
  publish_topic=self.WORKER_RESPONSE_TOPIC, status_topic=self.TASK_STATUS_TOPIC,
318
+ graph_update_topic=self.GRAPH_UPDATE_TOPIC
315
319
  )
316
320
  return instruction_agent, worker_agent
317
321
 
beswarm/broker.py CHANGED
@@ -152,7 +152,7 @@ class MessageBroker:
152
152
 
153
153
  if new_messages:
154
154
  if self.debug:
155
- print(f" -> 订阅者 '{callback.__name__}' 在 '{current_topic}' 主题上收到 {len(new_messages)} 条新消息。")
155
+ print(f" -> 订阅者 '{callback.__name__}' 在 '{current_topic}' 主题上收到 {len(new_messages)} 条新消息。{new_messages}")
156
156
  for msg in new_messages:
157
157
  try:
158
158
  if asyncio.iscoroutinefunction(callback):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: beswarm
3
- Version: 0.2.46
3
+ Version: 0.2.48
4
4
  Summary: MAS
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -1,12 +1,12 @@
1
1
  beswarm/__init__.py,sha256=HZjUOJtZR5QhMuDbq-wukQQn1VrBusNWai_ysGo-VVI,20
2
- beswarm/broker.py,sha256=RtnQZVbhf25acUHahNBiaS5FGxcrj0rhBhkon9gFY_M,9873
2
+ beswarm/broker.py,sha256=64Y-djrKYaZfBQ8obwHOmr921QgZeu9BtScZWaYLfDo,9887
3
3
  beswarm/core.py,sha256=htssaaeIBZ_yOqvX9VtANoVWaZHt_7oWcxyDI1z0paQ,310
4
4
  beswarm/knowledge_graph.py,sha256=Q2hhXL2RXnAM8vvxstYetch5wX7ghTM5S7FnORSxCG0,9205
5
5
  beswarm/prompt.py,sha256=n0a1a6NThIxAYSkisg1sEKjvz2w0tozpKL4BIplaAkI,32286
6
6
  beswarm/taskmanager.py,sha256=xczsnehCaOAI3SRE8wUxhzmt6i6G7ynndSWS_bAZn3k,12192
7
7
  beswarm/utils.py,sha256=S9jEtht0hTZbjZ2Hk24p4Ip41R69BogOkYS6fgPKY2Y,8219
8
8
  beswarm/agents/chatgroup.py,sha256=YHofra9kE0x7UrhqZjlP7PbWvinEew1BkjJ0XilzudM,12020
9
- beswarm/agents/planact.py,sha256=PGj69lhy6r3q07R8w16aMoWY1OjXVXothu7lDG-UC4Y,19140
9
+ beswarm/agents/planact.py,sha256=-JPN8L1JgVjy4G36eUHZHyLiBrN5oI8fLTbpweZsUuU,19568
10
10
  beswarm/aient/main.py,sha256=SiYAIgQlLJqYusnTVEJOx1WNkSJKMImhgn5aWjfroxg,3814
11
11
  beswarm/aient/setup.py,sha256=Mq1M05mT9_UYBK2jk5mP_sLxKQAolcuh8PYXexfj-XU,487
12
12
  beswarm/aient/src/aient/__init__.py,sha256=SRfF7oDVlOOAi6nGKiJIUK6B_arqYLO9iSMp-2IZZps,21
@@ -145,7 +145,7 @@ beswarm/tools/search_web.py,sha256=LhgXOSHL9fwxg5T2AAOV4TTJkcJVLogsfRJW2faPvDE,1
145
145
  beswarm/tools/subtasks.py,sha256=zZmRCjDocbvrU8MvZvpDWpQCKNntDJ123ByBiS8pRko,9889
146
146
  beswarm/tools/worker.py,sha256=-tcLGrdLPZYxc1z66iQIB1VH7RWcR-5CgVWuDIQJBCQ,2013
147
147
  beswarm/tools/write_csv.py,sha256=-r5OghcvjCg00hY0YQbp6u31VIJLrgaqDIvczAFoqDE,1470
148
- beswarm-0.2.46.dist-info/METADATA,sha256=xFDxpNffZqMEucZHFfh63mCH2YBq6UnKBz8gJF5kvtk,3878
149
- beswarm-0.2.46.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
150
- beswarm-0.2.46.dist-info/top_level.txt,sha256=pJw4O87wvt5882smuSO6DfByJz7FJ8SxxT8h9fHCmpo,8
151
- beswarm-0.2.46.dist-info/RECORD,,
148
+ beswarm-0.2.48.dist-info/METADATA,sha256=x4Nf2GnW7tPwtMAWDVu3tTMWj1aJkM-6gwFPwG5Ga8Q,3878
149
+ beswarm-0.2.48.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
150
+ beswarm-0.2.48.dist-info/top_level.txt,sha256=pJw4O87wvt5882smuSO6DfByJz7FJ8SxxT8h9fHCmpo,8
151
+ beswarm-0.2.48.dist-info/RECORD,,