HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //opt/PraisonAI/docs/tools/langchain_tools.mdx
---
title: "LangChain Agent"
sidebarTitle: "LangChain Agent"
description: "Learn how to use LangChain tools and utilities with PraisonAI agents."
icon: "link-simple"
---

## Quick Start

<Tabs>
  <Tab title="Code">
    <Steps>
        <Step title="Install Package">
            First, install the required packages:
            ```bash
            pip install praisonaiagents langchain-community wikipedia youtube-search
            ```
        </Step>

        <Step title="Set API Key">
            Set your OpenAI API key as an environment variable in your terminal:
            ```bash
            export OPENAI_API_KEY=your_api_key_here
            ```
        </Step>

        <Step title="Create a file">
            Create a new file `app.py` with the basic setup:
<CodeGroup>
  ```python Single Tool
from praisonaiagents import Agent
from langchain_community.utilities import WikipediaAPIWrapper

wiki_agent = Agent(
    instructions="You are a wikipedia research Agent",
    tools=[WikipediaAPIWrapper]
)

wiki_agent.start("Research 'Artificial Intelligence' on Wikipedia")
```

```python Multiple Tools
from praisonaiagents import Agent, PraisonAIAgents
from langchain_community.utilities import WikipediaAPIWrapper
from langchain_community.tools import YouTubeSearchTool

youtube_agent = Agent(
    instructions="Search for information about 'AI advancements' on YouTube",
    tools=[YouTubeSearchTool]
)

wiki_agent = Agent(
    instructions="Research 'Artificial Intelligence' on Wikipedia",
    tools=[WikipediaAPIWrapper]
)

agents = PraisonAIAgents(agents=[youtube_agent, wiki_agent])
agents.start()
```
</CodeGroup>
        </Step>

        <Step title="Start Agents">
            Type this in your terminal to run your agents:
            ```bash
            python app.py
            ```
        </Step>
    </Steps>
  </Tab>
  <Tab title="No Code">
    <Steps>
        <Step title="Install Package">
            (Upcoming Feature)
            Install the PraisonAI package:
            ```bash
            pip install "praisonai"
            ```
        </Step>
        <Step title="Set API Key">
            Set your OpenAI API key as an environment variable in your terminal:
            ```bash
            export OPENAI_API_KEY=your_api_key_here
            ```
        </Step>
        <Step title="Create a file">
            Create a new file `agents.yaml` with the basic setup:
```yaml
framework: praisonai
process: sequential
roles:
  researcher:
    name: SearchAgent
    role: Research Assistant
    goal: Search for information from multiple sources
    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
```
        </Step>
        <Step title="Start Agents">
            Type this in your terminal to run your agents:
```bash
praisonai agents.yaml
```
        </Step>
    </Steps>
  </Tab>
</Tabs>

