From f6264e1ff2f45148d5c91cda6856949bcf53ea10 Mon Sep 17 00:00:00 2001 From: Kye Gomez Date: Sat, 26 Apr 2025 10:10:26 -0700 Subject: [PATCH] readme --- README.md | 142 ++++++------------------------------------------------ 1 file changed, 15 insertions(+), 127 deletions(-) diff --git a/README.md b/README.md index dfd58bdc..42ab65dc 100644 --- a/README.md +++ b/README.md @@ -780,40 +780,8 @@ print(json.dumps(response, indent=4)) ### `SequentialWorkflow` -Sequential Workflow enables you to sequentially execute tasks with `Agent` and then pass the output into the next agent and onwards until you have specified your max loops. - -```mermaid -graph LR - A[Agent 1] --> B[Agent 2] - B --> C[Agent 3] - C --> D[Agent 4] - D --> E[Max Loops] - E --> F[End] -``` - - - -### Methods - -| Method | Description | Parameters | Return Value | -|--------|-------------|------------|--------------| -| `__init__` | Initialize the SequentialWorkflow | `agents`: List of Agent objects
`max_loops`: Maximum number of iterations
`verbose`: Boolean for verbose output | None | -| `run` | Execute the workflow | `input_data`: Initial input for the first agent | Final output after all agents have processed | - -### Inputs - -| Input | Type | Description | -|-------|------|-------------| -| `agents` | List[Agent] | List of Agent objects to be executed sequentially | -| `max_loops` | int | Maximum number of times the entire sequence will be repeated | -| `verbose` | bool | If True, print detailed information during execution | - -### Output - -The `run` method returns the final output after all agents have processed the input sequentially. - -In this example, each `Agent` represents a task that is executed sequentially. The output of each agent is passed to the next agent in the sequence until the maximum number of loops is reached. This workflow is particularly useful for tasks that require a series of steps to be executed in a specific order, such as data processing pipelines or complex calculations that rely on the output of previous steps. +The SequentialWorkflow in the Swarms framework enables sequential task execution across multiple Agent objects. Each agent's output serves as input for the next agent in the sequence, continuing until reaching the specified maximum number of loops (max_loops). This workflow is particularly well-suited for tasks requiring a specific order of operations, such as data processing pipelines. To learn more, visit: [Learn More](https://docs.swarms.world/en/latest/swarms/structs/sequential_workflow/) ```python import os @@ -1003,32 +971,10 @@ print( ------ -## `AgentRearrange` - -The `AgentRearrange` orchestration technique, inspired by Einops and einsum, allows you to define and map out the relationships between various agents. It provides a powerful tool for orchestrating complex workflows, enabling you to specify linear and sequential relationships such as `a -> a1 -> a2 -> a3`, or concurrent relationships where the first agent sends a message to 3 agents simultaneously: `a -> a1, a2, a3`. This level of customization allows for the creation of highly efficient and dynamic workflows, where agents can work in parallel or in sequence as needed. The `AgentRearrange` technique is a valuable addition to the swarms library, providing a new level of flexibility and control over the orchestration of agents. For more detailed information and examples, please refer to the [official documentation](https://docs.swarms.world/en/latest/swarms/structs/agent_rearrange/). - -[Check out my video on agent rearrange!](https://youtu.be/Rq8wWQ073mg) - - - -### Methods - -| Method | Description | Parameters | Return Value | -|--------|-------------|------------|--------------| -| `__init__` | Initialize the AgentRearrange | `agents`: List of Agent objects
`flow`: String describing the agent flow | None | -| `run` | Execute the workflow | `input_data`: Initial input for the first agent | Final output after all agents have processed | -### Inputs - -| Input | Type | Description | -|-------|------|-------------| -| `agents` | List[Agent] | List of Agent objects to be orchestrated | -| `flow` | str | String describing the flow of agents (e.g., "A -> B, C") | - -### Output - -The `run` method returns the final output after all agents have processed the input according to the specified flow. +## `AgentRearrange` +The `AgentRearrange` orchestration technique, inspired by Einops and einsum, enables you to define and map relationships between multiple agents. This powerful tool facilitates the orchestration of complex workflows by allowing you to specify both linear and concurrent relationships. For example, you can create sequential workflows like `a -> a1 -> a2 -> a3` or parallel workflows where a single agent distributes tasks to multiple agents simultaneously: `a -> a1, a2, a3`. This flexibility enables the creation of highly efficient and dynamic workflows, with agents operating either in parallel or sequence as required. As a valuable addition to the swarms library, `AgentRearrange` provides enhanced flexibility and precise control over agent orchestration. For comprehensive information and examples, visit the [official documentation](https://docs.swarms.world/en/latest/swarms/structs/agent_rearrange/). [Watch my video tutorial on agent rearrange!](https://youtu.be/Rq8wWQ073mg) @@ -1215,33 +1161,20 @@ if __name__ == "__main__": ``` -## `HierarhicalSwarm` -Coming soon... - - -## `GraphSwarm` +------------ -The `GraphSwarm` is a workflow management system designed to orchestrate complex tasks by leveraging the power of graph theory. It enables the creation of a directed acyclic graph (DAG) to model dependencies between tasks and agents. This allows for efficient task assignment, execution, and monitoring. -Here's a breakdown of how the `GraphSwarm` works: +## `HierarhicalSwarm` +Coming soon... -1. **Node Creation**: The `GraphSwarm` workflow is composed of nodes, which can be either agents or tasks. Agents are responsible for executing tasks, and tasks represent specific operations that need to be performed. In the example, two agents (`agent1` and `agent2`) and one task (`task1`) are created. -2. **Edge Definition**: Edges are used to define the relationships between nodes. In this case, edges are created to connect `agent1` and `agent2` to `task1`, indicating that both agents are capable of executing `task1`. -3. **Entry and End Points**: The `GraphSwarm` workflow requires the definition of entry points (where the workflow starts) and end points (where the workflow concludes). In this example, `agent1` and `agent2` are set as entry points, and `task1` is set as the end point. -4. **Visualization**: The `GraphSwarm` provides a visualization feature to graphically represent the workflow. This allows for easy understanding and debugging of the workflow structure. -5. **Execution**: The `GraphSwarm` workflow is executed by traversing the graph from the entry points to the end points. In this case, both `agent1` and `agent2` execute `task1` concurrently, and the results are collected. -6. **Results**: The final results of the workflow execution are aggregated and returned. In this example, the result of executing `task1` is "Task completed". -The `GraphSwarm` offers several benefits, including: +----------------- -* **Concurrency**: Enables the execution of tasks concurrently, improving overall workflow efficiency. -* **Flexibility**: Allows for dynamic task assignment based on agent availability and task requirements. -* **Scalability**: Supports the addition of new agents and tasks as needed, making it suitable for large-scale workflows. -* **Visualization**: Provides a graphical representation of the workflow, facilitating understanding and debugging. +## `GraphSwarm` -By leveraging the `GraphSwarm`, complex workflows can be efficiently managed, and tasks can be executed in a coordinated and scalable manner. +GraphSwarm is a workflow management system using a directed acyclic graph (DAG) to orchestrate complex tasks. Nodes (agents or tasks) and edges define dependencies, with agents executing tasks concurrently. It features entry/end points, visualization for debugging, and scalability for dynamic task assignment. Benefits include concurrency, flexibility, scalability, and clear workflow visualization. [Learn more:](https://docs.swarms.world/en/latest/swarms/structs/graph_swarm/) ### Methods @@ -1481,42 +1414,12 @@ print(out) ``` +------- ## SpreadSheetSwarm -The `SpreadSheetSwarm` is designed for concurrent management and oversight of thousands of agents, facilitating a one-to-many approach for efficient task processing and output analysis. - -### Key Features - -* **Concurrency**: Enables the simultaneous execution of multiple agents, significantly reducing processing time and increasing overall system efficiency. -* **One-to-Many**: Allows a single task to be dynamically distributed among multiple agents, ensuring that each agent is utilized to its full potential. -* **Scalability**: Supports the integration of thousands of agents, making it an ideal solution for large-scale task processing and data analysis. - - -### Methods - -| Method | Description | Parameters | Return Value | -|--------|-------------|------------|--------------| -| `__init__` | Initialize the SpreadSheetSwarm | `name`: Name of the swarm
`description`: Description of the swarm
`agents`: List of Agent objects
`autosave_on`: Boolean to enable autosave
`save_file_path`: Path to save the spreadsheet
`run_all_agents`: Boolean to run all agents or not
`max_loops`: Maximum number of loops | None | -| `run` | Execute the swarm | `task`: Input task for the swarm | Dictionary of agent outputs | - -### Inputs - -| Input | Type | Description | -|-------|------|-------------| -| `name` | str | Name of the swarm | -| `description` | str | Description of the swarm's purpose | -| `agents` | List[Agent] | List of Agent objects to be used in the swarm | -| `autosave_on` | bool | Enable autosaving of results | -| `save_file_path` | str | Path to save the spreadsheet results | -| `run_all_agents` | bool | Whether to run all agents or select based on relevance | -| `max_loops` | int | Maximum number of processing loops | - -### Output - -The `run` method returns a dictionary containing the outputs of each agent that processed the task. +SpreadSheetSwarm manages thousands of agents concurrently for efficient task processing. It supports one-to-many task distribution, scalability, and autosaving results. Initialized with a name, description, agents, and settings, the run method executes tasks and returns a dictionary of agent outputs. - -[Learn more at the docs here:](https://docs.swarms.world/en/latest/swarms/structs/spreadsheet_swarm/) +[Learn more:](https://docs.swarms.world/en/latest/swarms/structs/spreadsheet_swarm/) ```python import os @@ -1673,28 +1576,13 @@ swarm.run( ``` -## `ForestSwarm` -The `ForestSwarm` architecture is designed for efficient task assignment by dynamically selecting the most suitable agent from a collection of trees. This is achieved through asynchronous task processing, where agents are chosen based on their relevance to the task at hand. The relevance is determined by calculating the similarity between the system prompts associated with each agent and the keywords present in the task itself. For a more in-depth understanding of how `ForestSwarm` works, please refer to the [official documentation](https://docs.swarms.world/en/latest/swarms/structs/forest_swarm/). - - - -### Methods - -| Method | Description | Parameters | Return Value | -|--------|-------------|------------|--------------| -| `__init__` | Initialize the ForestSwarm | `trees`: List of Tree objects | None | -| `run` | Execute the ForestSwarm | `task`: Input task for the swarm | Output from the most relevant agent | +---------- -### Inputs +## `ForestSwarm` -| Input | Type | Description | -|-------|------|-------------| -| `trees` | List[Tree] | List of Tree objects, each containing TreeAgent objects | -| `task` | str | The task to be processed by the ForestSwarm | +The `ForestSwarm` architecture is an intelligent system designed to optimize task assignment by dynamically selecting the most appropriate agent from a collection of specialized trees. Through asynchronous task processing, the system intelligently matches tasks with agents based on their relevance. This matching is accomplished by computing the semantic similarity between each agent's system prompts and the keywords present in the task. For comprehensive details about the `ForestSwarm` implementation and capabilities, please consult the [official documentation](https://docs.swarms.world/en/latest/swarms/structs/forest_swarm/). -### Output -The `run` method returns the output from the most relevant agent selected based on the input task. ```python