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 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 ```python
from swarms import Agent, Anthropic, AgentRearrange, from swarms import Agent, AgentRearrange, rearrange, Anthropic
## Initialize the workflow
agent = Agent( # Initialize the director agent
agent_name="t",
agent_description=( director = Agent(
"Generate a transcript for a youtube video on what swarms" agent_name="Director",
" are!" system_prompt="Directs the tasks for the workers",
),
system_prompt=(
"Generate a transcript for a youtube video on what swarms"
" are!"
),
llm=Anthropic(), llm=Anthropic(),
max_loops=1, max_loops=1,
autosave=True,
dashboard=False, dashboard=False,
streaming_on=True, streaming_on=True,
verbose=True, verbose=True,
stopping_token="<DONE>", stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="director.json",
) )
agent2 = Agent(
agent_name="t1", # Initialize worker 1
agent_description=(
"Generate a transcript for a youtube video on what swarms" worker1 = Agent(
" are!" agent_name="Worker1",
), system_prompt="Generates a transcript for a youtube video on what swarms are",
llm=Anthropic(), llm=Anthropic(),
max_loops=1, max_loops=1,
system_prompt="Summarize the transcript",
autosave=True,
dashboard=False, dashboard=False,
streaming_on=True, streaming_on=True,
verbose=True, verbose=True,
stopping_token="<DONE>", stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="worker1.json",
) )
agent3 = Agent(
agent_name="t2", # Initialize worker 2
agent_description=( worker2 = Agent(
"Generate a transcript for a youtube video on what swarms" agent_name="Worker2",
" are!" system_prompt="Summarizes the transcript generated by Worker1",
),
llm=Anthropic(), llm=Anthropic(),
max_loops=1, max_loops=1,
system_prompt="Finalize the transcript",
autosave=True,
dashboard=False, dashboard=False,
streaming_on=True, streaming_on=True,
verbose=True, verbose=True,
stopping_token="<DONE>", stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="worker2.json",
) )
# Rearrange the agents # Create a list of agents
rearrange = AgentRearrange( agents = [director, worker1, worker2]
agents=[agent, agent2, agent3],
verbose=True, # Define the flow pattern
# custom_prompt="Summarize the transcript", 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( # Using rearrange function
# pattern="t -> t1, t2 -> t2", output = rearrange(
pattern="t -> t1 -> t2", agents,
default_task=( flow,
"Generate a transcript for a YouTube video on what swarms" "Create a format to express and communicate swarms of llms in a structured manner for youtube",
" are!"
),
t="Generate a transcript for a YouTube video on what swarms are!",
# t2="Summarize the transcript",
# t3="Finalize the transcript",
) )
# print(results)
print(output)
``` ```

Loading…
Cancel
Save