Update README.md

pull/468/head
Eternal Reclaimer 8 months ago committed by GitHub
parent f55c140b5a
commit 860df09bc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1173,82 +1173,78 @@ autoswarm.run("Analyze these financial data and give me a summary")
Inspired by Einops and einsum, this orchestration techniques enables you to map out the relationships between various agents. For example you specify linear and sequential relationships like `a -> a1 -> a2 -> a3` or concurrent relationships where the first agent will send a message to 3 agents all at once: `a -> a1, a2, a3`. You can customize your workflow to mix sequential and concurrent relationships
```python
from swarms import Agent, Anthropic, AgentRearrange,
from swarms import Agent, AgentRearrange, rearrange, Anthropic
## Initialize the workflow
agent = Agent(
agent_name="t",
agent_description=(
"Generate a transcript for a youtube video on what swarms"
" are!"
),
system_prompt=(
"Generate a transcript for a youtube video on what swarms"
" are!"
),
# Initialize the director agent
director = Agent(
agent_name="Director",
system_prompt="Directs the tasks for the workers",
llm=Anthropic(),
max_loops=1,
autosave=True,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="director.json",
)
agent2 = Agent(
agent_name="t1",
agent_description=(
"Generate a transcript for a youtube video on what swarms"
" are!"
),
# Initialize worker 1
worker1 = Agent(
agent_name="Worker1",
system_prompt="Generates a transcript for a youtube video on what swarms are",
llm=Anthropic(),
max_loops=1,
system_prompt="Summarize the transcript",
autosave=True,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="worker1.json",
)
agent3 = Agent(
agent_name="t2",
agent_description=(
"Generate a transcript for a youtube video on what swarms"
" are!"
),
# Initialize worker 2
worker2 = Agent(
agent_name="Worker2",
system_prompt="Summarizes the transcript generated by Worker1",
llm=Anthropic(),
max_loops=1,
system_prompt="Finalize the transcript",
autosave=True,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="worker2.json",
)
# Rearrange the agents
rearrange = AgentRearrange(
agents=[agent, agent2, agent3],
verbose=True,
# custom_prompt="Summarize the transcript",
# Create a list of agents
agents = [director, worker1, worker2]
# Define the flow pattern
flow = "Director -> Worker1 -> Worker2"
# Using AgentRearrange class
agent_system = AgentRearrange(agents=agents, flow=flow)
output = agent_system.run(
"Create a format to express and communicate swarms of llms in a structured manner for youtube"
)
print(output)
# Run the workflow on a task
results = rearrange(
# pattern="t -> t1, t2 -> t2",
pattern="t -> t1 -> t2",
default_task=(
"Generate a transcript for a YouTube video on what swarms"
" are!"
),
t="Generate a transcript for a YouTube video on what swarms are!",
# t2="Summarize the transcript",
# t3="Finalize the transcript",
# Using rearrange function
output = rearrange(
agents,
flow,
"Create a format to express and communicate swarms of llms in a structured manner for youtube",
)
# print(results)
print(output)
```

Loading…
Cancel
Save