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.
swarms/multi_agent_debate.py

24 lines
771 B

from typing import List, Callable
from swarms import Worker, MultiAgentDebate, select_speaker
# Initialize agents
worker1 = Worker(openai_api_key="", ai_name="Optimus Prime")
worker2 = Worker(openai_api_key="", ai_name="Bumblebee")
worker3 = Worker(openai_api_key="", ai_name="Megatron")
agents = [
worker1,
worker2,
worker3
]
# Initialize multi-agent debate with the selection function
debate = MultiAgentDebate(agents, select_speaker)
# Run task
task = "What were the winning boston marathon times for the past 5 years (ending in 2022)? Generate a table of the year, name, country of origin, and times."
results = debate.run(task, max_iters=4)
# Print results
for result in results:
print(f"Agent {result['agent']} responded: {result['response']}")