diff --git a/README.md b/README.md index ad61b3aee..6196c2d9e 100644 --- a/README.md +++ b/README.md @@ -597,9 +597,11 @@ Inspired by Einops and einsum, this orchestration techniques enables you to map ```python -from swarms import Agent, AgentRearrange, Anthropic +from swarms import Agent, AgentRearrange +from swarm_models import Anthropic + # Initialize the director agent director = Agent( diff --git a/docs/swarms/concept/framework_architecture 2.md b/docs/swarms/concept/framework_architecture 2.md deleted file mode 100644 index 8d82aebcf..000000000 --- a/docs/swarms/concept/framework_architecture 2.md +++ /dev/null @@ -1,159 +0,0 @@ -# Swarms Framework Architecture - - -The Swarms package is designed to orchestrate and manage **swarms of agents**, enabling collaboration between multiple Large Language Models (LLMs) or other agent types to solve complex tasks. The architecture is modular and scalable, facilitating seamless integration of various agents, models, prompts, and tools. Below is an overview of the architectural components, along with instructions on where to find the corresponding documentation. - - - -``` -swarms/ -├── agents/ -├── artifacts/ -├── cli/ -├── memory/ -├── models/ -├── prompts/ -├── schemas/ -├── structs/ -├── telemetry/ -├── tools/ -├── utils/ -└── __init__.py -``` - - - -### Role of Folders in the Swarms Framework - -The **Swarms framework** is composed of several key folders, each serving a specific role in building, orchestrating, and managing swarms of agents. Below is an in-depth explanation of the role of each folder in the framework's architecture, focusing on how they contribute to the overall system for handling complex multi-agent workflows. - ---- - -### **1. Agents Folder (`agents/`)** - - **Role:** - - The **agents** folder contains the core logic for individual agents within the Swarms framework. Agents are the key functional units responsible for carrying out specific tasks, whether it be text generation, web scraping, data analysis, or more specialized functions like marketing or accounting. - - **Customization:** Each agent can be specialized for different tasks by defining custom system prompts and behaviors. - - **Modular Agent System:** New agents can be easily added to this folder to expand the framework's capabilities. - - **Importance:** This folder allows users to create and manage multiple types of agents that can interact and collaborate to solve complex problems. - - **Examples:** Accounting agents, marketing agents, and programming agents. - ---- - -### **2. Artifacts Folder (`artifacts/`)** - - **Role:** - - The **artifacts** folder is responsible for storing the results or outputs generated by agents and swarms. This could include reports, logs, or data that agents generate during task execution. - - **Persistent Storage:** It helps maintain a persistent record of agent interactions, making it easier to retrieve or review past actions and outputs. - - **Data Handling:** Users can configure this folder to store artifacts that are essential for later analysis or reporting. - - **Importance:** Acts as a storage mechanism for important task-related outputs, ensuring that no data is lost after tasks are completed. - ---- - -### **3. CLI Folder (`cli/`)** - - **Role:** - - The **CLI** folder contains tools for interacting with the Swarms framework through the command-line interface. This allows users to easily manage and orchestrate swarms without needing a graphical interface. - - **Command-line Tools:** Commands in this folder enable users to initiate, control, and monitor swarms, making the system accessible and versatile. - - **Automation and Scriptability:** Enables advanced users to automate swarm interactions and deploy agents programmatically. - - **Importance:** Provides a flexible way to control the Swarms system for developers who prefer using the command line. - ---- - -### **4. Memory Folder (`memory/`) Depcriated!!** - - **Role:** - - The **memory** folder handles the framework's memory management for agents. This allows agents to retain and recall past interactions or task contexts, enabling continuity in long-running processes or multi-step workflows. - - **Context Retention:** Agents that depend on historical context to make decisions or carry out tasks can store and access memory using this folder. - - **Long-Term and Short-Term Memory:** This could be implemented in various ways, such as short-term conversational memory or long-term knowledge storage. - - **Importance:** Crucial for agents that require memory to handle complex workflows, where decisions are based on prior outputs or interactions. - ---- - -### **5. Models Folder (`models/`)** - - **Role:** - - The **models** folder houses pre-trained machine learning models that agents utilize to complete their tasks. These models could include LLMs (Large Language Models), custom-trained models, or fine-tuned models specific to the tasks being handled by the agents. - - **Plug-and-Play Architecture:** The framework allows users to easily add or switch models depending on the specific needs of their agents. - - **Custom Model Support:** Users can integrate custom models here for more specialized tasks. - - **Importance:** Provides the computational backbone for agent decision-making and task execution. - ---- - -### **6. Prompts Folder (`prompts/`)** - - **Role:** - - The **prompts** folder contains reusable prompt templates that agents use to interact with their environment and complete tasks. These system prompts define the behavior and task orientation of the agents. - - **Template Reusability:** Users can create and store common prompt templates, making it easy to define agent behavior across different tasks without rewriting prompts from scratch. - - **Task-Specific Prompts:** For example, an accounting agent may have a prompt template that guides its interaction with financial data. - - **Importance:** Provides the logic and guidance agents need to generate outputs in a coherent and task-focused manner. - ---- - -### **7. Schemas Folder (`schemas/`)** - - **Role:** - - The **schemas** folder defines the data structures and validation logic for inputs and outputs within the framework, using tools like **Pydantic** for data validation. - - **Standardization and Validation:** This ensures that all interactions between agents and swarms follow consistent data formats, which is critical for large-scale agent coordination and task management. - - **Error Prevention:** By validating data early, it prevents errors from propagating through the system, improving reliability. - - **Importance:** Ensures data consistency across the entire framework, making it easier to integrate and manage swarms of agents at scale. - ---- - -### **8. Structs Folder (`structs/`)** - - **Role:** - - The **structs** folder is the core of the Swarms framework, housing the orchestration logic for managing and coordinating swarms of agents. This folder allows for dynamic task assignment, queue management, inter-agent communication, and result aggregation. - - **Swarm Management:** Agents are grouped into swarms to handle tasks that require multiple agents working in parallel or collaboratively. - - **Scalability:** The swarm structure is designed to be scalable, allowing thousands of agents to operate together on distributed tasks. - - **Task Queueing and Execution:** Supports task queueing, task prioritization, and load balancing between agents. - - **Importance:** This folder is critical for managing how agents interact and collaborate to solve complex, multi-step problems. - ---- - -### **9. Telemetry Folder (`telemetry/`)** - - **Role:** - - The **telemetry** folder provides logging and monitoring tools to capture agent performance metrics, error handling, and real-time activity tracking. It helps users keep track of what each agent or swarm is doing, making it easier to debug, audit, and optimize operations. - - **Monitoring:** Tracks agent performance and system health. - - **Logs:** Maintains logs for troubleshooting and operational review. - - **Importance:** Provides visibility into the system, ensuring smooth operation and enabling fine-tuning of agent behaviors. - ---- - -### **10. Tools Folder (`tools/`)** - - **Role:** - - The **tools** folder contains specialized utility functions or scripts that agents and swarms may require to complete certain tasks, such as web scraping, API interactions, data parsing, or other external resource handling. - - **Task-Specific Tools:** Agents can call these tools to perform operations outside of their own logic, enabling them to interact with external systems more efficiently. - - **Importance:** Expands the capabilities of agents, allowing them to complete more sophisticated tasks by relying on these external tools. - ---- - -### **11. Utils Folder (`utils/`)** - - **Role:** - - The **utils** folder contains general-purpose utility functions that are reused throughout the framework. These may include functions for data formatting, validation, logging setup, and configuration management. - - **Shared Utilities:** Helps keep the codebase clean by providing reusable functions that multiple agents or parts of the framework can call. - - **Importance:** Provides common functions that help the Swarms framework operate efficiently and consistently. - ---- - -### **Core Initialization File (`__init__.py`)** - - **Role:** - - The `__init__.py` file is the entry point of the Swarms package, ensuring that all necessary modules, agents, and tools are loaded when the Swarms framework is imported. It allows for the modular loading of different components, making it easier for users to work with only the parts of the framework they need. - - **Importance:** Acts as the bridge that connects all other components in the framework, enabling the entire package to work together seamlessly. - ---- - -### How to Access Documentation - -- **Official Documentation Site:** - - URL: [docs.swarms.world](https://docs.swarms.world) - - Here, users can find detailed guides, tutorials, and API references on how to use each of the folders mentioned above. The documentation covers setup, agent orchestration, and practical examples of how to leverage swarms for real-world tasks. - -- **GitHub Repository:** - - URL: [Swarms GitHub](https://github.com/kyegomez/swarms) - - The repository contains code examples, detailed folder explanations, and further resources on how to get started with building and managing agent swarms. - -By understanding the purpose and role of each folder in the Swarms framework, users can more effectively build, orchestrate, and manage agents to handle complex tasks and workflows at scale. - -## Support: - -- **Post Issue On Github** - - URL: [Submit issue](https://github.com/kyegomez/swarms/issues/new/choose) - - Post your issue whether it's an issue or a feature request - - -- **Community Support** - - URL: [Submit issue](https://discord.gg/agora-999382051935506503) - - Ask the community for support in real-time and or admin support \ No newline at end of file diff --git a/docs/swarms/concept/future_swarm_architectures 2.md b/docs/swarms/concept/future_swarm_architectures 2.md deleted file mode 100644 index 095cbd684..000000000 --- a/docs/swarms/concept/future_swarm_architectures 2.md +++ /dev/null @@ -1,122 +0,0 @@ - - ---- - -### Federated Swarm - -**Overview:** -A Federated Swarm architecture involves multiple independent swarms collaborating to complete a task. Each swarm operates autonomously but can share information and results with other swarms. - -**Use-Cases:** -- Distributed learning systems where data is processed across multiple nodes. - -- Scenarios requiring collaboration between different teams or departments. - -```mermaid -graph TD - A[Central Coordinator] - subgraph Swarm1 - B1[Agent 1.1] --> B2[Agent 1.2] - B2 --> B3[Agent 1.3] - end - subgraph Swarm2 - C1[Agent 2.1] --> C2[Agent 2.2] - C2 --> C3[Agent 2.3] - end - subgraph Swarm3 - D1[Agent 3.1] --> D2[Agent 3.2] - D2 --> D3[Agent 3.3] - end - B1 --> A - C1 --> A - D1 --> A -``` - ---- - -### Star Swarm - -**Overview:** -A Star Swarm architecture features a central agent that coordinates the activities of several peripheral agents. The central agent assigns tasks to the peripheral agents and aggregates their results. - -**Use-Cases:** -- Centralized decision-making processes. - -- Scenarios requiring a central authority to coordinate multiple workers. - -```mermaid -graph TD - A[Central Agent] --> B1[Peripheral Agent 1] - A --> B2[Peripheral Agent 2] - A --> B3[Peripheral Agent 3] - A --> B4[Peripheral Agent 4] -``` - ---- - -### Mesh Swarm - -**Overview:** -A Mesh Swarm architecture allows for a fully connected network of agents where each agent can communicate with any other agent. This setup provides high flexibility and redundancy. - -**Use-Cases:** -- Complex systems requiring high fault tolerance and redundancy. - -- Scenarios involving dynamic and frequent communication between agents. - -```mermaid -graph TD - A1[Agent 1] --> A2[Agent 2] - A1 --> A3[Agent 3] - A1 --> A4[Agent 4] - A2 --> A3 - A2 --> A4 - A3 --> A4 -``` - ---- - -### Cascade Swarm - -**Overview:** -A Cascade Swarm architecture involves a chain of agents where each agent triggers the next one in a cascade effect. This is useful for scenarios where tasks need to be processed in stages, and each stage initiates the next. - -**Use-Cases:** -- Multi-stage processing tasks such as data transformation pipelines. - -- Event-driven architectures where one event triggers subsequent actions. - -```mermaid -graph TD - A[Trigger Agent] --> B[Agent 1] - B --> C[Agent 2] - C --> D[Agent 3] - D --> E[Agent 4] -``` - ---- - -### Hybrid Swarm - -**Overview:** -A Hybrid Swarm architecture combines elements of various architectures to suit specific needs. It might integrate hierarchical and parallel components, or mix sequential and round robin patterns. - -**Use-Cases:** -- Complex workflows requiring a mix of different processing strategies. - -- Custom scenarios tailored to specific operational requirements. - -```mermaid -graph TD - A[Root Agent] --> B1[Sub-Agent 1] - A --> B2[Sub-Agent 2] - B1 --> C1[Parallel Agent 1] - B1 --> C2[Parallel Agent 2] - B2 --> C3[Sequential Agent 1] - C3 --> C4[Sequential Agent 2] - C3 --> C5[Sequential Agent 3] -``` - ---- - -These swarm architectures provide different models for organizing and orchestrating large language models (LLMs) to perform various tasks efficiently. Depending on the specific requirements of your project, you can choose the appropriate architecture or even combine elements from multiple architectures to create a hybrid solution. \ No newline at end of file diff --git a/docs/swarms/concept/how_to_choose_swarms 2.md b/docs/swarms/concept/how_to_choose_swarms 2.md deleted file mode 100644 index dc1415ca4..000000000 --- a/docs/swarms/concept/how_to_choose_swarms 2.md +++ /dev/null @@ -1,137 +0,0 @@ -# Choosing the Right Swarm for Your Business Problem - -`AgentRearrange` provides various swarm structures designed to fit specific business needs. Depending on the complexity and nature of your problem, different swarm configurations can be more effective in achieving optimal performance. This guide provides a detailed explanation of when to use each swarm type, including their strengths and potential drawbacks. - -## Swarm Types Overview - -- **MajorityVoting**: A swarm structure where agents vote on an outcome, and the majority decision is taken as the final result. -- **AgentRearrange**: Provides the foundation for both sequential and parallel swarms. -- **RoundRobin**: Agents take turns handling tasks in a cyclic manner. -- **Mixture of Agents**: A heterogeneous swarm where agents with different capabilities are combined. -- **GraphWorkflow**: Agents collaborate in a directed acyclic graph (DAG) format. -- **GroupChat**: Agents engage in a chat-like interaction to reach decisions. -- **AgentRegistry**: A centralized registry where agents are stored, retrieved, and invoked. -- **SpreadsheetSwarm**: A swarm designed to manage tasks at scale, tracking agent outputs in a structured format (e.g., CSV files). - ---- - -## MajorityVoting Swarm - -### Use-Case -MajorityVoting is ideal for scenarios where accuracy is paramount, and the decision must be determined from multiple perspectives. For instance, choosing the best marketing strategy where various marketing agents vote on the highest predicted performance. - -### Advantages -- Ensures robustness in decision-making by leveraging multiple agents. -- Helps eliminate outliers or faulty agent decisions. - -### Warnings -!!! warning - Majority voting can be slow if too many agents are involved. Ensure that your swarm size is manageable for real-time decision-making. - ---- - -## AgentRearrange (Sequential and Parallel) - -### Sequential Swarm Use-Case -For linear workflows where each task depends on the outcome of the previous task, such as processing legal documents step by step through a series of checks and validations. - -### Parallel Swarm Use-Case -For tasks that can be executed concurrently, such as batch processing customer data in marketing campaigns. Parallel swarms can significantly reduce processing time by dividing tasks across multiple agents. - -### Notes -!!! note - Sequential swarms are slower but ensure strict task dependencies are respected. Parallel swarms are faster but require careful management of task interdependencies. - ---- - -## RoundRobin Swarm - -### Use-Case -For balanced task distribution where agents need to handle tasks evenly. An example would be assigning customer support tickets to agents in a cyclic manner, ensuring no single agent is overloaded. - -### Advantages -- Fair and even distribution of tasks. -- Simple and effective for balanced workloads. - -### Warnings -!!! warning - Round-robin may not be the best choice when some agents are more competent than others, as it can assign tasks equally regardless of agent performance. - ---- - -## Mixture of Agents - -### Use-Case -Ideal for complex problems that require diverse skills. For example, a financial forecasting problem where some agents specialize in stock data, while others handle economic factors. - -### Notes -!!! note - A mixture of agents is highly flexible and can adapt to various problem domains. However, be mindful of coordination overhead. - ---- - -## GraphWorkflow Swarm - -### Use-Case -This swarm structure is suited for tasks that can be broken down into a series of dependencies but are not strictly linear, such as an AI-driven software development pipeline where one agent handles front-end development while another handles back-end concurrently. - -### Advantages -- Provides flexibility for managing dependencies. -- Agents can work on different parts of the problem simultaneously. - -### Warnings -!!! warning - GraphWorkflow requires clear definition of task dependencies, or it can lead to execution issues and delays. - ---- - -## GroupChat Swarm - -### Use-Case -For real-time collaborative decision-making. For instance, agents could participate in group chat for negotiating contracts, each contributing their expertise and adjusting responses based on the collective discussion. - -### Advantages -- Facilitates highly interactive problem-solving. -- Ideal for dynamic and unstructured problems. - -### Warnings -!!! warning - High communication overhead between agents may slow down decision-making in large swarms. - ---- - -## AgentRegistry Swarm - -### Use-Case -For dynamically managing agents based on the problem domain. An AgentRegistry is useful when new agents can be added or removed as needed, such as adding new machine learning models for an evolving recommendation engine. - -### Notes -!!! note - AgentRegistry is a flexible solution but introduces additional complexity when agents need to be discovered and registered on the fly. - ---- - -## SpreadsheetSwarm - -### Use-Case -When dealing with massive-scale data or agent outputs that need to be stored and managed in a tabular format. SpreadsheetSwarm is ideal for businesses handling thousands of agent outputs, such as large-scale marketing analytics or financial audits. - -### Advantages -- Provides structure and order for managing massive amounts of agent outputs. -- Outputs are easily saved and tracked in CSV files. - -### Warnings -!!! warning - Ensure the correct configuration of agents in SpreadsheetSwarm to avoid data mismatches and inconsistencies when scaling up to thousands of agents. - ---- - -## Final Thoughts - -The choice of swarm depends on: -1. **Nature of the task**: Whether it's sequential or parallel. -2. **Problem complexity**: Simple problems might benefit from RoundRobin, while complex ones may need GraphWorkflow or Mixture of Agents. -3. **Scale of execution**: For large-scale tasks, Swarms like SpreadsheetSwarm or MajorityVoting provide scalability with structured outputs. - -When integrating agents in a business workflow, it's crucial to balance task complexity, agent capabilities, and scalability to ensure the optimal swarm architecture. - diff --git a/docs/swarms/structs/multi_agent_collaboration_examples.md b/docs/swarms/structs/multi_agent_collaboration_examples.md index 7623b4631..3b671feae 100644 --- a/docs/swarms/structs/multi_agent_collaboration_examples.md +++ b/docs/swarms/structs/multi_agent_collaboration_examples.md @@ -49,9 +49,11 @@ workflow.run( Inspired by Einops and einsum, this orchestration techniques enables you to map out the relationships between various agents. For example you specify linear and sequential relationships like `a -> a1 -> a2 -> a3` or concurrent relationships where the first agent will send a message to 3 agents all at once: `a -> a1, a2, a3`. You can customize your workflow to mix sequential and concurrent relationships. [Docs Available:](https://docs.swarms.world/en/latest/swarms/structs/agent_rearrange/) ```python -from swarms import Agent, AgentRearrange, Anthropic +from swarms import Agent, AgentRearrange +from swarm_models import Anthropic + # Initialize the director agent director = Agent( diff --git a/examples/structs/swarms/spreadsheet_swarm/spreadsheet_swarm_examples/csvs/README.md b/examples/structs/swarms/spreadsheet_swarm/spreadsheet_swarm_examples/csvs/README.md index d22e24219..7a6c90f22 100644 --- a/examples/structs/swarms/spreadsheet_swarm/spreadsheet_swarm_examples/csvs/README.md +++ b/examples/structs/swarms/spreadsheet_swarm/spreadsheet_swarm_examples/csvs/README.md @@ -669,9 +669,11 @@ workflow.run( Inspired by Einops and einsum, this orchestration techniques enables you to map out the relationships between various agents. For example you specify linear and sequential relationships like `a -> a1 -> a2 -> a3` or concurrent relationships where the first agent will send a message to 3 agents all at once: `a -> a1, a2, a3`. You can customize your workflow to mix sequential and concurrent relationships. [Docs Available:](https://docs.swarms.world/en/latest/swarms/structs/agent_rearrange/) ```python -from swarms import Agent, AgentRearrange, Anthropic +from swarms import Agent, AgentRearrange +from swarm_models import Anthropic + # Initialize the director agent director = Agent(