|
|
|
@ -61,32 +61,6 @@ flowchart LR
|
|
|
|
|
|
|
|
|
|
|
|
- Maintains strict ordering of task processing
|
|
|
|
- Maintains strict ordering of task processing
|
|
|
|
|
|
|
|
|
|
|
|
### Linear Swarm
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
|
|
|
def linear_swarm(agents: AgentListType, tasks: List[str], return_full_history: bool = True)
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**Information Flow:**
|
|
|
|
|
|
|
|
```mermaid
|
|
|
|
|
|
|
|
flowchart LR
|
|
|
|
|
|
|
|
Input[Task Input] --> A1
|
|
|
|
|
|
|
|
subgraph Sequential Processing
|
|
|
|
|
|
|
|
A1((Agent 1)) --> A2((Agent 2))
|
|
|
|
|
|
|
|
A2 --> A3((Agent 3))
|
|
|
|
|
|
|
|
A3 --> A4((Agent 4))
|
|
|
|
|
|
|
|
A4 --> A5((Agent 5))
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
A5 --> Output[Final Result]
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**Best Used When:**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- Tasks need sequential, pipeline-style processing
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- Each agent performs a specific transformation step
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- Order of processing is critical
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Star Swarm
|
|
|
|
### Star Swarm
|
|
|
|
```python
|
|
|
|
```python
|
|
|
|
def star_swarm(agents: AgentListType, tasks: List[str], return_full_history: bool = True)
|
|
|
|
def star_swarm(agents: AgentListType, tasks: List[str], return_full_history: bool = True)
|
|
|
|
@ -351,7 +325,6 @@ from swarms.structs.swarming_architectures import (
|
|
|
|
exponential_swarm,
|
|
|
|
exponential_swarm,
|
|
|
|
fibonacci_swarm,
|
|
|
|
fibonacci_swarm,
|
|
|
|
grid_swarm,
|
|
|
|
grid_swarm,
|
|
|
|
linear_swarm,
|
|
|
|
|
|
|
|
mesh_swarm,
|
|
|
|
mesh_swarm,
|
|
|
|
one_to_three,
|
|
|
|
one_to_three,
|
|
|
|
prime_swarm,
|
|
|
|
prime_swarm,
|
|
|
|
@ -459,29 +432,6 @@ def run_healthcare_grid_swarm():
|
|
|
|
print("\nGrid swarm processing completed")
|
|
|
|
print("\nGrid swarm processing completed")
|
|
|
|
print(result)
|
|
|
|
print(result)
|
|
|
|
|
|
|
|
|
|
|
|
def run_finance_linear_swarm():
|
|
|
|
|
|
|
|
"""Loan approval process using linear swarm"""
|
|
|
|
|
|
|
|
print_separator()
|
|
|
|
|
|
|
|
print("FINANCE - LOAN APPROVAL PROCESS (Linear Swarm)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
agents = create_finance_agents()[:3]
|
|
|
|
|
|
|
|
tasks = [
|
|
|
|
|
|
|
|
"Review loan application and credit history",
|
|
|
|
|
|
|
|
"Assess risk factors and compliance requirements",
|
|
|
|
|
|
|
|
"Generate final loan recommendation"
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("\nTasks:")
|
|
|
|
|
|
|
|
for i, task in enumerate(tasks, 1):
|
|
|
|
|
|
|
|
print(f"{i}. {task}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = linear_swarm(agents, tasks)
|
|
|
|
|
|
|
|
print("\nResults:")
|
|
|
|
|
|
|
|
for log in result['history']:
|
|
|
|
|
|
|
|
print(f"\n{log['agent_name']}:")
|
|
|
|
|
|
|
|
print(f"Task: {log['task']}")
|
|
|
|
|
|
|
|
print(f"Response: {log['response']}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_healthcare_star_swarm():
|
|
|
|
def run_healthcare_star_swarm():
|
|
|
|
"""Complex medical case management using star swarm"""
|
|
|
|
"""Complex medical case management using star swarm"""
|
|
|
|
print_separator()
|
|
|
|
print_separator()
|
|
|
|
@ -615,7 +565,6 @@ async def run_all_examples():
|
|
|
|
|
|
|
|
|
|
|
|
# Finance examples
|
|
|
|
# Finance examples
|
|
|
|
run_finance_circular_swarm()
|
|
|
|
run_finance_circular_swarm()
|
|
|
|
run_finance_linear_swarm()
|
|
|
|
|
|
|
|
run_finance_mesh_swarm()
|
|
|
|
run_finance_mesh_swarm()
|
|
|
|
run_mathematical_finance_swarms()
|
|
|
|
run_mathematical_finance_swarms()
|
|
|
|
|
|
|
|
|
|
|
|
|