Run one iteration of the AgentSwarm, which gathers responses, computes consensus, and aggregates the output.
Parameters: |
-
query
(str )
–
The query to be processed by the agents in the swarm.
|
Returns: |
-
object
–
The aggregated output based on the consensus of the agent responses.
|
Source code in llamarch/patterns/agent_swarm/__init__.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 | def run_iteration(self, query):
"""
Run one iteration of the AgentSwarm, which gathers responses, computes consensus, and aggregates the output.
Parameters
----------
query : str
The query to be processed by the agents in the swarm.
Returns
-------
object
The aggregated output based on the consensus of the agent responses.
"""
# Get the consensus
responses = asyncio.run(self._gather_responses(self.agent_list, query))
consensus_result = self.consensus_layer.get_consensus(
responses, self.agent_list)
output = self.aggregator.aggregate_output(consensus_result)
return output
|