@ -107,25 +107,6 @@ Main class for routing tasks to different swarm types.
| `concurrent_run` | `task: str, *args, **kwargs` | Execute a task using concurrent execution |
| `concurrent_batch_run` | `tasks: List[str], *args, **kwargs` | Execute multiple tasks concurrently |
## Function: swarm_router
A convenience function to create and run a SwarmRouter instance.
| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `name` | str | "swarm-router" | Name of the swarm router. |
| `description` | str | "Routes your task to the desired swarm" | Description of the router. |
| `max_loops` | int | 1 | Maximum number of execution loops. |
| `agents` | List[Union[Agent, Callable]] | [] | List of agents or callables. |
| `swarm_type` | SwarmType | "SequentialWorkflow" | Type of swarm to use. |
| `autosave` | bool | False | Whether to autosave results. |
| `flow` | str | None | Flow configuration. |
| `return_json` | bool | True | Whether to return results as JSON. |
| `auto_generate_prompts` | bool | False | Whether to auto-generate prompts. |
| `task` | str | None | Task to execute. |
| `rules` | str | None | Rules to inject into every agent. |
| `*args` | | | Additional positional arguments passed to SwarmRouter.run() |
| `**kwargs` | | | Additional keyword arguments passed to SwarmRouter.run() |
## Installation
@ -564,184 +545,3 @@ result = swarm_router(
task="Analyze the quarterly report"
)
```
I'll help you create tables for each section while maintaining their titles. I'll convert the bullet points into organized tables.
## Best Practices
**1. Choose the Right Swarm Type**
| Swarm Type | Use Case |
|------------|----------|
| `SequentialWorkflow` | Tasks that need to be executed in order |
| `ConcurrentWorkflow` | Independent tasks that can run in parallel |
| `MALT` | Complex language processing tasks |
| `DeepResearchSwarm` | Comprehensive research tasks |
| `CouncilAsAJudge` | Consensus-based decision making |
| `auto` | When unsure which swarm type is best |
**2. Configure Multi-Agent Collaboration**
| Feature | Purpose |
|---------|----------|
| `multi_agent_collab_prompt` | Enable better agent cooperation |
| `GroupChat` swarm type | Interactive agent discussions |
| Shared memory | Share context between agents |
**3. Optimize Performance**
| Feature | Purpose |
|---------|----------|
| `output_type` | Set appropriate output format |
| `autosave` | Enable for long-running tasks |
| `concurrent_batch_run` | Process multiple independent tasks |
| `max_loops` | Set reasonable limits to prevent infinite loops |
**4. Error Handling and Logging**
| Feature | Purpose |
|---------|----------|
| `get_logs()` | Regular log checking |
| Error handling | Proper application error management |
| `reliability_check` | Verify system reliability |
**5. Agent Configuration**
| Feature | Purpose |
|---------|----------|
| System prompts | Provide clear and specific instructions |
| Model settings | Configure appropriate temperature and parameters |
| CSV loading | Manage large agent sets efficiently |
**6. Resource Management**
| Feature | Purpose |
|---------|----------|
| `no_cluster_ops` | Work with limited resources |
| Background tasks | Handle long-running operations |
| Resource cleanup | Proper cleanup and release |
**7. Security and Rules**
| Feature | Purpose |
|---------|----------|
| `rules` | Enforce agent behavior constraints |
| Authentication | Implement proper API security |
| Input validation | Sanitize and validate inputs |
**8. Monitoring and Debugging**
| Feature | Purpose |
|---------|----------|
| Logging system | Effective system monitoring |
| Performance monitoring | Track swarm performance |
| Error reporting | Implement proper error tracking |
**9. Scalability**
| Feature | Purpose |
|---------|----------|
| Horizontal scaling | Design for system expansion |
| Batch sizes | Configure appropriate concurrent operations |
| Resource limitations | Consider system constraints |
**10. Documentation and Maintenance**
| Feature | Purpose |
|---------|----------|
| Custom configurations | Document system extensions |
| Performance metrics | Track swarm performance |
| Agent prompts | Regular updates of prompts and rules |
## Common Use Cases
**1. Document Analysis**
| Component | Purpose |
|-----------|----------|
| `DeepResearchSwarm` | Comprehensive document analysis |
| `MALT` | Complex language processing |
| `SequentialWorkflow` | Structured document processing |
**2. Decision Making**
| Component | Purpose |
|-----------|----------|
| `CouncilAsAJudge` | Consensus-based decisions |
| `MajorityVoting` | Democratic decision making |
| `GroupChat` | Interactive decision processes |
**3. Research and Analysis**
| Component | Purpose |
|-----------|----------|
| `DeepResearchSwarm` | Deep research tasks |
| `MixtureOfAgents` | Combine multiple expert agents |
| `HiearchicalSwarm` | Organized research workflows |
**4. Data Processing**
| Component | Purpose |
|-----------|----------|
| `ConcurrentWorkflow` | Parallel data processing |
| `SpreadSheetSwarm` | Structured data operations |
| `SequentialWorkflow` | Ordered data transformations |
**5. Collaborative Tasks**
| Feature | Purpose |
|---------|----------|
| `multi_agent_collab_prompt` | Better cooperation |
| `GroupChat` | Interactive collaboration |
| Shared memory | Context sharing |
## Troubleshooting
**1. Common Issues**
| Area | Action |
|------|---------|
| Agent configurations | Check configurations and prompts |
| Swarm type | Verify compatibility with task |
| Resource usage | Monitor limitations |
**2. Performance Issues**
| Area | Action |
|------|---------|
| Operations | Optimize batch sizes and concurrent operations |
| Memory | Check for leaks and resource cleanup |
| System resources | Monitor scaling |
**3. Integration Issues**
| Area | Action |
|------|---------|
| API configurations | Verify settings and authentication |
| External services | Check compatibility |
| Network | Monitor connectivity and timeouts |
## Future Development
**1. Planned Features**
| Feature | Description |
|---------|-------------|
| Swarm types | Additional specialized tasks |
| Collaboration | Enhanced mechanisms |
| Performance | Improved optimizations |
**2. Contributing**
| Area | Action |
|------|---------|
| Guidelines | Follow contribution rules |
| Bug reports | Submit issues and requests |
| Community | Participate in discussions |
**3. Roadmap**
| Feature | Description |
|---------|-------------|
| AI models | Integration with more models |
| Tools | Enhanced monitoring and debugging |
| Performance | Improved scalability |