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

23 lines
737 B

1 year ago
from swarms import Worker, MultiAgentDebate, select_speaker
1 year ago
1 year ago
# 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")
1 year ago
agents = [
worker1,
worker2,
worker3
1 year ago
]
1 year ago
# Initialize multi-agent debate with the selection function
debate = MultiAgentDebate(agents, select_speaker)
1 year ago
# 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)
1 year ago
# Print results
for result in results:
print(f"Agent {result['agent']} responded: {result['response']}")