You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							32 lines
						
					
					
						
							750 B
						
					
					
				
			
		
		
	
	
							32 lines
						
					
					
						
							750 B
						
					
					
				from swarms import AutoSwarm, AutoSwarmRouter, BaseSwarm
 | 
						|
 | 
						|
 | 
						|
# Build your own Swarm
 | 
						|
class MySwarm(BaseSwarm):
 | 
						|
    def __init__(self, *args, **kwargs):
 | 
						|
        super().__init__(*args, **kwargs)
 | 
						|
 | 
						|
    def run(self, task: str, *args, **kwargs):
 | 
						|
        # Add your multi-agent logic here
 | 
						|
        # agent 1
 | 
						|
        # agent 2
 | 
						|
        # agent 3
 | 
						|
        return "output of the swarm"
 | 
						|
 | 
						|
 | 
						|
# Add your custom swarm to the AutoSwarmRouter
 | 
						|
router = AutoSwarmRouter(swarms=[MySwarm])
 | 
						|
 | 
						|
 | 
						|
# Create an AutoSwarm instance
 | 
						|
autoswarm = AutoSwarm(
 | 
						|
    name="AutoSwarm, an API for all swarms",
 | 
						|
    description="A simple API to build and run swarms",
 | 
						|
    verbose=True,
 | 
						|
    router=router,
 | 
						|
)
 | 
						|
 | 
						|
 | 
						|
# Run the AutoSwarm
 | 
						|
autoswarm.run("Analyze these financial data and give me a summary")
 |