pull/483/head
Kye Gomez 7 months ago
parent 1142eedeeb
commit 1cb5f8e2a7

@ -169,15 +169,53 @@ For further reading and background information on the concepts used in the `Mixt
#### Example 1: Basic Initialization and Run #### Example 1: Basic Initialization and Run
```python ```python
from swarms import MixtureOfAgents, Agent from swarms import MixtureOfAgents, Agent, OpenAIOpenAIChat
# Define agents # Define agents
agent1 = Agent(name="Agent1") director = Agent(
agent2 = Agent(name="Agent2") agent_name="Director",
final_agent = Agent(name="FinalAgent") system_prompt="Directs the tasks for the accountants",
llm=OpenAIChat(),
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="director.json",
)
# Initialize accountant 1
accountant1 = Agent(
agent_name="Accountant1",
system_prompt="Prepares financial statements",
llm=OpenAIChat(),
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="accountant1.json",
)
# Initialize accountant 2
accountant2 = Agent(
agent_name="Accountant2",
system_prompt="Audits financial records",
llm=OpenAIChat(),
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="accountant2.json",
)
# Initialize the MixtureOfAgents # Initialize the MixtureOfAgents
moe_swarm = MixtureOfAgents(agents=[agent1, agent2], final_agent=final_agent) moe_swarm = MixtureOfAgents(agents=[director, accountant1, accountant2], final_agent=director)
# Run the swarm # Run the swarm
history = moe_swarm.run(task="Perform task X.") history = moe_swarm.run(task="Perform task X.")
@ -187,19 +225,55 @@ print(history)
#### Example 2: Verbose Output and Auto-Save #### Example 2: Verbose Output and Auto-Save
```python ```python
from swarms import MixtureOfAgents, Agent from swarms import MixtureOfAgents, Agent, OpenAIOpenAIChat
# Define Agents
# Define agents
director = Agent(
agent_name="Director",
system_prompt="Directs the tasks for the accountants",
llm=OpenAIChat(),
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="director.json",
)
# Define # Initialize accountant 1
accountant1 = Agent(
agent_name="Accountant1",
system_prompt="Prepares financial statements",
llm=OpenAIChat(),
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="accountant1.json",
)
agents # Initialize accountant 2
agent1 = Agent(name="Agent1") accountant2 = Agent(
agent2 = Agent(name="Agent2") agent_name="Accountant2",
final_agent = Agent(name="FinalAgent") system_prompt="Audits financial records",
llm=OpenAIChat(),
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="accountant2.json",
)
# Initialize the MixtureOfAgents with verbose output and auto-save enabled # Initialize the MixtureOfAgents with verbose output and auto-save enabled
moe_swarm = MixtureOfAgents( moe_swarm = MixtureOfAgents(
agents=[agent1, agent2], agents=[director, accountant1, accountant2],
final_agent=final_agent, final_agent=director,
verbose=True, verbose=True,
auto_save=True auto_save=True
) )
@ -212,17 +286,55 @@ print(history)
#### Example 3: Custom Rules and Multiple Layers #### Example 3: Custom Rules and Multiple Layers
```python ```python
from swarms import MixtureOfAgents, Agent from swarms import MixtureOfAgents, Agent, OpenAIOpenAIChat
# Define agents # Define agents
agent1 = Agent(name="Agent1") # Initialize the director agent
agent2 = Agent(name="Agent2") director = Agent(
final_agent = Agent(name="FinalAgent") agent_name="Director",
system_prompt="Directs the tasks for the accountants",
llm=OpenAIChat(),
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="director.json",
)
# Initialize accountant 1
accountant1 = Agent(
agent_name="Accountant1",
system_prompt="Prepares financial statements",
llm=OpenAIChat(),
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="accountant1.json",
)
# Initialize accountant 2
accountant2 = Agent(
agent_name="Accountant2",
system_prompt="Audits financial records",
llm=OpenAIChat(),
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="accountant2.json",
)
# Initialize the MixtureOfAgents with custom rules and multiple layers # Initialize the MixtureOfAgents with custom rules and multiple layers
moe_swarm = MixtureOfAgents( moe_swarm = MixtureOfAgents(
agents=[agent1, agent2], agents=[director, accountant1, accountant2],
final_agent=final_agent, final_agent=director,
layers=5, layers=5,
rules="Custom rules for the swarm" rules="Custom rules for the swarm"
) )

Loading…
Cancel
Save