Skip to content

Commit

Permalink
Merge branch 'kyegomez:master' into final
Browse files Browse the repository at this point in the history
  • Loading branch information
harshalmore31 authored Jan 2, 2025
2 parents e94a925 + cd56932 commit 154e751
Show file tree
Hide file tree
Showing 12 changed files with 1,344 additions and 162 deletions.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1918,6 +1918,56 @@ if __name__ == "__main__":

```

---

## MultiAgentRouter

The MultiAgentRouter is a swarm architecture designed to dynamically assign tasks to the most suitable agent. It achieves this through a director or boss entity that utilizes function calls to identify and allocate tasks to the agent best equipped to handle them.

```python
from swarms import Agent
from swarms.structs.multi_agent_orchestrator import MultiAgentRouter

# Example usage:
if __name__ == "__main__":
# Define some example agents
agents = [
Agent(
agent_name="ResearchAgent",
description="Specializes in researching topics and providing detailed, factual information",
system_prompt="You are a research specialist. Provide detailed, well-researched information about any topic, citing sources when possible.",
model_name="openai/gpt-4o",
),
Agent(
agent_name="CodeExpertAgent",
description="Expert in writing, reviewing, and explaining code across multiple programming languages",
system_prompt="You are a coding expert. Write, review, and explain code with a focus on best practices and clean code principles.",
model_name="openai/gpt-4o",
),
Agent(
agent_name="WritingAgent",
description="Skilled in creative and technical writing, content creation, and editing",
system_prompt="You are a writing specialist. Create, edit, and improve written content while maintaining appropriate tone and style.",
model_name="openai/gpt-4o",
),
]

# Initialize routers with different configurations
router_execute = MultiAgentRouter(agents=agents, execute_task=True)

# Example task
task = "Write a Python function to calculate fibonacci numbers"

try:
# Process the task with execution
print("\nWith task execution:")
result_execute = router_execute.route_task(task)
print(result_execute)

except Exception as e:
print(f"Error occurred: {str(e)}")
```


----------

Expand Down
Loading

0 comments on commit 154e751

Please sign in to comment.