/ swarm_main.py
swarm_main.py
1 from swarm import Swarm, Agent 2 from bridge import trigger_n8n_swarm 3 4 client = Swarm() 5 6 # Specialized Agent for Research 7 research_agent = Agent( 8 name="Research_Agent", 9 instructions="You are a data gatherer. Use 'trigger_n8n_swarm' to find information.", 10 functions=[trigger_n8n_swarm], 11 ) 12 13 # Entry Agent 14 triage_agent = Agent( 15 name="Triage_Agent", 16 instructions="You talk to the user. If they need research, hand off to Research_Agent.", 17 ) 18 19 def transfer_to_researcher(): 20 return research_agent 21 22 triage_agent.functions.append(transfer_to_researcher) 23 24 # Execution logic 25 if __name__ == "__main__": 26 print("--- Swarm Activated ---") 27 user_input = input("User: ") 28 response = client.run( 29 agent=triage_agent, 30 messages=[{"role": "user", "content": user_input}], 31 ) 32 print(f"\nSwarm Response:\n{response.messages[-1]['content']}")