Add MultiAgentCollab example

pull/895/head
Pavan Kumar 1 month ago committed by GitHub
commit 836d8b6774
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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 |

@ -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)
Loading…
Cancel
Save