mayooear /ai-pdf-chatbot-langchain

AI PDF chatbot agent built with LangChain & LangGraph

★ 16,582⑂ 3,227👁 160⑃ 105● 301▤ 0
TypeScriptMITCreated 2023-03-17www.youtube.com/watch?v=OF6SolDiEwU
-1
Daily
16,582
stars
3,227
forks
160
watchers
105
prs
301
issues
0
releases

README

AI PDF Chatbot & Agent Powered by LangChain and LangGraph

This monorepo is a customizable template example of an AI chatbot agent that "ingests" PDF documents, stores embeddings in a vector database (Supabase), and then answers user queries using OpenAI (or another LLM provider) utilising LangChain and LangGraph as orchestration frameworks.

This template is also an accompanying example to the book Learning LangChain (O'Reilly): Building AI and LLM applications with LangChain and LangGraph.

 [!IMPORTANT]
 This project is not actively maintained and is kept here for reference.
 Please do not expect responses to new issues or pull requests.

Here's what the Chatbot UI looks like:



 Table of Contents

1. Features
2. Architecture Overview
3. Prerequisites
4. Installation
5. Environment Variables
   - Frontend Variables
   - Backend Variables
6. Local Development
   - Running the Backend
   - Running the Frontend
7. Usage
   - Uploading/Ingesting PDFs
   - Asking Questions
   - Viewing Chat History
8. Production Build & Deployment
9. Customizing the Agent
10. Troubleshooting
11. Next Steps

---

 Features

- Document Ingestion Graph: Upload and parse PDFs into Document objects, then store vector embeddings into a vector database (we use Supabase in this example).
- Retrieval Graph: Handle user questions, decide whether to retrieve documents or give a direct answer, then generate concise responses with references to the retrieved documents.
- Streaming Responses: Real-time streaming of partial responses from the server to the client UI.
- LangGraph Integration: Built using LangGraph’s state machine approach to orchestrate ingestion and retrieval, visualise your agentic workflow, and debug each step of the graph.  
- Next.js Frontend: Allows file uploads, real-time chat, and easy extension with React components and Tailwind.

---

 Architecture Overview

ascii
┌─────────────────────┐    1. Upload PDFs    ┌───────────────────────────┐
│Frontend (Next.js)   │ ──────────────────── │Backend (LangGraph)       │
│ - React UI w/ chat  │                      │ - Ingestion Graph         │
│ - Upload .pdf files │  │Backend (LangGraph)       │
│ - Chat + SSE stream │                      │ - Retrieval Graph         │
│ - Display sources   │ = 18 and that you have all dependencies installed.

5. Network Errors
   - Frontend must point to the correct NEXT_PUBLIC_LANGGRAPH_API_URL. By default, it is http://localhost:2024.

 Next Steps

If you'd like to contribute to this project, feel free to open a pull request. Ensure it is well documented and includes tests in the test files.

If you'd like to learn more about building AI chatbots and agents with LangChain and LangGraph, check out the book Learning LangChain (O'Reilly).

Discussions

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON