Logo

The Enterprise-Grade Production-Ready Multi-Agent Orchestration Framework

Python Version

🐦 Twitter   β€’   πŸ“’ Discord   β€’   Swarms Website   β€’   πŸ“™ Documentation   β€’   Swarms Marketplace

Discord YouTube LinkedIn X.com

GitHub issues GitHub forks GitHub stars GitHub license GitHub star chart Dependency Status Downloads

Share on Twitter Share on Facebook Share on LinkedIn

Share on Reddit Share on Hacker News Share on Pinterest Share on WhatsApp

## ✨ Features | Category | Features | Benefits | |----------|----------|-----------| | 🏒 Enterprise Architecture | β€’ Production-Ready Infrastructure
β€’ High Reliability Systems
β€’ Modular Design
β€’ Comprehensive Logging | β€’ Reduced downtime
β€’ Easier maintenance
β€’ Better debugging
β€’ Enhanced monitoring | | πŸ€– Agent Orchestration | β€’ Hierarchical Swarms
β€’ Parallel Processing
β€’ Sequential Workflows
β€’ Graph-based Workflows
β€’ Dynamic Agent Rearrangement | β€’ Complex task handling
β€’ Improved performance
β€’ Flexible workflows
β€’ Optimized execution | | πŸ”„ Integration Capabilities | β€’ Multi-Model Support
β€’ Custom Agent Creation
β€’ Extensive Tool Library
β€’ Multiple Memory Systems | β€’ Provider flexibility
β€’ Custom solutions
β€’ Extended functionality
β€’ Enhanced memory management | | πŸ“ˆ Scalability | β€’ Concurrent Processing
β€’ Resource Management
β€’ Load Balancing
β€’ Horizontal Scaling | β€’ Higher throughput
β€’ Efficient resource use
β€’ Better performance
β€’ Easy scaling | | πŸ› οΈ Developer Tools | β€’ Simple API
β€’ Extensive Documentation
β€’ Active Community
β€’ CLI Tools | β€’ Faster development
β€’ Easy learning curve
β€’ Community support
β€’ Quick deployment | | πŸ” Security Features | β€’ Error Handling
β€’ Rate Limiting
β€’ Monitoring Integration
β€’ Audit Logging | β€’ Improved reliability
β€’ API protection
β€’ Better monitoring
β€’ Enhanced tracking | | πŸ“Š Advanced Features | β€’ SpreadsheetSwarm
β€’ Group Chat
β€’ Agent Registry
β€’ Mixture of Agents | β€’ Mass agent management
β€’ Collaborative AI
β€’ Centralized control
β€’ Complex solutions | | πŸ”Œ Provider Support | β€’ OpenAI
β€’ Anthropic
β€’ ChromaDB
β€’ Custom Providers | β€’ Provider flexibility
β€’ Storage options
β€’ Custom integration
β€’ Vendor independence | | πŸ’ͺ Production Features | β€’ Automatic Retries
β€’ Async Support
β€’ Environment Management
β€’ Type Safety | β€’ Better reliability
β€’ Improved performance
β€’ Easy configuration
β€’ Safer code | | 🎯 Use Case Support | β€’ Task-Specific Agents
β€’ Custom Workflows
β€’ Industry Solutions
β€’ Extensible Framework | β€’ Quick deployment
β€’ Flexible solutions
β€’ Industry readiness
β€’ Easy customization | ## Install πŸ’» ### Using pip ```bash $ pip3 install -U swarms ``` ### Using uv (Recommended) [uv](https://github.com/astral-sh/uv) is a fast Python package installer and resolver, written in Rust. ```bash # Install uv $ curl -LsSf https://astral.sh/uv/install.sh | sh # Install swarms using uv $ uv pip install swarms ``` ### Using poetry ```bash # Install poetry if you haven't already $ curl -sSL https://install.python-poetry.org | python3 - # Add swarms to your project $ poetry add swarms ``` ### From source ```bash # Clone the repository $ git clone https://github.com/kyegomez/swarms.git $ cd swarms # Install with pip $ pip install -e . ``` --- ## Environment Configuration [Learn more about the environment configuration here](https://docs.swarms.world/en/latest/swarms/install/env/) ``` OPENAI_API_KEY="" WORKSPACE_DIR="agent_workspace" ANTHROPIC_API_KEY="" GROQ_API_KEY="" ``` ### πŸ€– Your First Agent An **Agent** is the fundamental building block of a swarmβ€”an autonomous entity powered by an LLM + Tools + Memory. [Learn more Here](https://docs.swarms.world/en/latest/swarms/structs/agent/) ```python from swarms import Agent # Initialize a new agent agent = Agent( model_name="gpt-4o-mini", # Specify the LLM max_loops=1, # Set the number of interactions interactive=True, # Enable interactive mode for real-time feedback ) # Run the agent with a task agent.run("What are the key benefits of using a multi-agent system?") ``` ### 🀝 Your First Swarm: Multi-Agent Collaboration A **Swarm** consists of multiple agents working together. This simple example creates a two-agent workflow for researching and writing a blog post. [Learn More About SequentialWorkflow](https://docs.swarms.world/en/latest/swarms/structs/sequential_workflow/) ```python from swarms import Agent, SequentialWorkflow # Agent 1: The Researcher researcher = Agent( agent_name="Researcher", system_prompt="Your job is to research the provided topic and provide a detailed summary.", model_name="gpt-4o-mini", ) # Agent 2: The Writer writer = Agent( agent_name="Writer", system_prompt="Your job is to take the research summary and write a beautiful, engaging blog post about it.", model_name="gpt-4o-mini", ) # Create a sequential workflow where the researcher's output feeds into the writer's input workflow = SequentialWorkflow(agents=[researcher, writer]) # Run the workflow on a task final_post = workflow.run("The history and future of artificial intelligence") print(final_post) ``` ----- ## πŸ—οΈ Swarm Architectures for Production Workflows `swarms` provides a variety of powerful, pre-built architectures to orchestrate agents in different ways. Choose the right structure for your specific problem to build efficient and reliable production systems. | **Architecture** | **Description** | **Best For** | |---|---|---| | **SequentialWorkflow** | Agents execute tasks in a linear chain; one agent's output is the next one's input. | Step-by-step processes like data transformation pipelines, report generation. | | **ConcurrentWorkflow** | Agents run tasks simultaneously for maximum efficiency. | High-throughput tasks like batch processing, parallel data analysis. | | **AgentRearrange** | Dynamically maps complex relationships (e.g., `a -> b, c`) between agents. | Flexible and adaptive workflows, task distribution, dynamic routing. | | **GraphWorkflow** | Orchestrates agents as nodes in a Directed Acyclic Graph (DAG). | Complex projects with intricate dependencies, like software builds. | | **MixtureOfAgents (MoA)** | Utilizes multiple expert agents in parallel and synthesizes their outputs. | Complex problem-solving, achieving state-of-the-art performance through collaboration. | | **GroupChat** | Agents collaborate and make decisions through a conversational interface. | Real-time collaborative decision-making, negotiations, brainstorming. | | **ForestSwarm** | Dynamically selects the most suitable agent or tree of agents for a given task. | Task routing, optimizing for expertise, complex decision-making trees. | | **SpreadSheetSwarm**| Manages thousands of agents concurrently, tracking tasks and outputs in a structured format. | Massive-scale parallel operations, large-scale data generation and analysis. | ----- ### SequentialWorkflow A `SequentialWorkflow` executes tasks in a strict order, forming a pipeline where each agent builds upon the work of the previous one. **Description:** Ideal for processes that have clear, ordered steps. This ensures that tasks with dependencies are handled correctly. ```python from swarms import Agent, SequentialWorkflow # Initialize agents for a 3-step process # 1. Generate an idea idea_generator = Agent(agent_name="IdeaGenerator", system_prompt="Generate a unique startup idea.", model_name="gpt-4o-mini") # 2. Validate the idea validator = Agent(agent_name="Validator", system_prompt="Take this startup idea and analyze its market viability.", model_name="gpt-4o-mini") # 3. Create a pitch pitch_creator = Agent(agent_name="PitchCreator", system_prompt="Write a 3-sentence elevator pitch for this validated startup idea.", model_name="gpt-4o-mini") # Create the sequential workflow workflow = SequentialWorkflow(agents=[idea_generator, validator, pitch_creator]) # Run the workflow elevator_pitch = workflow.run() print(elevator_pitch) ``` ----- ### ConcurrentWorkflow (with `SpreadSheetSwarm`) 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. **Description:** Use this for high-throughput tasks that can be performed in parallel, drastically reducing execution time. ```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", ) # 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! ``` ### AgentRearrange Inspired by `einsum`, `AgentRearrange` lets you define complex, non-linear relationships between agents using a simple string-based syntax. [Learn more](https://docs.swarms.world/en/latest/swarms/structs/agent_rearrange/) **Description:** Perfect for orchestrating dynamic workflows where agents might work in parallel, sequence, or a combination of both. ```python from swarms import Agent, AgentRearrange # Define agents researcher = Agent(agent_name="researcher", model_name="gpt-4o-mini") writer = Agent(agent_name="writer", model_name="gpt-4o-mini") editor = Agent(agent_name="editor", model_name="gpt-4o-mini") # Define a flow: researcher sends work to both writer and editor simultaneously # This is a one-to-many relationship flow = "researcher -> writer, editor" # Create the rearrangement system rearrange_system = AgentRearrange( agents=[researcher, writer, editor], flow=flow, ) # Run the system # The researcher will generate content, and then both the writer and editor # will process that content in parallel. outputs = rearrange_system.run("Analyze the impact of AI on modern cinema.") print(outputs) ``` ### GraphWorkflow `GraphWorkflow` orchestrates tasks using a Directed Acyclic Graph (DAG), allowing you to manage complex dependencies where some tasks must wait for others to complete. **Description:** Essential for building sophisticated pipelines, like in software development or complex project management, where task order and dependencies are critical. ```python from swarms import Agent, GraphWorkflow, Node, Edge, NodeType # Define agents and a simple python function as nodes code_generator = Agent(agent_name="CodeGenerator", system_prompt="Write Python code for the given task.", model_name="gpt-4o-mini") code_tester = Agent(agent_name="CodeTester", system_prompt="Test the given Python code and find bugs.", model_name="gpt-4o-mini") # Create nodes for the graph node1 = Node(id="generator", agent=code_generator) node2 = Node(id="tester", agent=code_tester) # Create the graph and define the dependency graph = GraphWorkflow() graph.add_nodes([node1, node2]) graph.add_edge(Edge(source="generator", target="tester")) # Tester runs after generator # Set entry and end points graph.set_entry_points(["generator"]) graph.set_end_points(["tester"]) # Run the graph workflow results = graph.run("Create a function that calculates the factorial of a number.") print(results) ``` ### MixtureOfAgents (MoA) The `MixtureOfAgents` architecture processes tasks by feeding them to multiple "expert" agents in parallel. Their diverse outputs are then synthesized by an aggregator agent to produce a final, high-quality result. **Description:** Use this to achieve state-of-the-art performance on complex reasoning tasks by leveraging the collective intelligence of specialized agents. ```python from swarms import Agent, MixtureOfAgents # Define expert agents financial_analyst = Agent(agent_name="FinancialAnalyst", system_prompt="Analyze financial data.", model_name="gpt-4o-mini") market_analyst = Agent(agent_name="MarketAnalyst", system_prompt="Analyze market trends.", model_name="gpt-4o-mini") risk_analyst = Agent(agent_name="RiskAnalyst", system_prompt="Analyze investment risks.", model_name="gpt-4o-mini") # Define the aggregator agent aggregator = Agent( agent_name="InvestmentAdvisor", system_prompt="Synthesize the financial, market, and risk analyses to provide a final investment recommendation.", model_name="gpt-4o-mini" ) # Create the MoA swarm moa_swarm = MixtureOfAgents( agents=[financial_analyst, market_analyst, risk_analyst], aggregator_agent=aggregator, ) # Run the swarm recommendation = moa_swarm.run("Should we invest in NVIDIA stock right now?") print(recommendation) ``` ### GroupChat `GroupChat` creates a conversational environment where multiple agents can interact, discuss, and collaboratively solve a problem. You can define the speaking order or let it be determined dynamically. **Description:** Ideal for tasks that benefit from debate and multi-perspective reasoning, such as contract negotiation, brainstorming, or complex decision-making. ```python from swarms import Agent, GroupChat # Define agents for a debate tech_optimist = Agent(agent_name="TechOptimist", system_prompt="Argue for the benefits of AI in society.", model_name="gpt-4o-mini") tech_critic = Agent(agent_name="TechCritic", system_prompt="Argue against the unchecked advancement of AI.", model_name="gpt-4o-mini") # Create the group chat chat = GroupChat( agents=[tech_optimist, tech_critic], max_loops=4, # Limit the number of turns in the conversation ) # Run the chat with an initial topic conversation_history = chat.run( "Let's discuss the societal impact of artificial intelligence." ) # Print the full conversation for message in conversation_history: print(f"[{message['agent_name']}]: {message['content']}") ``` --- ## Documentation Documentation is located here at: [docs.swarms.world](https://docs.swarms.world) ----- ## Guides and Walkthroughs Refer to our documentation for production grade implementation details. ## Guides and Walkthroughs Refer to our documentation for production grade implementation details. | Section | Description | Links | |----------------------|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | Installation | Complete setup guide for Swarms in your environment | [Installation](https://docs.swarms.world/en/latest/swarms/install/install/) | | Quickstart | Get up and running with your first swarm in minutes | [Get Started](https://docs.swarms.world/en/latest/swarms/install/quickstart/) | | Agent Internal Mechanisms | Deep dive into how agents work internally | [Agent Architecture](https://docs.swarms.world/en/latest/swarms/framework/agents_explained/) | | Agent API | Complete reference for the Agent class and its methods | [Agent API](https://docs.swarms.world/en/latest/swarms/structs/agent/) | | Integrating External Agents | Connect Swarms with other AI frameworks like Griptape and Autogen | [Integrating External APIs](https://docs.swarms.world/en/latest/swarms/agents/external_party_agents/) | | Creating Agents from YAML | Define and configure agents using YAML configuration files | [Creating Agents from YAML](https://docs.swarms.world/en/latest/swarms/agents/create_agents_yaml/) | | Why You Need Swarms | Understanding the benefits of multi-agent collaboration | [Why Multi-Agent Collaboration is Necessary](https://docs.swarms.world/en/latest/swarms/concept/why/) | | Swarm Architectures Analysis | Comprehensive analysis of different swarm patterns and architectures | [Swarm Architectures](https://docs.swarms.world/en/latest/swarms/concept/swarm_architectures/) | | Choosing the Right Swarm | Guide to selecting the optimal swarm architecture for your specific business needs | [Business Problem Guide](https://docs.swarms.world/en/latest/swarms/concept/swarm_architectures/) | | AgentRearrange Docs | Documentation for dynamic agent rearrangement and workflow optimization | [AgentRearrange API](https://docs.swarms.world/en/latest/swarms/structs/agent_rearrange/) | ------ ## 🫢 Contribute to Swarms Swarms is built by the community, for the community. We believe that collaborative development is the key to pushing the boundaries of what's possible with multi-agent AI. Your contributions are not only welcomeβ€”they are essential to our mission. [Learn more about why you should contribute to swarms](https://docs.swarms.world/en/latest/contributors/main/) ### Why Contribute? By joining us, you have the opportunity to: * πŸš€ **Work on the Frontier of agents:** Shape the future of autonomous agent technology and help build a production-grade, open-source framework. * 🀝 **Join a Vibrant Community:** Collaborate with a passionate and growing group of agent developers, researchers, and AI enthusiasts. * πŸ› οΈ **Make a Tangible Impact:** Whether you're fixing a bug, adding a new feature, or improving documentation, your work will be used in real-world applications. * πŸ“š **Learn and Grow:** Gain hands-on experience with advanced AI concepts and strengthen your software engineering skills. Discover more about our mission and the benefits of becoming a contributor in our official [**Contributor's Guide**](https://docs.swarms.world/en/latest/contributors/main/). ### How to Get Started We've made it easy to start contributing. Here's how you can help: 1. **Find an Issue to Tackle:** The best way to begin is by visiting our [**contributing project board**](https://github.com/users/kyegomez/projects/1). Look for issues tagged with `good first issue`β€”these are specifically selected for new contributors. 2. **Report a Bug or Request a Feature:** Have a new idea or found something that isn't working right? We'd love to hear from you. Please [**file a Bug Report or Feature Request**](https://github.com/kyegomez/swarms/issues) on our GitHub Issues page. 3. **Understand Our Workflow and Standards:** Before submitting your work, please review our complete [**Contribution Guidelines**](https://github.com/kyegomez/swarms/blob/master/CONTRIBUTING.md). To help maintain code quality, we also encourage you to read our guide on [**Code Cleanliness**](https://docs.swarms.world/en/latest/swarms/framework/code_cleanliness/). 4. **Join the Discussion:** To participate in roadmap discussions and connect with other developers, join our community on [**Discord**](https://discord.gg/jM3Z6M9uMq). ### ✨ Our Valued Contributors Thank you for contributing to swarms. Your work is extremely appreciated and recognized. ----- ## Onboarding Session Get onboarded now with the creator and lead maintainer of Swarms, Kye Gomez, who will show you how to get started with the installation, usage examples, and starting to build your custom use case! [CLICK HERE](https://cal.com/swarms/swarms-onboarding-session) ---- ### Connect With Us | Platform | Link | Description | |----------|------|-------------| | πŸ“š Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides | | πŸ“ Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles | | πŸ’¬ Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support | | 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements | | πŸ‘₯ LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates | | πŸ“Ί YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos | | 🎫 Events | [Sign up here](https://lu.ma/5p2jnc2v) | Join our community events | ## Citation If you use **swarms** in your research, please cite the project by referencing the metadata in [CITATION.cff](./CITATION.cff). ```bibtex @misc{SWARMS_2022, author = {Gomez, Kye and Pliny and More, Harshal and Swarms Community}, title = {{Swarms: Production-Grade Multi-Agent Infrastructure Platform}}, year = {2022}, howpublished = {\url{https://github.com/kyegomez/swarms}}, note = {Documentation available at \url{https://docs.swarms.world}}, version = {latest} } ``` # License APACHE