Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion swarms/structs/majority_voting.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
consensus_agent_description: str = "An agent that uses consensus to generate a final answer.",
consensus_agent_model_name: str = "gpt-4.1",
additional_consensus_agent_kwargs: dict = {},
consensus_agent: Agent = None, # Accept but don't use this parameter for backward compatibility

Check failure

Code scanning / Pyre

Incompatible variable type Error

Incompatible variable type [9]: consensus_agent is declared to have type Agent but is used as type None.
*args,
**kwargs,
):
Expand All @@ -135,8 +136,23 @@
self.output_type = output_type
self.consensus_agent_prompt = consensus_agent_prompt

# Filter out MajorityVoting-specific kwargs that shouldn't be passed to Conversation
majority_voting_specific_params = {
"consensus_agent",
"consensus_agent_prompt",
"consensus_agent_name",
"consensus_agent_description",
"consensus_agent_model_name",
"additional_consensus_agent_kwargs",
}
conversation_kwargs = {
k: v
for k, v in kwargs.items()
if k not in majority_voting_specific_params
}

self.conversation = Conversation(
time_enabled=False, *args, **kwargs
time_enabled=False, *args, **conversation_kwargs
)

self.consensus_agent = default_consensus_agent(
Expand Down
2 changes: 1 addition & 1 deletion swarms/structs/swarm_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def _create_majority_voting(self, *args, **kwargs):
name=self.name,
description=self.description,
agents=self.agents,
consensus_agent=self.agents[-1],
max_loops=self.max_loops,
*args,
**kwargs,
)
Expand Down
13 changes: 0 additions & 13 deletions test.py

This file was deleted.

Loading