diff --git a/README.md b/README.md index 5f0a833b..f929011a 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ for result in results: ```python from langchain.llms import ChatOpenAI -from swarms import Worker +from swarms.workers import Worker llm = ChatOpenAI( model_name='gpt-4', diff --git a/multi_agent_debate.py b/multi_agent_debate.py new file mode 100644 index 00000000..067d3e89 --- /dev/null +++ b/multi_agent_debate.py @@ -0,0 +1,44 @@ +from swarms.swarms.multi_agent_debate import MultiAgentDebate, select_speaker +from swarms.workers.worker import Worker +from langchain.llms import OpenAIChat + +llm = OpenAIChat(model_name="gpt-4", openai_api_key="api-key", temperature=0.5) + +worker1 = Worker( + llm=llm, + ai_name="Bumble Bee", + ai_role="Worker in a swarm", + external_tools=None, + human_in_the_loop=False, + temperature=0.5, +) +worker2 = Worker( + llm=llm, + ai_name="Optimus Prime", + ai_role="Worker in a swarm", + external_tools=None, + human_in_the_loop=False, + temperature=0.5, +) +worker3 = Worker( + llm=llm, + ai_name="Megatron", + ai_role="Worker in a swarm", + external_tools=None, + human_in_the_loop=False, + temperature=0.5, +) + +#init agents +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']}") diff --git a/playground/swarms/multi_agent_debate.py b/playground/swarms/multi_agent_debate.py deleted file mode 100644 index e6e785c7..00000000 --- a/playground/swarms/multi_agent_debate.py +++ /dev/null @@ -1,20 +0,0 @@ -from swarms.swarms.multi_agent_debate import MultiAgentDebate, select_speaker -from swarms.workers.worker import Worker - -# 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']}")