|
|
|
@ -1,9 +1,10 @@
|
|
|
|
|
# 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
|
|
|
|
|
from swarms import Agent, MultiAgentRouter
|
|
|
|
|
from swarms import Agent
|
|
|
|
|
from swarms.structs.swarm_router import SwarmRouter
|
|
|
|
|
|
|
|
|
|
agents = [
|
|
|
|
|
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).
|