Learn how to use LangChain tools and utilities with PraisonAI agents.
Use LangChain community tools and utilities directly on PraisonAI agents — no adapter layer required.
from praisonaiagents import Agentfrom langchain_community.utilities import WikipediaAPIWrapperwiki = WikipediaAPIWrapper()agent = Agent(name="Researcher", tools=[wiki.run], instructions="Answer with Wikipedia")agent.start("Summarise quantum computing in two paragraphs")
The user asks a research question; LangChain tools run inside the PraisonAI agent loop.
pip install praisonaiagents langchain-community wikipedia
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 a file
Create a new file app.py with the basic setup:
from praisonaiagents import Agent, Task, AgentTeamfrom langchain_community.utilities import WikipediaAPIWrapper# Create an agent with Wikipedia toolagent = Agent( name="WikiAgent", role="Research Assistant", goal="Search Wikipedia for accurate information", backstory="I am an AI assistant specialized in Wikipedia research", tools=[WikipediaAPIWrapper], reflection=False)# Create a research tasktask = Task( name="wiki_search", description="Research 'Artificial Intelligence' on Wikipedia", expected_output="Comprehensive information from Wikipedia articles", agent=agent)# Create and start the workflowagents = AgentTeam( agents=[agent], tasks=[task])agents.start()
from praisonaiagents import Agent, Task, AgentTeamfrom langchain_community.tools import YouTubeSearchToolfrom langchain_community.utilities import WikipediaAPIWrapper# Create YouTube search agentagent = Agent( name="SearchAgent", role="Research Assistant", goal="Search for information from YouTube", backstory="I am an AI assistant that can search YouTube for relevant videos.", tools=[YouTubeSearchTool], reflection=False)# Create Wikipedia research agentagent2 = Agent( name="WikiAgent", role="Research Assistant", goal="Search for information from Wikipedia", backstory="I am an AI assistant that can search Wikipedia for accurate information.", tools=[WikipediaAPIWrapper], reflection=False)# Create YouTube search tasktask = Task( name="search_task", description="Search for information about 'AI advancements' on YouTube", expected_output="Relevant information from YouTube videos", agent=agent)# Create Wikipedia research tasktask2 = Task( name="wiki_task", description="Search for information about 'AI advancements' on Wikipedia", expected_output="Comprehensive information from Wikipedia articles", agent=agent2)# Create and start the workflowagents = AgentTeam( agents=[agent, agent2], tasks=[task, task2])agents.start()
4
Start Agents
Type this in your terminal to run your agents:
python app.py
1
Install Package
(Upcoming Feature)
Install the PraisonAI package:
pip install "praisonai"
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 a file
Create a new file agents.yaml with the basic setup:
framework: praisonaiprocess: sequentialagents: # Canonical: use 'agents' instead of 'roles' researcher: name: SearchAgent role: Research Assistant goal: Search for information from multiple sources instructions: # Canonical: use 'instructions' instead of 'backstory' I am an AI assistant that can search YouTube and Wikipedia. tools: - youtube_search - wikipedia tasks: search_task: name: search_task description: Search for information about 'AI advancements' on both YouTube and Wikipedia expected_output: Combined information from YouTube videos and Wikipedia articles