pull/459/head^2
Kye 12 months ago
parent 47a1592d2a
commit dd1af43013

@ -479,54 +479,40 @@ Sequential Workflow enables you to sequentially execute tasks with `Agent` and t
✅ Utilizes Agent class ✅ Utilizes Agent class
```python ```python
import os from swarms import Agent, SequentialWorkflow, Anthropic
from dotenv import load_dotenv
from swarms import Agent, OpenAIChat, SequentialWorkflow
load_dotenv()
# Load the environment variables
api_key = os.getenv("OPENAI_API_KEY")
# Initialize the language model agent (e.g., GPT-3)
llm = Anthropic()
# Initialize the language agent # Initialize agents for individual tasks
llm = OpenAIChat( agent1 = Agent(
temperature=0.5, model_name="gpt-4", openai_api_key=api_key, max_tokens=4000 agent_name="Blog generator",
system_prompt="Generate a blog post like stephen king",
llm=llm,
max_loops=1,
dashboard=False,
tools=[],
) )
agent2 = Agent(
agent_name="summarizer",
# Initialize the agent with the language agent system_prompt="Sumamrize the blog post",
agent1 = Agent(llm=llm, max_loops=1) llm=llm,
max_loops=1,
# Create another agent for a different task dashboard=False,
agent2 = Agent(llm=llm, max_loops=1) tools=[],
# Create another agent for a different task
agent3 = Agent(llm=llm, max_loops=1)
# Create the workflow
workflow = SequentialWorkflow(max_loops=1)
# Add tasks to the workflow
workflow.add(
agent1,
"Generate a 10,000 word blog on health and wellness.",
) )
# Suppose the next task takes the output of the first task as input # Create the Sequential workflow
workflow.add( workflow = SequentialWorkflow(
agent2, agents=[agent1, agent2], max_loops=1, verbose=False
"Summarize the generated blog",
) )
# Run the workflow # Run the workflow
workflow.run() workflow.run(
"Generate a blog post on how swarms of agents can help businesses grow."
)
# Output the results
for task in workflow.tasks:
print(f"Task: {task.description}, Result: {task.result}")
``` ```

Loading…
Cancel
Save