From 0e7762a7a60543d501fe4847a9139bac5bfc80bc Mon Sep 17 00:00:00 2001 From: Kye Date: Sun, 24 Sep 2023 20:13:01 -0400 Subject: [PATCH] examples --- playground/multi_agent_collab.py | 9 +++++++++ orchestrator.py => playground/orchestrator.py | 0 swarms/swarms/dialogue_authoritarian_speaker.py | 12 ------------ swarms/swarms/multi_agent_collab.py | 13 +++++++++++++ workflow.py | 11 ----------- 5 files changed, 22 insertions(+), 23 deletions(-) create mode 100644 playground/multi_agent_collab.py rename orchestrator.py => playground/orchestrator.py (100%) delete mode 100644 swarms/swarms/dialogue_authoritarian_speaker.py delete mode 100644 workflow.py diff --git a/playground/multi_agent_collab.py b/playground/multi_agent_collab.py new file mode 100644 index 00000000..8caebb51 --- /dev/null +++ b/playground/multi_agent_collab.py @@ -0,0 +1,9 @@ +from swarms import DialogueSimulator, Worker + +def select_next_speaker(step: int, agents) -> int: + idx = (step) % len(agents) + return idx + +debate = DialogueSimulator(Worker, select_next_speaker) + +debate.run() diff --git a/orchestrator.py b/playground/orchestrator.py similarity index 100% rename from orchestrator.py rename to playground/orchestrator.py diff --git a/swarms/swarms/dialogue_authoritarian_speaker.py b/swarms/swarms/dialogue_authoritarian_speaker.py deleted file mode 100644 index 2009efd8..00000000 --- a/swarms/swarms/dialogue_authoritarian_speaker.py +++ /dev/null @@ -1,12 +0,0 @@ -def select_next_speaker( - step: int, - agents, - director -) -> int: - #if the step if even => director - #=> director selects next speaker - if step % 2 == 1: - idx = 0 - else: - idx = director.select_next_speaker() + 1 - return idx diff --git a/swarms/swarms/multi_agent_collab.py b/swarms/swarms/multi_agent_collab.py index 878639c3..ef595c28 100644 --- a/swarms/swarms/multi_agent_collab.py +++ b/swarms/swarms/multi_agent_collab.py @@ -11,6 +11,19 @@ bid_parser = BidOutputParser( regex=r"<(\d+)>", output_keys=["bid"], default_output_key="bid" ) +def select_next_speaker( + step: int, + agents, + director +) -> int: + #if the step if even => director + #=> director selects next speaker + if step % 2 == 1: + idx = 0 + else: + idx = director.select_next_speaker() + 1 + return idx + #main class MultiAgentCollaboration: diff --git a/workflow.py b/workflow.py deleted file mode 100644 index a40fe605..00000000 --- a/workflow.py +++ /dev/null @@ -1,11 +0,0 @@ - -from swarms import Workflow -from swarms.tools.autogpt import ChatOpenAI - -workflow = Workflow(ChatOpenAI) - -workflow.add("What's the weather in miami") -workflow.add("Provide details for {{ parent_output }}") -workflow.add("Summarize the above information: {{ parent_output}}") - -workflow.run()