Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Building a Chat Interface for Jupyter with LangChain

Building a Chat Interface for Jupyter with LangChain

This folder demonstrates how to build a chat interface for Jupyter notebooks using LangChain and ipywidgets, with an optional JupyterLab extension for production use.

What you’ll learn

Project files

Two approaches

This tutorial shows two ways to add chat to Jupyter:

1. In-Notebook Chat (ipywidgets)

Quick and easy - add chat directly in your notebook using ipywidgets. See jupyter_chat_extension.ipynb.

Pros:

Cons:

A proper JupyterLab sidebar extension with backend endpoint. See jupyterlab_context_chat/.

Pros:

Cons:

For detailed comparison and full tutorial, see blog_jupyter_chat_langchain.md.

Extension setup: jupyterlab_context_chat/SETUP.md

Docker: build + run JupyterLab

From this directory:

cd tutorials/Jupyter_Extension_Langchain
cp .env.example .env
# Edit `.env` and set your API key.
docker compose up --build

Then open:

Notes:

Running the notebook

Open jupyter_chat_extension.ipynb and run it top-to-bottom.

Notes:

Provider configuration

Set env vars in .env (loaded via docker-compose.yml) and restart the container. See .env.example for the supported variables.

Changelog