From 860df09bc13fd3df64c16bc030504bc614021437 Mon Sep 17 00:00:00 2001 From: Eternal Reclaimer <98760976+kyegomez@users.noreply.github.com> Date: Fri, 10 May 2024 18:11:29 -0700 Subject: [PATCH] Update README.md --- README.md | 88 ++++++++++++++++++++++++++----------------------------- 1 file changed, 42 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 5e7986b1..f7c5a491 100644 --- a/README.md +++ b/README.md @@ -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="", + 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="", + 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="", + 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) ```