|  |  | @ -6,29 +6,29 @@ from swarms.workers.worker import Worker | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | @dataclass |  |  |  | @dataclass | 
			
		
	
		
		
			
				
					
					|  |  |  | class GroupChat: |  |  |  | class GroupChat: | 
			
		
	
		
		
			
				
					
					|  |  |  |     """A group chat with multiple participants with a list of agents and a max number of rounds""" |  |  |  |     """A group chat with multiple participants with a list of workers and a max number of rounds""" | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     agents: List[Worker] |  |  |  |     workers: List[Worker] | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     messages: List[Dict] |  |  |  |     messages: List[Dict] | 
			
		
	
		
		
			
				
					
					|  |  |  |     max_rounds: int = 10 |  |  |  |     max_rounds: int = 10 | 
			
		
	
		
		
			
				
					
					|  |  |  |     admin_name: str = "Admin" #admin agent |  |  |  |     admin_name: str = "Admin" #admin agent | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     @property |  |  |  |     @property | 
			
		
	
		
		
			
				
					
					|  |  |  |     def agent_names(self) -> List[str]: |  |  |  |     def agent_names(self) -> List[str]: | 
			
		
	
		
		
			
				
					
					|  |  |  |         """returns the names of the agents in the group chat""" |  |  |  |         """returns the names of the workers in the group chat""" | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         return [agent.ai_name for agent in self.agents] |  |  |  |         return [agent.ai_name for agent in self.workers] | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |     def reset(self): |  |  |  |     def reset(self): | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.messages.clear() |  |  |  |         self.messages.clear() | 
			
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |     def agent_by_name(self, name: str) -> Worker: |  |  |  |     def agent_by_name(self, name: str) -> Worker: | 
			
		
	
		
		
			
				
					
					|  |  |  |         """Find the next speaker baed on the message""" |  |  |  |         """Find the next speaker baed on the message""" | 
			
		
	
		
		
			
				
					
					|  |  |  |         return self.agents[self.agent_names.index(name)] |  |  |  |         return self.workers[self.agent_names.index(name)] | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |     def next_agent(self, agent: Worker) -> Worker: |  |  |  |     def next_agent(self, agent: Worker) -> Worker: | 
			
		
	
		
		
			
				
					
					|  |  |  |         """Returns the next agent in the list""" |  |  |  |         """Returns the next agent in the list""" | 
			
		
	
		
		
			
				
					
					|  |  |  |         return self.agents[ |  |  |  |         return self.workers[ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             (self.agents_names.index(agent.ai_name) + 1) % len(self.agents) |  |  |  |             (self.workers_names.index(agent.ai_name) + 1) % len(self.workers) | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         ] |  |  |  |         ] | 
			
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |     def select_speaker_msg(self): |  |  |  |     def select_speaker_msg(self): | 
			
		
	
	
		
		
			
				
					|  |  | @ -67,7 +67,7 @@ class GroupChat: | 
			
		
	
		
		
			
				
					
					|  |  |  |          |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |     def _participant_roles(self): |  |  |  |     def _participant_roles(self): | 
			
		
	
		
		
			
				
					
					|  |  |  |         return "\n".join( |  |  |  |         return "\n".join( | 
			
		
	
		
		
			
				
					
					|  |  |  |             [f"{agent.ai_name}: {agent.system_message}" for agent in self.agents]  |  |  |  |             [f"{agent.ai_name}: {agent.system_message}" for agent in self.workers]  | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         ) |  |  |  |         ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -117,8 +117,8 @@ class GroupChatManager(Worker): | 
			
		
	
		
		
			
				
					
					|  |  |  |              |  |  |  |              | 
			
		
	
		
		
			
				
					
					|  |  |  |             groupchat.messages.append(message) |  |  |  |             groupchat.messages.append(message) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             #broadcast the message to all agents except the speaker |  |  |  |             #broadcast the message to all workers except the speaker | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             for agent in groupchat.agents: |  |  |  |             for agent in groupchat.workers: | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 if agent != speaker: |  |  |  |                 if agent != speaker: | 
			
		
	
		
		
			
				
					
					|  |  |  |                     self.send( |  |  |  |                     self.send( | 
			
		
	
		
		
			
				
					
					|  |  |  |                         message, |  |  |  |                         message, | 
			
		
	
	
		
		
			
				
					|  |  | 
 |