parent
74715f191b
commit
06d79356d4
@ -0,0 +1,27 @@
|
||||
# MultiAgentRouter Minimal Example
|
||||
|
||||
This example shows how to route a task to the most suitable agent using `MultiAgentRouter`.
|
||||
|
||||
```python
|
||||
from swarms import Agent, MultiAgentRouter
|
||||
|
||||
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 = MultiAgentRouter(agents=agents)
|
||||
|
||||
result = router.route_task("Write a function that adds two numbers")
|
||||
print("Chosen agent:", result["boss_decision"]["selected_agent"])
|
||||
```
|
||||
|
||||
View the source on [GitHub](https://github.com/kyegomez/swarms/blob/master/examples/multi_agent/mar/multi_agent_router_minimal.py).
|
@ -0,0 +1,20 @@
|
||||
from swarms import Agent, MultiAgentRouter
|
||||
|
||||
if __name__ == "__main__":
|
||||
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 = MultiAgentRouter(agents=agents)
|
||||
|
||||
result = router.route_task("Write a function that adds two numbers")
|
||||
print("Chosen agent:", result["boss_decision"]["selected_agent"])
|
Loading…
Reference in new issue