-
-
Notifications
You must be signed in to change notification settings - Fork 717
[FEAT-STRUCT][Finished off Election swarm, based on arxiv research paper and past projects] #1095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| from enum import Enum | ||
| from typing import Any, Dict, List, Optional | ||
|
|
||
| from pydantic import BaseModel, Field |
Check failure
Code scanning / Pyre
Undefined import Error
| DEFAULT_BATCH_SIZE = 25 | ||
|
|
||
|
|
||
| class ElectionConfigModel(BaseModel): |
Check failure
Code scanning / Pyre
Undefined or invalid type Error
| try: | ||
| import yaml | ||
|
|
||
| with open(self.config_file_path, "r", encoding="utf-8") as f: |
Check failure
Code scanning / Pyre
Incompatible parameter type Error
| try: | ||
| import yaml | ||
|
|
||
| config_dict = self.config.model_dump() |
Check failure
Code scanning / Pyre
Undefined attribute Error
| def validate_config(self) -> List[str]: | ||
| errors = [] | ||
| try: | ||
| self.config.model_validate(self.config.model_dump()) |
Check failure
Code scanning / Pyre
Undefined attribute Error
| - Verification Protocols: {vote_counter.verification_protocols} | ||
| """ | ||
|
|
||
| vote_counter.agent.system_prompt += context |
Check failure
Code scanning / Pyre
Undefined attribute Error
| election_logger.error(f"Failed to count votes with vote counter: {str(e)}") | ||
| # Fallback to basic counting | ||
| return VoteCountingResult( | ||
| counter_id=self.vote_counter.counter_id, |
Check failure
Code scanning / Pyre
Undefined attribute Error
| # Fallback to basic counting | ||
| return VoteCountingResult( | ||
| counter_id=self.vote_counter.counter_id, | ||
| counter_name=self.vote_counter.name, |
Check failure
Code scanning / Pyre
Undefined attribute Error
|
|
||
| # Create counting result | ||
| counting_result = VoteCountingResult( | ||
| counter_id=self.vote_counter.counter_id, |
Check failure
Code scanning / Pyre
Undefined attribute Error
| # Create counting result | ||
| counting_result = VoteCountingResult( | ||
| counter_id=self.vote_counter.counter_id, | ||
| counter_name=self.vote_counter.name, |
Check failure
Code scanning / Pyre
Undefined attribute Error
Description
This PR introduces ElectionSwarm, a sophisticated multi-agent orchestrator selection system that implements democratic decision-making protocols for leadership selection in multi-agent workflows. The system enables agent voters to elect the best orchestrator candidate through various coordination algorithms, providing a structured approach to leadership selection.
Key Features Added:
ElectionSwarm Core System (
swarms/structs/election_swarm.py):Vote Counter Integration:
VoteCounterProfiledataclass for dedicated vote counting agentsVoteCountingResultdataclass for detailed vote analysisElectionResultto include vote counting informationReal-World Example (
examples/multi_agent/election_swarm/real_world_election.py):Documentation (
docs/swarms/structs/election_swarm.md):Package Integration:
ElectionSwarmtoswarms/structs/__init__.pyexportsArchitecture:
graph TD A[User Task] --> B[ElectionSwarm] B --> C[Voter Registration] B --> D[Candidate Registration] C --> E[Agent Voters] D --> F[Orchestrator Candidates] E --> G[Message Passing Protocol] F --> G G --> H[AGENTSNET Communication] H --> I[Voting Process] I --> J[Election Algorithms] J --> K[Consensus Building] J --> L[Leader Election] J --> M[Matching Algorithm] J --> N[Coloring Algorithm] J --> O[Vertex Cover] K --> P[Election Result] L --> P M --> P N --> P O --> P P --> Q[Selected Orchestrator]Technical Implementation:
Issue
#957
Dependencies
Tag Maintainer
@kyegomez
Twitter Handle
x.com/IlumTheProtogen
Testing
The implementation includes:
Files Changed
swarms/structs/election_swarm.py- Core ElectionSwarm implementationexamples/multi_agent/election_swarm/real_world_election.py- Real-world CEO election exampledocs/swarms/structs/election_swarm.md- Comprehensive documentationswarms/structs/__init__.py- Added ElectionSwarm to exportsexamples/multi_agent/election_swarm/basic_usage.py- Basic Usage exampleexamples/multi_agent/election_swarm/specialized_session.py- advanced(more complex) exampledocs/mkdocs.yml- added election_swarm under advanced workflowsUsage Example
This PR significantly enhances the Swarms framework with democratic decision-making capabilities, enabling more sophisticated multi-agent coordination and leadership selection.
📚 Documentation preview 📚: https://swarms--1095.org.readthedocs.build/en/1095/