Create multiple AI agents that can work together in just a few lines of code!
Code
No Code
1
Install Package
First, install the PraisonAI Agents package:
pip install praisonaiagents duckduckgo_search
2
Set API Key
Set your OpenAI API key as an environment variable in your terminal:
export OPENAI_API_KEY="${OPENAI_API_KEY:?Set OPENAI_API_KEY in your shell}"
3
Create Your Agents
from praisonaiagents import Agent, AgentTeamsummarise_agent = Agent(instructions="Summarise Photosynthesis")agents = AgentTeam(agents=[summarise_agent])agents.start()
# Agent with Internet Search Toolfrom praisonaiagents import Agent, AgentTeamresearch_agent = Agent(instructions="Research about AI 2024", tools=[Tools.internet_search])summarise_agent = Agent(instructions="Summarise research agent's findings")agents = AgentTeam(agents=[research_agent, summarise_agent])agents.start()
4
Run Your Agents
Execute your agents by running:
python app.py
1
Install Package
First, install the PraisonAI Agents package:
pip install praisonaiagents duckduckgo_search
2
Set API Key
Set your OpenAI API key as an environment variable in your terminal:
export OPENAI_API_KEY="${OPENAI_API_KEY:?Set OPENAI_API_KEY in your shell}"
3
Create Your Agents
# Create a new file `agents.yaml` with the following content:agents: # Canonical summarise_agent instructions: Summarise Photosynthesis
# Create a new file `agents.yaml` with the following content:# Agent with Internet Search Toolagents: # Canonical research_agent instructions: Research about AI 2024 tools: - internet_search summarise_agent instructions: Summarise research agent's findings
4
Run Your Agents
Execute your agents by running:
python app.py
Prerequisites
Python 3.10 or higher
OpenAI API key. Generate OpenAI API key here. Use Other models using this guide.
# Simple instructionsresearch_agent = Agent( instructions="Research about climate change")
# Detailed instructionsresearch_agent = Agent( instructions=""" You are a research agent focused on gathering information about: 1. Latest AI developments in 2024 2. Major breakthroughs in machine learning 3. New AI applications in industry Provide detailed and accurate information from reliable sources. """)
# Research agentresearcher = Agent( instructions="Research latest developments in quantum computing", tools=[Tools.internet_search])# Analysis agentanalyst = Agent( instructions="Analyze and explain the research findings in simple terms")agents = AgentTeam(agents=[researcher, analyst])
# Data collectorcollector = Agent( instructions="Collect information about renewable energy", tools=[Tools.internet_search])# Summarizersummarizer = Agent( instructions="Create a concise summary of the collected information")# Report writerwriter = Agent( instructions="Write a detailed report based on the summary")agents = AgentTeam(agents=[collector, summarizer, writer])