You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.4 KiB
62 lines
1.4 KiB
from swarms import Agent, OpenAIChat
|
|
from swarms.structs.mixture_of_agents import MixtureOfAgents
|
|
|
|
# Initialize the director agent
|
|
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",
|
|
)
|
|
|
|
# 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",
|
|
)
|
|
|
|
# Create a list of agents
|
|
agents = [director, accountant1, accountant2]
|
|
|
|
|
|
# Swarm
|
|
swarm = MixtureOfAgents(
|
|
name="Mixture of Accountants",
|
|
agents=agents,
|
|
layers=3,
|
|
final_agent=director,
|
|
)
|
|
|
|
|
|
# Run the swarm
|
|
out = swarm.run("Prepare financial statements and audit financial records")
|
|
print(out)
|