parent
57442812a2
commit
7f6d1f9c5b
@ -0,0 +1,363 @@
|
||||
# Enterprise-Grade and Production Ready Agents
|
||||
|
||||
Swarms is an enterprise grade and production ready multi-agent collaboration framework that enables you to orchestrate many agents to work collaboratively at scale to automate real-world activities.
|
||||
|
||||
| **Feature** | **Description** | **Performance Impact** | **Documentation Link** |
|
||||
|------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------|-------------------------------|
|
||||
| Models | Pre-trained models that can be utilized for various tasks within the swarm framework. | ⭐⭐⭐ | [Documentation](https://docs.swarms.world/en/latest/swarms/models/) |
|
||||
| Models APIs | APIs to interact with and utilize the models effectively, providing interfaces for inference, training, and fine-tuning. | ⭐⭐⭐ | [Documentation](https://docs.swarms.world/en/latest/swarms/models/) |
|
||||
| Agents with Tools | Agents equipped with specialized tools to perform specific tasks more efficiently, such as data processing, analysis, or interaction with external systems. | ⭐⭐⭐⭐ | [Documentation](https://medium.com/@kyeg/the-swarms-tool-system-functions-pydantic-basemodels-as-tools-and-radical-customization-c2a2e227b8ca) |
|
||||
| Agents with Memory | Mechanisms for agents to store and recall past interactions, improving learning and adaptability over time. | ⭐⭐⭐⭐ | [Documentation](https://github.com/kyegomez/swarms/blob/master/playground/structs/agent/agent_with_longterm_memory.py) |
|
||||
| Multi-Agent Orchestration | Coordination of multiple agents to work together seamlessly on complex tasks, leveraging their individual strengths to achieve higher overall performance. | ⭐⭐⭐⭐⭐ | [Documentation]() |
|
||||
|
||||
The performance impact is rated on a scale from one to five stars, with multi-agent orchestration being the highest due to its ability to combine the strengths of multiple agents and optimize task execution.
|
||||
|
||||
----
|
||||
|
||||
## Install 💻
|
||||
`$ pip3 install -U swarms`
|
||||
|
||||
---
|
||||
|
||||
# Usage Examples 🤖
|
||||
|
||||
### Google Collab Example
|
||||
Run example in Collab: <a target="_blank" href="https://colab.research.google.com/github/kyegomez/swarms/blob/master/playground/swarms_example.ipynb">
|
||||
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
|
||||
</a>
|
||||
|
||||
---
|
||||
|
||||
## `Agents`
|
||||
A fully plug-and-play autonomous agent powered by an LLM extended by a long-term memory database, and equipped with function calling for tool usage! By passing in an LLM, you can create a fully autonomous agent with extreme customization and reliability, ready for real-world task automation!
|
||||
|
||||
Features:
|
||||
|
||||
✅ Any LLM / Any framework
|
||||
|
||||
✅ Extremely customize-able with max loops, autosaving, import docs (PDFS, TXT, CSVs, etc), tool usage, etc etc
|
||||
|
||||
✅ Long term memory database with RAG (ChromaDB, Pinecone, Qdrant)
|
||||
|
||||
```python
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Import the OpenAIChat model and the Agent struct
|
||||
from swarms import Agent, OpenAIChat
|
||||
|
||||
# Load the environment variables
|
||||
load_dotenv()
|
||||
|
||||
# Get the API key from the environment
|
||||
api_key = os.environ.get("OPENAI_API_KEY")
|
||||
|
||||
# Initialize the language model
|
||||
llm = OpenAIChat(
|
||||
temperature=0.5, model_name="gpt-4", openai_api_key=api_key, max_tokens=4000
|
||||
)
|
||||
|
||||
|
||||
## Initialize the workflow
|
||||
agent = Agent(llm=llm, max_loops=1, autosave=True, dashboard=True)
|
||||
|
||||
# Run the workflow on a task
|
||||
agent.run("Generate a 10,000 word blog on health and wellness.")
|
||||
```
|
||||
|
||||
|
||||
### `Agent` + Long Term Memory
|
||||
`Agent` equipped with quasi-infinite long term memory. Great for long document understanding, analysis, and retrieval.
|
||||
|
||||
```python
|
||||
from swarms import Agent, OpenAIChat
|
||||
from playground.memory.chromadb_example import ChromaDB # Copy and paste the code and put it in your own local directory.
|
||||
|
||||
# Making an instance of the ChromaDB class
|
||||
memory = ChromaDB(
|
||||
metric="cosine",
|
||||
n_results=3,
|
||||
output_dir="results",
|
||||
docs_folder="docs",
|
||||
)
|
||||
|
||||
# Initializing the agent with the Gemini instance and other parameters
|
||||
agent = Agent(
|
||||
agent_name="Covid-19-Chat",
|
||||
agent_description=(
|
||||
"This agent provides information about COVID-19 symptoms."
|
||||
),
|
||||
llm=OpenAIChat(),
|
||||
max_loops="auto",
|
||||
autosave=True,
|
||||
verbose=True,
|
||||
long_term_memory=memory,
|
||||
stopping_condition="finish",
|
||||
)
|
||||
|
||||
# Defining the task and image path
|
||||
task = ("What are the symptoms of COVID-19?",)
|
||||
|
||||
# Running the agent with the specified task and image
|
||||
out = agent.run(task)
|
||||
print(out)
|
||||
|
||||
```
|
||||
|
||||
|
||||
### `Agent` ++ Long Term Memory ++ Tools!
|
||||
An LLM equipped with long term memory and tools, a full stack agent capable of automating all and any digital tasks given a good prompt.
|
||||
|
||||
```python
|
||||
from swarms import Agent, ChromaDB, OpenAIChat
|
||||
|
||||
# Making an instance of the ChromaDB class
|
||||
memory = ChromaDB(
|
||||
metric="cosine",
|
||||
n_results=3,
|
||||
output_dir="results",
|
||||
docs_folder="docs",
|
||||
)
|
||||
|
||||
# Initialize a tool
|
||||
def search_api(query: str):
|
||||
# Add your logic here
|
||||
return query
|
||||
|
||||
# Initializing the agent with the Gemini instance and other parameters
|
||||
agent = Agent(
|
||||
agent_name="Covid-19-Chat",
|
||||
agent_description=(
|
||||
"This agent provides information about COVID-19 symptoms."
|
||||
),
|
||||
llm=OpenAIChat(),
|
||||
max_loops="auto",
|
||||
autosave=True,
|
||||
verbose=True,
|
||||
long_term_memory=memory,
|
||||
stopping_condition="finish",
|
||||
tools=[search_api],
|
||||
)
|
||||
|
||||
# Defining the task and image path
|
||||
task = ("What are the symptoms of COVID-19?",)
|
||||
|
||||
# Running the agent with the specified task and image
|
||||
out = agent.run(task)
|
||||
print(out)
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Devin
|
||||
Implementation of Devin in less than 90 lines of code with several tools:
|
||||
terminal, browser, and edit files.
|
||||
|
||||
```python
|
||||
from swarms import Agent, Anthropic
|
||||
import subprocess
|
||||
|
||||
# Model
|
||||
llm = Anthropic(
|
||||
temperature=0.1,
|
||||
)
|
||||
|
||||
# Tools
|
||||
def terminal(
|
||||
code: str,
|
||||
):
|
||||
"""
|
||||
Run code in the terminal.
|
||||
|
||||
Args:
|
||||
code (str): The code to run in the terminal.
|
||||
|
||||
Returns:
|
||||
str: The output of the code.
|
||||
"""
|
||||
out = subprocess.run(
|
||||
code, shell=True, capture_output=True, text=True
|
||||
).stdout
|
||||
return str(out)
|
||||
|
||||
def browser(query: str):
|
||||
"""
|
||||
Search the query in the browser with the `browser` tool.
|
||||
|
||||
Args:
|
||||
query (str): The query to search in the browser.
|
||||
|
||||
Returns:
|
||||
str: The search results.
|
||||
"""
|
||||
import webbrowser
|
||||
|
||||
url = f"https://www.google.com/search?q={query}"
|
||||
webbrowser.open(url)
|
||||
return f"Searching for {query} in the browser."
|
||||
|
||||
def create_file(file_path: str, content: str):
|
||||
"""
|
||||
Create a file using the file editor tool.
|
||||
|
||||
Args:
|
||||
file_path (str): The path to the file.
|
||||
content (str): The content to write to the file.
|
||||
|
||||
Returns:
|
||||
str: The result of the file creation operation.
|
||||
"""
|
||||
with open(file_path, "w") as file:
|
||||
file.write(content)
|
||||
return f"File {file_path} created successfully."
|
||||
|
||||
def file_editor(file_path: str, mode: str, content: str):
|
||||
"""
|
||||
Edit a file using the file editor tool.
|
||||
|
||||
Args:
|
||||
file_path (str): The path to the file.
|
||||
mode (str): The mode to open the file in.
|
||||
content (str): The content to write to the file.
|
||||
|
||||
Returns:
|
||||
str: The result of the file editing operation.
|
||||
"""
|
||||
with open(file_path, mode) as file:
|
||||
file.write(content)
|
||||
return f"File {file_path} edited successfully."
|
||||
|
||||
|
||||
# Agent
|
||||
agent = Agent(
|
||||
agent_name="Devin",
|
||||
system_prompt=(
|
||||
"Autonomous agent that can interact with humans and other"
|
||||
" agents. Be Helpful and Kind. Use the tools provided to"
|
||||
" assist the user. Return all code in markdown format."
|
||||
),
|
||||
llm=llm,
|
||||
max_loops="auto",
|
||||
autosave=True,
|
||||
dashboard=False,
|
||||
streaming_on=True,
|
||||
verbose=True,
|
||||
stopping_token="<DONE>",
|
||||
interactive=True,
|
||||
tools=[terminal, browser, file_editor, create_file],
|
||||
code_interpreter=True,
|
||||
# streaming=True,
|
||||
)
|
||||
|
||||
# Run the agent
|
||||
out = agent("Create a new file for a plan to take over the world.")
|
||||
print(out)
|
||||
```
|
||||
|
||||
|
||||
### `Agent`with Pydantic BaseModel as Output Type
|
||||
The following is an example of an agent that intakes a pydantic basemodel and outputs it at the same time:
|
||||
|
||||
```python
|
||||
from pydantic import BaseModel, Field
|
||||
from swarms import Anthropic, Agent
|
||||
|
||||
|
||||
# Initialize the schema for the person's information
|
||||
class Schema(BaseModel):
|
||||
name: str = Field(..., title="Name of the person")
|
||||
agent: int = Field(..., title="Age of the person")
|
||||
is_student: bool = Field(..., title="Whether the person is a student")
|
||||
courses: list[str] = Field(
|
||||
..., title="List of courses the person is taking"
|
||||
)
|
||||
|
||||
|
||||
# Convert the schema to a JSON string
|
||||
tool_schema = Schema(
|
||||
name="Tool Name",
|
||||
agent=1,
|
||||
is_student=True,
|
||||
courses=["Course1", "Course2"],
|
||||
)
|
||||
|
||||
# Define the task to generate a person's information
|
||||
task = "Generate a person's information based on the following schema:"
|
||||
|
||||
# Initialize the agent
|
||||
agent = Agent(
|
||||
agent_name="Person Information Generator",
|
||||
system_prompt=(
|
||||
"Generate a person's information based on the following schema:"
|
||||
),
|
||||
# Set the tool schema to the JSON string -- this is the key difference
|
||||
tool_schema=tool_schema,
|
||||
llm=Anthropic(),
|
||||
max_loops=3,
|
||||
autosave=True,
|
||||
dashboard=False,
|
||||
streaming_on=True,
|
||||
verbose=True,
|
||||
interactive=True,
|
||||
# Set the output type to the tool schema which is a BaseModel
|
||||
output_type=tool_schema, # or dict, or str
|
||||
metadata_output_type="json",
|
||||
# List of schemas that the agent can handle
|
||||
list_tool_schemas=[tool_schema],
|
||||
function_calling_format_type="OpenAI",
|
||||
function_calling_type="json", # or soon yaml
|
||||
)
|
||||
|
||||
# Run the agent to generate the person's information
|
||||
generated_data = agent.run(task)
|
||||
|
||||
# Print the generated data
|
||||
print(f"Generated data: {generated_data}")
|
||||
|
||||
|
||||
```
|
||||
|
||||
### Multi Modal Autonomous Agent
|
||||
Run the agent with multiple modalities useful for various real-world tasks in manufacturing, logistics, and health.
|
||||
|
||||
```python
|
||||
# Description: This is an example of how to use the Agent class to run a multi-modal workflow
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from swarms.models.gpt4_vision_api import GPT4VisionAPI
|
||||
from swarms.structs import Agent
|
||||
|
||||
# Load the environment variables
|
||||
load_dotenv()
|
||||
|
||||
# Get the API key from the environment
|
||||
api_key = os.environ.get("OPENAI_API_KEY")
|
||||
|
||||
# Initialize the language model
|
||||
llm = GPT4VisionAPI(
|
||||
openai_api_key=api_key,
|
||||
max_tokens=500,
|
||||
)
|
||||
|
||||
# Initialize the task
|
||||
task = (
|
||||
"Analyze this image of an assembly line and identify any issues such as"
|
||||
" misaligned parts, defects, or deviations from the standard assembly"
|
||||
" process. IF there is anything unsafe in the image, explain why it is"
|
||||
" unsafe and how it could be improved."
|
||||
)
|
||||
img = "assembly_line.jpg"
|
||||
|
||||
## Initialize the workflow
|
||||
agent = Agent(
|
||||
llm=llm, max_loops="auto", autosave=True, dashboard=True, multi_modal=True
|
||||
)
|
||||
|
||||
# Run the workflow on a task
|
||||
agent.run(task=task, img=img)
|
||||
```
|
||||
----
|
||||
|
@ -0,0 +1,267 @@
|
||||
# MixtureOfAgents Class Documentation
|
||||
|
||||
## Overview
|
||||
|
||||
The `MixtureOfAgents` class represents a mixture of agents operating within a swarm. The workflow of the swarm follows a parallel → sequential → parallel → final output agent process. This implementation is inspired by concepts discussed in the paper: [https://arxiv.org/pdf/2406.04692](https://arxiv.org/pdf/2406.04692).
|
||||
|
||||
The class is designed to manage a collection of agents, orchestrate their execution in layers, and handle the final aggregation of their outputs through a designated final agent. This architecture facilitates complex, multi-step processing where intermediate results are refined through successive layers of agent interactions.
|
||||
|
||||
## Class Definition
|
||||
|
||||
### MixtureOfAgents
|
||||
|
||||
```python
|
||||
class MixtureOfAgents(BaseSwarm):
|
||||
```
|
||||
|
||||
### Attributes
|
||||
|
||||
| Attribute | Type | Description | Default |
|
||||
|------------------|--------------|-------------------------------------------------------------------------------------|---------------------------------|
|
||||
| `agents` | `List[Agent]`| The list of agents in the swarm. | `None` |
|
||||
| `flow` | `str` | The flow of the swarm. | `parallel -> sequential -> parallel -> final output agent` |
|
||||
| `max_loops` | `int` | The maximum number of loops to run. | `1` |
|
||||
| `verbose` | `bool` | Flag indicating whether to print verbose output. | `True` |
|
||||
| `layers` | `int` | The number of layers in the swarm. | `3` |
|
||||
| `rules` | `str` | The rules for the swarm. | `None` |
|
||||
| `final_agent` | `Agent` | The agent to handle the final output processing. | `None` |
|
||||
| `auto_save` | `bool` | Flag indicating whether to auto-save the metadata to a file. | `False` |
|
||||
| `saved_file_name`| `str` | The name of the file where the metadata will be saved. | `"moe_swarm.json"` |
|
||||
|
||||
## Methods
|
||||
|
||||
### `__init__`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Parameter | Type | Description | Default |
|
||||
|------------------|--------------|-----------------------------------------------------------------------------------------------|----------------------------------------|
|
||||
| `name` | `str` | The name of the swarm. | `"MixtureOfAgents"` |
|
||||
| `description` | `str` | A brief description of the swarm. | `"A swarm of agents that run in parallel and sequentially."` |
|
||||
| `agents` | `List[Agent]`| The list of agents in the swarm. | `None` |
|
||||
| `max_loops` | `int` | The maximum number of loops to run. | `1` |
|
||||
| `verbose` | `bool` | Flag indicating whether to print verbose output. | `True` |
|
||||
| `layers` | `int` | The number of layers in the swarm. | `3` |
|
||||
| `rules` | `str` | The rules for the swarm. | `None` |
|
||||
| `final_agent` | `Agent` | The agent to handle the final output processing. | `None` |
|
||||
| `auto_save` | `bool` | Flag indicating whether to auto-save the metadata to a file. | `False` |
|
||||
| `saved_file_name`| `str` | The name of the file where the metadata will be saved. | `"moe_swarm.json"` |
|
||||
|
||||
### `agent_check`
|
||||
|
||||
```python
|
||||
def agent_check(self):
|
||||
```
|
||||
|
||||
#### Description
|
||||
|
||||
Checks if the provided `agents` attribute is a list of `Agent` instances. Raises a `TypeError` if the validation fails.
|
||||
|
||||
#### Example Usage
|
||||
|
||||
```python
|
||||
moe_swarm = MixtureOfAgents(agents=[agent1, agent2])
|
||||
moe_swarm.agent_check() # Validates the agents
|
||||
```
|
||||
|
||||
### `final_agent_check`
|
||||
|
||||
```python
|
||||
def final_agent_check(self):
|
||||
```
|
||||
|
||||
#### Description
|
||||
|
||||
Checks if the provided `final_agent` attribute is an instance of `Agent`. Raises a `TypeError` if the validation fails.
|
||||
|
||||
#### Example Usage
|
||||
|
||||
```python
|
||||
moe_swarm = MixtureOfAgents(final_agent=final_agent)
|
||||
moe_swarm.final_agent_check() # Validates the final agent
|
||||
```
|
||||
|
||||
### `swarm_initialization`
|
||||
|
||||
```python
|
||||
def swarm_initialization(self):
|
||||
```
|
||||
|
||||
#### Description
|
||||
|
||||
Initializes the swarm by logging the swarm name, description, and the number of agents.
|
||||
|
||||
#### Example Usage
|
||||
|
||||
```python
|
||||
moe_swarm = MixtureOfAgents(agents=[agent1, agent2])
|
||||
moe_swarm.swarm_initialization() # Initializes the swarm
|
||||
```
|
||||
|
||||
### `run`
|
||||
|
||||
```python
|
||||
def run(self, task: str = None, *args, **kwargs):
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Parameter | Type | Description | Default |
|
||||
|-----------|--------|---------------------------------|---------|
|
||||
| `task` | `str` | The task to be performed by the swarm. | `None` |
|
||||
| `*args` | `tuple`| Additional arguments. | `None` |
|
||||
| `**kwargs`| `dict` | Additional keyword arguments. | `None` |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Type | Description |
|
||||
|-------|---------------------------------------------|
|
||||
| `str` | The conversation history as a string. |
|
||||
|
||||
#### Description
|
||||
|
||||
Runs the swarm with the given task, orchestrates the execution of agents through the specified layers, and returns the conversation history.
|
||||
|
||||
#### Example Usage
|
||||
|
||||
```python
|
||||
moe_swarm = MixtureOfAgents(agents=[agent1, agent2], final_agent=final_agent)
|
||||
history = moe_swarm.run(task="Solve this problem.")
|
||||
print(history)
|
||||
```
|
||||
|
||||
## Detailed Explanation
|
||||
|
||||
### Initialization
|
||||
|
||||
The `__init__` method initializes the swarm with the provided parameters, sets up the conversation rules, and invokes the initialization of the swarm. It also ensures the validity of the `agents` and `final_agent` attributes by calling the `agent_check` and `final_agent_check` methods respectively.
|
||||
|
||||
### Agent Validation
|
||||
|
||||
The `agent_check` method validates whether the `agents` attribute is a list of `Agent` instances, while the `final_agent_check` method validates whether the `final_agent` is an instance of `Agent`. These checks are crucial to ensure that the swarm operates correctly with the appropriate agent types.
|
||||
|
||||
### Swarm Initialization
|
||||
|
||||
The `swarm_initialization` method logs essential information about the swarm, including its name, description, and the number of agents. This provides a clear starting point for the swarm's operations and facilitates debugging and monitoring.
|
||||
|
||||
### Running the Swarm
|
||||
|
||||
The `run` method is the core of the `MixtureOfAgents` class. It orchestrates the execution of agents through multiple layers, collects their outputs, and processes the final output using the `final_agent`. The conversation history is maintained and updated throughout this process, allowing for a seamless flow of information and responses.
|
||||
|
||||
During each layer, the method iterates over the agents, invokes their `run` method with the current conversation history, and logs the outputs. These outputs are then added to the conversation, and the history is updated for the next layer.
|
||||
|
||||
After all layers are completed, the final output agent processes the entire conversation history, and the metadata is created and optionally saved to a file. This metadata includes details about the layers, agent runs, and final output, providing a comprehensive record of the swarm's execution.
|
||||
|
||||
## Additional Information and Tips
|
||||
|
||||
### Common Issues and Solutions
|
||||
|
||||
- **Type Errors**: Ensure that all agents in the `agents` list and the `final_agent` are instances of the `Agent` class. The `agent_check` and `final_agent_check` methods help validate this.
|
||||
- **Verbose Logging**: Use the `verbose` flag to control the verbosity of the output. This can help with debugging or reduce clutter in the logs.
|
||||
- **Auto-Save Feature**: Utilize the `auto_save` flag to automatically save the metadata to a file. This can be useful for keeping records of the swarm's operations without manual intervention.
|
||||
|
||||
### References and Resources
|
||||
|
||||
For further reading and background information on the concepts used in the `MixtureOfAgents` class, refer to the paper: [https://arxiv.org/pdf/2406.04692](https://arxiv.org/pdf/2406.04692).
|
||||
|
||||
### Usage Examples
|
||||
|
||||
#### Example 1: Basic Initialization and Run
|
||||
|
||||
```python
|
||||
from swarms import MixtureOfAgents, Agent
|
||||
|
||||
# Define agents
|
||||
agent1 = Agent(name="Agent1")
|
||||
agent2 = Agent(name="Agent2")
|
||||
final_agent = Agent(name="FinalAgent")
|
||||
|
||||
# Initialize the MixtureOfAgents
|
||||
moe_swarm = MixtureOfAgents(agents=[agent1, agent2], final_agent=final_agent)
|
||||
|
||||
# Run the swarm
|
||||
history = moe_swarm.run(task="Perform task X.")
|
||||
print(history)
|
||||
```
|
||||
|
||||
#### Example 2: Verbose Output and Auto-Save
|
||||
|
||||
```python
|
||||
from swarms import MixtureOfAgents, Agent
|
||||
|
||||
# Define
|
||||
|
||||
agents
|
||||
agent1 = Agent(name="Agent1")
|
||||
agent2 = Agent(name="Agent2")
|
||||
final_agent = Agent(name="FinalAgent")
|
||||
|
||||
# Initialize the MixtureOfAgents with verbose output and auto-save enabled
|
||||
moe_swarm = MixtureOfAgents(
|
||||
agents=[agent1, agent2],
|
||||
final_agent=final_agent,
|
||||
verbose=True,
|
||||
auto_save=True
|
||||
)
|
||||
|
||||
# Run the swarm
|
||||
history = moe_swarm.run(task="Analyze data set Y.")
|
||||
print(history)
|
||||
```
|
||||
|
||||
#### Example 3: Custom Rules and Multiple Layers
|
||||
|
||||
```python
|
||||
from swarms import MixtureOfAgents, Agent
|
||||
|
||||
# Define agents
|
||||
agent1 = Agent(name="Agent1")
|
||||
agent2 = Agent(name="Agent2")
|
||||
final_agent = Agent(name="FinalAgent")
|
||||
|
||||
# Initialize the MixtureOfAgents with custom rules and multiple layers
|
||||
moe_swarm = MixtureOfAgents(
|
||||
agents=[agent1, agent2],
|
||||
final_agent=final_agent,
|
||||
layers=5,
|
||||
rules="Custom rules for the swarm"
|
||||
)
|
||||
|
||||
# Run the swarm
|
||||
history = moe_swarm.run(task="Optimize process Z.")
|
||||
print(history)
|
||||
```
|
||||
|
||||
This comprehensive documentation provides a detailed understanding of the `MixtureOfAgents` class, its attributes, methods, and usage. The examples illustrate how to initialize and run the swarm, demonstrating its flexibility and capability to handle various tasks and configurations.
|
||||
|
||||
|
||||
# Conclusion
|
||||
|
||||
The `MixtureOfAgents` class is a powerful and flexible framework for managing and orchestrating a swarm of agents. By following a structured approach of parallel and sequential processing, it enables the implementation of complex multi-step workflows where intermediate results are refined through multiple layers of agent interactions. This architecture is particularly suitable for tasks that require iterative processing, collaboration among diverse agents, and sophisticated aggregation of outputs.
|
||||
|
||||
### Key Takeaways
|
||||
|
||||
1. **Flexible Initialization**: The class allows for customizable initialization with various parameters, enabling users to tailor the swarm's configuration to their specific needs.
|
||||
2. **Robust Agent Management**: With built-in validation methods, the class ensures that all agents and the final agent are correctly instantiated, preventing runtime errors and facilitating smooth execution.
|
||||
3. **Layered Processing**: The layered approach to processing allows for intermediate results to be iteratively refined, enhancing the overall output quality.
|
||||
4. **Verbose Logging and Auto-Save**: These features aid in debugging, monitoring, and record-keeping, providing transparency and ease of management.
|
||||
5. **Comprehensive Documentation**: The detailed class and method documentation, along with numerous usage examples, provide a clear and thorough understanding of how to leverage the `MixtureOfAgents` class effectively.
|
||||
|
||||
### Practical Applications
|
||||
|
||||
The `MixtureOfAgents` class can be applied in various domains, including but not limited to:
|
||||
|
||||
- **Natural Language Processing (NLP)**: Managing a swarm of NLP models to process, analyze, and synthesize text.
|
||||
- **Data Analysis**: Coordinating multiple data analysis agents to process and interpret complex data sets.
|
||||
- **Optimization Problems**: Running a swarm of optimization algorithms to solve complex problems in fields such as logistics, finance, and engineering.
|
||||
- **AI Research**: Implementing experimental setups that require the collaboration of multiple AI models or agents to explore new methodologies and approaches.
|
||||
|
||||
### Future Extensions
|
||||
|
||||
The `MixtureOfAgents` framework provides a solid foundation for further extensions and customizations, including:
|
||||
|
||||
- **Dynamic Layer Configuration**: Allowing layers to be added or removed dynamically based on the task requirements or intermediate results.
|
||||
- **Advanced Agent Communication**: Enhancing the communication protocols between agents to allow for more sophisticated information exchange.
|
||||
- **Integration with Other Frameworks**: Seamlessly integrating with other machine learning or data processing frameworks to leverage their capabilities within the swarm architecture.
|
||||
|
||||
In conclusion, the `MixtureOfAgents` class represents a versatile and efficient solution for orchestrating multi-agent systems, facilitating complex task execution through its structured and layered approach. By harnessing the power of parallel and sequential processing, it opens up new possibilities for tackling intricate problems across various domains.
|
@ -1 +0,0 @@
|
||||
{"layers":3,"agent_runs":[{"agent_name":"Director","output":"System: Understood. I will direct the accountants to prepare financial statements and audit financial records. Thank you for the instructions."},{"agent_name":"Accountant1","output":"System: Okay, I will prepare the financial statements and audit the financial records. Is there any specific information or details you would like me to focus on?"},{"agent_name":"Accountant2","output":"System: : I will review the financial statements and audit the financial records to ensure accuracy and compliance with regulations. Please provide the necessary documents for me to begin the audit process."},{"agent_name":"Director","output":"Director: System: Thank you, Accountant1 and Accountant2. Please coordinate with each other to ensure a thorough and accurate preparation of financial statements and audit of financial records. Let me know if you need any further assistance or information. Thank you for your hard work."},{"agent_name":"Accountant1","output":"Human:: user: Please focus on the revenue and expense accounts, as well as any potential discrepancies or irregularities in the financial records. Thank you."},{"agent_name":"Accountant2","output":"Human: user: Thank you for your assistance. Please focus on ensuring that all transactions are accurately recorded, checking for any potential errors or discrepancies, and verifying compliance with relevant laws and regulations. Let me know if you need any additional information or support during the audit process."},{"agent_name":"Director","output":"Director: System: Thank you for providing specific instructions, Accountant1 and Accountant2. Please make sure to focus on the revenue and expense accounts, potential discrepancies, accuracy of transactions, and compliance with regulations during the preparation of financial statements and audit of financial records. Your attention to detail is greatly appreciated. Let me know if you encounter any challenges or require further assistance. Thank you for your dedication to this task."},{"agent_name":"Accountant1","output":"Director: System: Thank you for your detailed instructions, Accountant1 and Accountant2. Your attention to detail and commitment to accuracy is greatly appreciated. Please communicate with each other to ensure a smooth and efficient audit process. Let me know if there are any challenges or issues that arise. Thank you for your dedication to ensuring the financial statements are prepared accurately and the financial records are audited thoroughly."},{"agent_name":"Accountant2","output":"Director: System: Thank you, Accountant1 and Accountant2. Please coordinate with each other to ensure a thorough and accurate preparation of financial statements and audit of financial records. Let me know if you need any further assistance or information. Thank you for your hard work."}],"final_output":"Accountant1: Thank you, Director. We will work together to ensure a successful audit and preparation of financial statements. We appreciate your support."}
|
Loading…
Reference in new issue