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.
30 lines
682 B
30 lines
682 B
1 year ago
|
import os
|
||
|
from dotenv import load_dotenv
|
||
1 year ago
|
from swarms import OpenAIChat, Task, ConcurrentWorkflow, Agent
|
||
|
|
||
|
# Load environment variables from .env file
|
||
|
load_dotenv()
|
||
|
|
||
|
# Load environment variables
|
||
|
llm = OpenAIChat(openai_api_key=os.getenv("OPENAI_API_KEY"))
|
||
|
agent = Agent(llm=llm, max_loops=1)
|
||
|
|
||
|
# Create a workflow
|
||
|
workflow = ConcurrentWorkflow(max_workers=5)
|
||
|
|
||
1 year ago
|
task = (
|
||
|
"Generate a report on how small businesses spend money and how"
|
||
|
" can they cut 40 percent of their costs"
|
||
|
)
|
||
|
|
||
1 year ago
|
# Create tasks
|
||
1 year ago
|
task1 = Task(agent, task)
|
||
|
task2 = Task(agent, task)
|
||
|
task3 = Task(agent, task)
|
||
1 year ago
|
|
||
|
# Add tasks to the workflow
|
||
1 year ago
|
workflow.add(tasks=[task1, task2, task3])
|
||
1 year ago
|
|
||
|
# Run the workflow
|
||
|
workflow.run()
|