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/playground/structs/multi_process_workflow.py

64 lines
1.0 KiB

10 months ago
import os
9 months ago
10 months ago
from dotenv import load_dotenv
9 months ago
from swarms import Agent, Gemini
from swarms.structs.multi_process_workflow import MultiProcessWorkflow
10 months ago
# Load the environment variables
load_dotenv()
# Gemini API key
api_key = os.getenv("GEMINI_API_KEY")
# Initialize LLM
llm = Gemini(
model_name="gemini-pro",
api_key=api_key,
)
# Initialize the agents
finance_agent = Agent(
agent_name="Finance Agent",
llm=llm,
max_loops=1,
system_prompt="Finance",
)
marketing_agent = Agent(
agent_name="Marketing Agent",
llm=llm,
max_loops=1,
system_prompt="Marketing",
)
product_agent = Agent(
agent_name="Product Agent",
llm=llm,
max_loops=1,
system_prompt="Product",
)
other_agent = Agent(
agent_name="Other Agent",
llm=llm,
max_loops=1,
system_prompt="Other",
)
# Swarm
workflow = MultiProcessWorkflow(
agents=[
finance_agent,
marketing_agent,
product_agent,
other_agent,
],
max_workers=5,
autosave=True,
)
# Run the workflow
results = workflow.run("What")