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/docs/swarms/examples/multi_agent_router_minimal.md

33 lines
919 B

# MultiAgentRouter Minimal Example
This example shows how to route a task to the most suitable agent using `SwarmRouter` with `swarm_type="MultiAgentRouter"`.
```python
from swarms import Agent
from swarms.structs.swarm_router import SwarmRouter
agents = [
Agent(
agent_name="Researcher",
system_prompt="Answer questions briefly.",
model_name="gpt-4o-mini",
),
Agent(
agent_name="Coder",
system_prompt="Write small Python functions.",
model_name="gpt-4o-mini",
),
]
router = SwarmRouter(
name="multi-agent-router-demo",
description="Routes tasks to the most suitable agent",
agents=agents,
swarm_type="MultiAgentRouter"
)
result = router.run("Write a function that adds two numbers")
print(result)
```
View the source on [GitHub](https://github.com/kyegomez/swarms/blob/master/examples/multi_agent/mar/multi_agent_router_minimal.py).