The Swarms module provides a powerful framework for creating and managing swarms of autonomous agents to accomplish complex tasks. It consists of the `WorkerNode` and `BossNode` classes, along with the `LLM` utility class, which allow you to easily set up and run a swarm of agents to tackle any objective. The module is highly configurable and extensible, providing flexibility to accommodate various use cases.
## Usage example
```python
from swarms import Swarms
api_key = "your_openai_api_key"
# Initialize Swarms with your API key
swarm = Swarms(api_key=api_key)
# Define an objective
objective = "Please make a web GUI for using HTTP API server..."
# Run Swarms
result = swarm.run_swarms(objective)
print(result)
```
## Constructor
```python
def __init__(self, openai_api_key)
```
-`openai_api_key` (required): The API key for OpenAI's models.
## Methods
### run_swarms(objective)
Runs the swarm with the given objective by initializing the worker and boss nodes.
-`objective` (required): The objective or task to be accomplished by the swarm.
Returns the result of the swarm execution.
## Example Usage
```python
from swarms import Swarms
api_key = "your_openai_api_key"
# Initialize Swarms with your API key
swarm = Swarms(api_key=api_key)
# Define an objective
objective = "Please make a web GUI for using HTTP API server..."
The `WorkerNode` class represents an autonomous agent instance that functions as a worker to accomplish complex tasks. It has the ability to search the internet, process and generate images, text, audio, and more.
The `BossNode` class represents an agent responsible for creating and managing tasks for the worker agent(s). It interacts with the worker node(s) to delegate tasks and monitor their progress.
The `LLM` class is a utility class that provides an interface to different language models (LLMs) such as OpenAI's ChatGPT and Hugging Face models. It is used to initialize the language model for the worker and boss nodes.
For more advanced usage, you can customize the tools and parameters according to your specific requirements. The Swarms module provides flexibility and extensibility to accommodate various use cases.
For example, you can add your own custom tools by extending the `Tool` class and adding them to the worker node. You can also modify the prompt templates used by the boss node to customize the interaction between the boss and worker agents.
The Swarms module provides a powerful framework for creating and managing swarms of autonomous agents to accomplish complex tasks. With the `WorkerNode` and `BossNode` classes, along with the `LLM` utility class, you can easily set up and run a swarm of agents to tackle any objective. The module is highly configurable and extensible, allowing you to tailor it to your specific needs.