<Note>
  **Requirements**
  - Python 3.10 or higher
  - OpenAI API key. Generate OpenAI API key [here](https://platform.openai.com/api-keys)
  - LangChain compatible tools and utilities
</Note>

## Understanding LangChain Integration

<Card title="What is LangChain Integration?" icon="question">
  LangChain integration enables agents to:
  - Use LangChain's extensive tool ecosystem
  - Access various data sources and APIs
  - Leverage pre-built utilities and wrappers
  - Combine multiple tools in a single agent
  - Extend agent capabilities with community tools
</Card>

## Features

<CardGroup cols={2}>
  <Card title="Tool Integration" icon="plug">
    Seamlessly use LangChain tools with PraisonAI agents.
  </Card>
  <Card title="Multiple Sources" icon="database">
    Access various data sources through LangChain utilities.
  </Card>
  <Card title="Community Tools" icon="users">
    Leverage the extensive LangChain community ecosystem.
  </Card>
  <Card title="Custom Tools" icon="wrench">
    Create and integrate custom LangChain tools.
  </Card>
</CardGroup>

## LangChain Tools with Wrappers

<Note>
  - LangChain tools with wrappers can be directly used as Tools without modification.
  - PraisonAI will automatically detect the tool and use it.
  - Some exceptions apply where it doesn't work.
</Note>

### Example Wrapper Usage

```bash
pip install langchain-community google-search-results
export SERPAPI_API_KEY=your_api_key_here
export OPENAI_API_KEY=your_api_key_here
```

```python
from praisonaiagents import Agent, PraisonAIAgents
from langchain_community.utilities import SerpAPIWrapper

data_agent = Agent(instructions="Search about AI job trends in 2025", tools=[SerpAPIWrapper])
editor_agent = Agent(instructions="Write a blog article")

agents = PraisonAIAgents(agents=[data_agent, editor_agent])
agents.start()
```

### Example without Wrapper Usage

```bash
pip install langchain-community 
export BRAVE_SEARCH_API=your_api_key_here
export OPENAI_API_KEY=your_api_key_here
```

```python
from praisonaiagents import Agent, PraisonAIAgents
from langchain_community.tools import BraveSearch
import os

def search_brave(query: str):
    """Searches using BraveSearch and returns results."""
    api_key = os.environ['BRAVE_SEARCH_API']
    tool = BraveSearch.from_api_key(api_key=api_key, search_kwargs={"count": 3})
    return tool.run(query)

data_agent = Agent(instructions="Search about AI job trends in 2025", tools=[search_brave])
editor_agent = Agent(instructions="Write a blog article")
agents = PraisonAIAgents(agents=[data_agent, editor_agent])
agents.start()
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Memory Integration" icon="brain" href="../concepts/memory">
    Learn how to combine LangChain tools with agent memory
  </Card>
  <Card title="Custom Tools" icon="wrench" href="./tools">
    Create your own custom tools for agents
  </Card>
</CardGroup>

<Note>
  For optimal results, ensure all required dependencies are installed and API keys are properly configured for each tool.
</Note>

## With More Detailed Instructions

<Tabs>
  <Tab title="Code">
    <Steps>
        <Step title="Install Package">
            First, install the required packages:
            ```bash
            pip install praisonaiagents langchain-community wikipedia
            ```
        </Step>

        <Step title="Set API Key">
            Set your OpenAI API key as an environment variable in your terminal:
            ```bash
            export OPENAI_API_KEY=your_api_key_here
            ```
        </Step>

        <Step title="Create a file">
            Create a new file `app.py` with the basic setup:
<CodeGroup>
  ```python Single Tool
  from praisonaiagents import Agent, Task, PraisonAIAgents
  from langchain_community.utilities import WikipediaAPIWrapper

  # Create an agent with Wikipedia tool
  agent = Agent(
      name="WikiAgent",
      role="Research Assistant",
      goal="Search Wikipedia for accurate information",
      backstory="I am an AI assistant specialized in Wikipedia research",
      tools=[WikipediaAPIWrapper],
      self_reflect=False
  )

  # Create a research task
  task = Task(
      name="wiki_search",
      description="Research 'Artificial Intelligence' on Wikipedia",
      expected_output="Comprehensive information from Wikipedia articles",
      agent=agent
  )

  # Create and start the workflow
  agents = PraisonAIAgents(
      agents=[agent],
      tasks=[task],
      verbose=True
  )

  agents.start()
  ```

  ```python Multiple Tools
  from praisonaiagents import Agent, Task, PraisonAIAgents
  from langchain_community.tools import YouTubeSearchTool
  from langchain_community.utilities import WikipediaAPIWrapper

  # Create YouTube search agent
  agent = 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],
      self_reflect=False
  )

  # Create Wikipedia research agent
  agent2 = 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],
      self_reflect=False
  )

  # Create YouTube search task
  task = 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 task
  task2 = 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 workflow
  agents = PraisonAIAgents(
      agents=[agent, agent2],
      tasks=[task, task2],
      verbose=True
  )

  agents.start()
  ```
</CodeGroup>
        </Step>

        <Step title="Start Agents">
            Type this in your terminal to run your agents:
            ```bash
            python app.py
            ```
        </Step>
    </Steps>
  </Tab>
  <Tab title="No Code">
    <Steps>
        <Step title="Install Package">
            (Upcoming Feature)
            Install the PraisonAI package:
            ```bash
            pip install "praisonai"
            ```
        </Step>
        <Step title="Set API Key">
            Set your OpenAI API key as an environment variable in your terminal:
            ```bash
            export OPENAI_API_KEY=your_api_key_here
            ```
        </Step>
        <Step title="Create a file">
            Create a new file `agents.yaml` with the basic setup:
```yaml
framework: praisonai
process: sequential
roles:
  researcher:
    name: SearchAgent
    role: Research Assistant
    goal: Search for information from multiple sources
    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
```
        </Step>
        <Step title="Start Agents">
            Type this in your terminal to run your agents:
```bash
praisonai agents.yaml
```
        </Step>
    </Steps>
  </Tab>
</Tabs>