apply black formatting to rearrange example

pull/577/head
tad dy 5 months ago
parent ef3be69c1b
commit 23cfe542e8

@ -1,13 +1,18 @@
import os
import asyncio
import os
from dotenv import load_dotenv
load_dotenv()
from swarms.structs import Agent
from swarms.models import Anthropic
from swarms.structs import Agent
from swarms.structs.rearrange import AgentRearrange
llm = Anthropic(anthropic_api_key=os.getenv("ANTHROPIC_API_KEY"), streaming=True)
llm = Anthropic(
anthropic_api_key=os.getenv("ANTHROPIC_API_KEY"), streaming=True
)
async def sequential():
@ -16,7 +21,7 @@ async def sequential():
system_prompt="Generate a blog post like Stephen King",
llm=llm,
dashboard=False,
streaming_on=True
streaming_on=True,
)
agent2 = Agent(
@ -24,7 +29,7 @@ async def sequential():
system_prompt="Summarize the blog post",
llm=llm,
dashboard=False,
streaming_on=True
streaming_on=True,
)
flow = f"{agent1.name} -> {agent2.name}"
@ -42,6 +47,7 @@ async def sequential():
# "Generate a short blog post about Muhammad Ali."
# )
async def parallel():
writer1 = Agent(
@ -55,14 +61,14 @@ async def parallel():
agent_name="Writer 2",
system_prompt="Generate a blog post in the style of Stephen King",
llm=llm,
dashboard=False
dashboard=False,
)
reviewer = Agent(
agent_name="Reviewer",
system_prompt="Select the writer that wrote the best story. There can only be one best story.",
llm=llm,
dashboard=False
dashboard=False,
)
flow = f"{writer1.name}, {writer2.name} -> {reviewer.name}"
@ -71,13 +77,15 @@ async def parallel():
[writer1, writer2, reviewer], flow, verbose=False, logging=False
)
result = await agent_rearrange.astream("Generate a 1 sentence story about Michael Jordan.")
result = await agent_rearrange.astream(
"Generate a 1 sentence story about Michael Jordan."
)
# LEAVING THIS CALL BELOW FOR COMPARISON with "completion-style" .run() approach ;)
# result = agent_rearrange.run(
# "Generate a short blog post about Michael Jordan."
# )
# asyncio.run(sequential())
asyncio.run(parallel())

Loading…
Cancel
Save