Frameworks
LangChain
Use Humanlayer with LangChain
Overview
Humanlayer integrates seamlessly with LangChain to add human oversight to your AI applications. This guide shows you how to use Humanlayer with LangChain.
Installation
Install the required packages:
Basic Example
Let’s create a customer onboarding assistant that sends emails with human oversight.
How it Works
- We create a HumanLayer instance with a Slack contact channel for approvals
- Define two functions:
get_info_about_customer
: Gets customer onboarding statussend_email
: Sends an email (requires approval)
- Create LangChain tools from these functions
- Initialize a LangChain agent with the tools
- The agent will request approval before sending any emails
Running the Example
- Set up your environment variables in
.env
- Configure your Slack channel ID in the
contact_channel
- Run the example:
When the agent attempts to send an email, it will pause and request approval through Slack.
Next Steps
- Learn more about require_approval
- Configure contact channels
- Explore response options
- Try the human-as-tool pattern
For more framework examples, see https://github.com/humanlayer/humanlayer/tree/main/examples