readme with concurrent example

pull/970/merge
Kye Gomez 5 days ago
parent 58bf7853a9
commit aecf5ad2a2

@ -224,7 +224,7 @@ print(final_post)
| **[MixtureOfAgents (MoA)](https://docs.swarms.world/en/latest/swarms/structs/moa/)** | Utilizes multiple expert agents in parallel and synthesizes their outputs. | Complex problem-solving, achieving state-of-the-art performance through collaboration. | | **[MixtureOfAgents (MoA)](https://docs.swarms.world/en/latest/swarms/structs/moa/)** | Utilizes multiple expert agents in parallel and synthesizes their outputs. | Complex problem-solving, achieving state-of-the-art performance through collaboration. |
| **[GroupChat](https://docs.swarms.world/en/latest/swarms/structs/group_chat/)** | Agents collaborate and make decisions through a conversational interface. | Real-time collaborative decision-making, negotiations, brainstorming. | | **[GroupChat](https://docs.swarms.world/en/latest/swarms/structs/group_chat/)** | Agents collaborate and make decisions through a conversational interface. | Real-time collaborative decision-making, negotiations, brainstorming. |
| **[ForestSwarm](https://docs.swarms.world/en/latest/swarms/structs/forest_swarm/)** | Dynamically selects the most suitable agent or tree of agents for a given task. | Task routing, optimizing for expertise, complex decision-making trees. | | **[ForestSwarm](https://docs.swarms.world/en/latest/swarms/structs/forest_swarm/)** | Dynamically selects the most suitable agent or tree of agents for a given task. | Task routing, optimizing for expertise, complex decision-making trees. |
| **[SpreadSheetSwarm](https://docs.swarms.world/en/latest/swarms/structs/spreadsheet_swarm/)** | Manages thousands of agents concurrently, tracking tasks and outputs in a structured format. | Massive-scale parallel operations, large-scale data generation and analysis. |
| **[HierarchicalSwarm](https://docs.swarms.world/en/latest/swarms/structs/hiearchical_swarm/)** | Orchestrates agents with a director that creates plans and distributes tasks to specialized worker agents. | Complex project management, team coordination, hierarchical decision-making with feedback loops. | | **[HierarchicalSwarm](https://docs.swarms.world/en/latest/swarms/structs/hiearchical_swarm/)** | Orchestrates agents with a director that creates plans and distributes tasks to specialized worker agents. | Complex project management, team coordination, hierarchical decision-making with feedback loops. |
| **[HeavySwarm](https://docs.swarms.world/en/latest/swarms/structs/heavy_swarm/)** | Implements a 5-phase workflow with specialized agents (Research, Analysis, Alternatives, Verification) for comprehensive task analysis. | Complex research and analysis tasks, financial analysis, strategic planning, comprehensive reporting. | | **[HeavySwarm](https://docs.swarms.world/en/latest/swarms/structs/heavy_swarm/)** | Implements a 5-phase workflow with specialized agents (Research, Analysis, Alternatives, Verification) for comprehensive task analysis. | Complex research and analysis tasks, financial analysis, strategic planning, comprehensive reporting. |
| **[SwarmRouter](https://docs.swarms.world/en/latest/swarms/structs/swarm_router/)** | Universal orchestrator that provides a single interface to run any type of swarm with dynamic selection. | Simplifying complex workflows, switching between swarm strategies, unified multi-agent management. | | **[SwarmRouter](https://docs.swarms.world/en/latest/swarms/structs/swarm_router/)** | Universal orchestrator that provides a single interface to run any type of swarm with dynamic selection. | Simplifying complex workflows, switching between swarm strategies, unified multi-agent management. |
@ -263,37 +263,49 @@ print(final_post)
----- -----
### ConcurrentWorkflow (with `SpreadSheetSwarm`) ### ConcurrentWorkflow
A concurrent workflow runs multiple agents simultaneously. `SpreadSheetSwarm` is a powerful implementation that can manage thousands of concurrent agents and log their outputs to a CSV file. Use this architecture for high-throughput tasks that can be performed in parallel, drastically reducing execution time. A `ConcurrentWorkflow` runs multiple agents simultaneously, allowing for parallel execution of tasks. This architecture drastically reduces execution time for tasks that can be performed in parallel, making it ideal for high-throughput scenarios where agents work on similar tasks concurrently.
```python ```python
from swarms import Agent, SpreadSheetSwarm from swarms import Agent, ConcurrentWorkflow
# Define a list of tasks (e.g., social media posts to generate) # Create agents for different analysis tasks
platforms = ["Twitter", "LinkedIn", "Instagram"] market_analyst = Agent(
agent_name="Market-Analyst",
# Create an agent for each task system_prompt="Analyze market trends and provide insights on the given topic.",
agents = [ model_name="gpt-4o-mini",
Agent( max_loops=1,
agent_name=f"{platform}-Marketer", )
system_prompt=f"Generate a real estate marketing post for {platform}.",
model_name="gpt-4o-mini", financial_analyst = Agent(
) agent_name="Financial-Analyst",
for platform in platforms system_prompt="Provide financial analysis and recommendations on the given topic.",
] model_name="gpt-4o-mini",
max_loops=1,
# Initialize the swarm to run these agents concurrently )
swarm = SpreadSheetSwarm(
agents=agents, risk_analyst = Agent(
autosave_on=True, agent_name="Risk-Analyst",
save_file_path="marketing_posts.csv", system_prompt="Assess risks and provide risk management strategies for the given topic.",
model_name="gpt-4o-mini",
max_loops=1,
)
# Create concurrent workflow
concurrent_workflow = ConcurrentWorkflow(
agents=[market_analyst, financial_analyst, risk_analyst],
max_loops=1,
)
# Run all agents concurrently on the same task
results = concurrent_workflow.run(
"Analyze the potential impact of AI technology on the healthcare industry"
) )
# Run the swarm with a single, shared task description # Each agent's output is available in the results
property_description = "A beautiful 3-bedroom house in sunny California." for agent_name, output in results.items():
swarm.run(task=f"Generate a post about: {property_description}") print(f"{agent_name}: {output}")
# Check marketing_posts.csv for the results!
``` ```
--- ---

Loading…
Cancel
Save