diff --git a/docs/examples/index.md b/docs/examples/index.md index 4781c3d7..4783bceb 100644 --- a/docs/examples/index.md +++ b/docs/examples/index.md @@ -79,6 +79,7 @@ Additionally, we have more comprehensive examples available in [The Swarms Cookb | Scheduling | [Round Robin](https://github.com/The-Swarm-Corporation/swarms-examples/blob/main/examples/structs/swarms/multi_agent_collaboration/round_robin_example.py) | Round-robin task scheduling and execution | | Load Balancing | [Load Balancer](https://github.com/The-Swarm-Corporation/swarms-examples/blob/main/examples/structs/swarms/multi_agent_collaboration/load_balancer_example.py) | Dynamic task distribution system for optimal resource utilization | | Consensus | [Majority Voting](https://github.com/The-Swarm-Corporation/swarms-examples/blob/main/examples/structs/swarms/multi_agent_collaboration/majority_voting.py) | Consensus-building system using democratic voting among agents | +| Workflow | [MultiAgentCollab Workflow](https://github.com/kyegomez/swarms/blob/master/examples/multi_agent/collaboration_examples/multiagent_collab_workflow.py) | Simple collaborative workflow using `MultiAgentCollaboration` | ### Industry Applications | Category | Example | Description | diff --git a/examples/multi_agent/collaboration_examples/multiagent_collab_workflow.py b/examples/multi_agent/collaboration_examples/multiagent_collab_workflow.py new file mode 100644 index 00000000..2089b3b1 --- /dev/null +++ b/examples/multi_agent/collaboration_examples/multiagent_collab_workflow.py @@ -0,0 +1,32 @@ +from swarms import Agent +from swarms.structs import MultiAgentCollaboration + +# Agents will directly initialize their language models + +# Define collaborating agents +planner = Agent( + agent_name="Planner", + system_prompt="Break the objective into clear steps.", + model_name="gpt-4o-mini", + max_loops=1, +) + +writer = Agent( + agent_name="Writer", + system_prompt="Use the plan to craft the final answer.", + model_name="gpt-4o-mini", + max_loops=1, +) + +# Initialize the collaborative workflow +swarm = MultiAgentCollaboration( + agents=[planner, writer], + max_loops=4, +) + +# Kick off the collaboration +swarm.inject("Manager", "Produce a short overview of reinforcement learning.") + +result = swarm.run("Begin") +print(result) +