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.
swarms/sequential_workflow_example.py

65 lines
1.7 KiB

from swarms.models import OpenAIChat, BioGPT, Anthropic
<<<<<<< HEAD
from swarms.structs import Agent
=======
from swarms.structs import Flow
>>>>>>> 3d3dddaf0c7894ec2df14c51f7dd843c41c878c4
from swarms.structs.sequential_workflow import SequentialWorkflow
# Example usage
api_key = "" # Your actual API key here
# Initialize the language flow
llm = OpenAIChat(
openai_api_key=api_key,
temperature=0.5,
max_tokens=3000,
)
biochat = BioGPT()
# Use Anthropic
anthropic = Anthropic()
# Initialize the agent with the language flow
<<<<<<< HEAD
agent1 = Agent(llm=llm, max_loops=1, dashboard=False)
# Create another agent for a different task
agent2 = Agent(llm=llm, max_loops=1, dashboard=False)
# Create another agent for a different task
agent3 = Agent(llm=biochat, max_loops=1, dashboard=False)
# agent4 = Agent(llm=anthropic, max_loops="auto")
=======
agent1 = Flow(llm=llm, max_loops=1, dashboard=False)
# Create another agent for a different task
agent2 = Flow(llm=llm, max_loops=1, dashboard=False)
# Create another agent for a different task
agent3 = Flow(llm=biochat, max_loops=1, dashboard=False)
# agent4 = Flow(llm=anthropic, max_loops="auto")
>>>>>>> 3d3dddaf0c7894ec2df14c51f7dd843c41c878c4
# Create the workflow
workflow = SequentialWorkflow(max_loops=1)
# Add tasks to the workflow
workflow.add("Generate a 10,000 word blog on health and wellness.", agent1)
# Suppose the next task takes the output of the first task as input
workflow.add("Summarize the generated blog", agent2)
workflow.add("Create a references sheet of materials for the curriculm", agent3)
# Run the workflow
workflow.run()
# Output the results
for task in workflow.tasks:
print(f"Task: {task.description}, Result: {task.result}")