@ -23,9 +23,10 @@ from swarms.structs.agent_rearrange import AgentRearrange
from swarms . structs . batched_grid_workflow import BatchedGridWorkflow
from swarms . structs . batched_grid_workflow import BatchedGridWorkflow
from swarms . structs . concurrent_workflow import ConcurrentWorkflow
from swarms . structs . concurrent_workflow import ConcurrentWorkflow
from swarms . structs . council_as_judge import CouncilAsAJudge
from swarms . structs . council_as_judge import CouncilAsAJudge
from swarms . structs . debate_with_judge import DebateWithJudge
from swarms . structs . groupchat import GroupChat
from swarms . structs . groupchat import GroupChat
from swarms . structs . heavy_swarm import HeavySwarm
from swarms . structs . heavy_swarm import HeavySwarm
from swarms . structs . hie archical_swarm import HierarchicalSwarm
from swarms . structs . hie r archical_swarm import HierarchicalSwarm
from swarms . structs . interactive_groupchat import InteractiveGroupChat
from swarms . structs . interactive_groupchat import InteractiveGroupChat
from swarms . structs . ma_utils import list_all_agents
from swarms . structs . ma_utils import list_all_agents
from swarms . structs . majority_voting import MajorityVoting
from swarms . structs . majority_voting import MajorityVoting
@ -58,6 +59,7 @@ SwarmType = Literal[
" HeavySwarm " ,
" HeavySwarm " ,
" BatchedGridWorkflow " ,
" BatchedGridWorkflow " ,
" LLMCouncil " ,
" LLMCouncil " ,
" DebateWithJudge " ,
]
]
@ -306,12 +308,23 @@ class SwarmRouter:
if (
if (
self . swarm_type != " HeavySwarm "
self . swarm_type != " HeavySwarm "
and self . swarm_type != " DebateWithJudge "
and self . agents is None
and self . agents is None
) :
) :
raise SwarmRouterConfigError (
raise SwarmRouterConfigError (
" SwarmRouter: No agents provided for the swarm. Check the docs to learn of required parameters. https://docs.swarms.world/en/latest/swarms/structs/agent/ "
" SwarmRouter: No agents provided for the swarm. Check the docs to learn of required parameters. https://docs.swarms.world/en/latest/swarms/structs/agent/ "
)
)
if self . swarm_type == " DebateWithJudge " :
if self . agents is None or len ( self . agents ) != 3 :
raise SwarmRouterConfigError (
" SwarmRouter: DebateWithJudge requires exactly 3 agents: "
" pro_agent (arguing in favor), con_agent (arguing against), "
" and judge_agent (evaluating and synthesizing). "
f " Provided { len ( self . agents ) if self . agents else 0 } agent(s). "
" Check the docs: https://docs.swarms.world/en/latest/swarms/structs/swarm_router/ "
)
if (
if (
self . swarm_type == " AgentRearrange "
self . swarm_type == " AgentRearrange "
and self . rearrange_flow is None
and self . rearrange_flow is None
@ -430,6 +443,7 @@ class SwarmRouter:
" ConcurrentWorkflow " : self . _create_concurrent_workflow ,
" ConcurrentWorkflow " : self . _create_concurrent_workflow ,
" BatchedGridWorkflow " : self . _create_batched_grid_workflow ,
" BatchedGridWorkflow " : self . _create_batched_grid_workflow ,
" LLMCouncil " : self . _create_llm_council ,
" LLMCouncil " : self . _create_llm_council ,
" DebateWithJudge " : self . _create_debate_with_judge ,
}
}
def _create_heavy_swarm ( self , * args , * * kwargs ) :
def _create_heavy_swarm ( self , * args , * * kwargs ) :
@ -457,6 +471,25 @@ class SwarmRouter:
chairman_model = self . chairman_model ,
chairman_model = self . chairman_model ,
)
)
def _create_debate_with_judge ( self , * args , * * kwargs ) :
""" Factory function for DebateWithJudge. """
if len ( self . agents ) != 3 :
raise SwarmRouterConfigError (
" DebateWithJudge requires exactly 3 agents: "
" pro_agent (arguing in favor), con_agent (arguing against), "
" and judge_agent (evaluating and synthesizing). "
f " Provided { len ( self . agents ) } agent(s). "
)
return DebateWithJudge (
pro_agent = self . agents [ 0 ] ,
con_agent = self . agents [ 1 ] ,
judge_agent = self . agents [ 2 ] ,
max_rounds = self . max_loops ,
output_type = self . output_type ,
verbose = self . verbose ,
)
def _create_agent_rearrange ( self , * args , * * kwargs ) :
def _create_agent_rearrange ( self , * args , * * kwargs ) :
""" Factory function for AgentRearrange. """
""" Factory function for AgentRearrange. """
return AgentRearrange (
return AgentRearrange (