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/example.py

32 lines
940 B

from swarms import Swarms
2 years ago
# Retrieve your API key from the environment or replace with your actual key
api_key = os.getenv("OPENAI_API_KEY")
2 years ago
# Initialize Swarms with your API key
swarm = Swarms(api_key)
# Initialize lower level models and tools
llm = swarm.initialize_llm()
tools = swarm.initialize_tools(llm)
# Initialize vector store
vectorstore = swarm.initialize_vectorstore()
# Initialize the worker node
worker_node = swarm.initialize_worker_node(llm, tools, vectorstore)
worker_node.create_agent("AI Assistant", "Assistant", True, {})
# Define an objective
objective = "Find 20 potential customers for a Swarms based AI Agent automation infrastructure"
# Initialize the boss node
boss_node = swarm.initialize_boss_node(llm, vectorstore, agent_executor)
# Create and execute a task
task = boss_node.create_task(objective)
2 years ago
boss_node.execute_task(task)
2 years ago
# Use the worker agent to perform a task
worker_node.run_agent(objective)