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.
32 lines
751 B
32 lines
751 B
1 year ago
|
import os
|
||
|
from dotenv import load_dotenv
|
||
1 year ago
|
from swarms import OpenAIChat, Task, ConcurrentWorkflow, Agent
|
||
1 year ago
|
|
||
|
# Load environment variables from .env file
|
||
|
load_dotenv()
|
||
|
|
||
|
# Load environment variables
|
||
|
llm = OpenAIChat(openai_api_key=os.getenv("OPENAI_API_KEY"))
|
||
1 year ago
|
agent = Agent(
|
||
|
llm=llm,
|
||
|
max_loops=1,
|
||
|
)
|
||
1 year ago
|
|
||
|
# Create a workflow
|
||
|
workflow = ConcurrentWorkflow(max_workers=5)
|
||
|
|
||
|
# Create tasks
|
||
1 year ago
|
task1 = Task(agent=agent, description="What's the weather in miami")
|
||
|
task2 = Task(
|
||
|
agent=agent, description="What's the weather in new york"
|
||
|
)
|
||
|
task3 = Task(agent=agent, description="What's the weather in london")
|
||
1 year ago
|
|
||
|
# Add tasks to the workflow
|
||
|
workflow.add(task1)
|
||
|
workflow.add(task2)
|
||
|
workflow.add(task3)
|
||
|
|
||
1 year ago
|
# Run the workflow and print each task result
|
||
1 year ago
|
workflow.run()
|