docs: update minimal MultiAgentRouter example and documentation to use SwarmRouter interface

pull/896/head
Pavan Kumar 2 weeks ago
parent f8f148d6e5
commit 1dae904c43

@ -1,9 +1,10 @@
# MultiAgentRouter Minimal Example # MultiAgentRouter Minimal Example
This example shows how to route a task to the most suitable agent using `MultiAgentRouter`. This example shows how to route a task to the most suitable agent using `SwarmRouter` with `swarm_type="MultiAgentRouter"`.
```python ```python
from swarms import Agent, MultiAgentRouter from swarms import Agent
from swarms.structs.swarm_router import SwarmRouter
agents = [ agents = [
Agent( Agent(
@ -18,9 +19,15 @@ agents = [
), ),
] ]
router = MultiAgentRouter(agents=agents) router = SwarmRouter(
name="multi-agent-router-demo",
description="Routes tasks to the most suitable agent",
agents=agents,
swarm_type="MultiAgentRouter"
)
result = router.route_task("Write a function that adds two numbers") 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). View the source on [GitHub](https://github.com/kyegomez/swarms/blob/master/examples/multi_agent/mar/multi_agent_router_minimal.py).
Loading…
Cancel
Save