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.
52 lines
1.0 KiB
52 lines
1.0 KiB
import os
|
|
|
|
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 agent
|
|
llm = OpenAIChat(
|
|
temperature=0.5,
|
|
model_name="gpt-4",
|
|
openai_api_key=api_key,
|
|
max_tokens=4000,
|
|
)
|
|
|
|
|
|
# Initialize the agent with the language agent
|
|
agent1 = Agent(llm=llm, max_loops=1)
|
|
|
|
# Create another agent for a different task
|
|
agent2 = Agent(llm=llm, max_loops=1)
|
|
|
|
# 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
|
|
workflow.add(
|
|
agent2,
|
|
"Summarize the generated blog",
|
|
)
|
|
|
|
# Run the workflow
|
|
workflow.run()
|
|
|
|
# Output the results
|
|
for task in workflow.tasks:
|
|
print(f"Task: {task.description}, Result: {task.result}")
|