From aecf5ad2a2e8660ba7ef825a674259699ad2bd0d Mon Sep 17 00:00:00 2001 From: Kye Gomez Date: Tue, 22 Jul 2025 10:14:56 -0700 Subject: [PATCH] readme with concurrent example --- README.md | 66 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index f293622a..582cba8b 100644 --- a/README.md +++ b/README.md @@ -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. | | **[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. | -| **[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. | | **[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. | @@ -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 -from swarms import Agent, SpreadSheetSwarm - -# Define a list of tasks (e.g., social media posts to generate) -platforms = ["Twitter", "LinkedIn", "Instagram"] - -# Create an agent for each task -agents = [ - Agent( - agent_name=f"{platform}-Marketer", - system_prompt=f"Generate a real estate marketing post for {platform}.", - model_name="gpt-4o-mini", - ) - for platform in platforms -] - -# Initialize the swarm to run these agents concurrently -swarm = SpreadSheetSwarm( - agents=agents, - autosave_on=True, - save_file_path="marketing_posts.csv", +from swarms import Agent, ConcurrentWorkflow + +# Create agents for different analysis tasks +market_analyst = Agent( + agent_name="Market-Analyst", + system_prompt="Analyze market trends and provide insights on the given topic.", + model_name="gpt-4o-mini", + max_loops=1, +) + +financial_analyst = Agent( + agent_name="Financial-Analyst", + system_prompt="Provide financial analysis and recommendations on the given topic.", + model_name="gpt-4o-mini", + max_loops=1, +) + +risk_analyst = Agent( + agent_name="Risk-Analyst", + 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 -property_description = "A beautiful 3-bedroom house in sunny California." -swarm.run(task=f"Generate a post about: {property_description}") -# Check marketing_posts.csv for the results! +# Each agent's output is available in the results +for agent_name, output in results.items(): + print(f"{agent_name}: {output}") ``` ---