LangChain AI开发框架 是 AI Skill Hub 本期精选AI工具之一。在 GitHub 上收获超过 16.5k 颗 Star,综合评分 8.2 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。
基于LangChain和LangGraph构建的开源PDF文档AI对话系统。支持智能问答、文档理解和多轮对话,具有完整的Agent工作流框架。适合开发者快速构建文档分析、知识库问答等应用场景。
LangChain AI开发框架 是一款基于 TypeScript 开发的开源工具,专注于 LangChain、LangGraph、PDF处理 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
基于LangChain和LangGraph构建的开源PDF文档AI对话系统。支持智能问答、文档理解和多轮对话,具有完整的Agent工作流框架。适合开发者快速构建文档分析、知识库问答等应用场景。
LangChain AI开发框架 是一款基于 TypeScript 开发的开源工具,专注于 LangChain、LangGraph、PDF处理 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
# 方式一:npm 全局安装 npm install -g ai-pdf-chatbot-langchain # 方式二:npx 直接运行(无需安装) npx ai-pdf-chatbot-langchain --help # 方式三:项目依赖安装 npm install ai-pdf-chatbot-langchain # 方式四:从源码运行 git clone https://github.com/mayooear/ai-pdf-chatbot-langchain cd ai-pdf-chatbot-langchain npm install npm start
# 命令行使用
ai-pdf-chatbot-langchain --help
# 基本用法
ai-pdf-chatbot-langchain [options] <input>
# Node.js 代码中使用
const ai_pdf_chatbot_langchain = require('ai-pdf-chatbot-langchain');
const result = await ai_pdf_chatbot_langchain.run(options);
console.log(result);
# ai-pdf-chatbot-langchain 配置说明 # 查看配置选项 ai-pdf-chatbot-langchain --config-example > config.yml # 常见配置项 # output_dir: ./output # log_level: info # workers: 4 # 环境变量(覆盖配置文件) export AI_PDF_CHATBOT_LANGCHAIN_CONFIG="/path/to/config.yml"
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:
<img width="1096" alt="Screenshot 2025-02-20 at 05 39 55" src="https://github.com/user-attachments/assets/3a9ddea7-b718-476b-bdae-38839be20c12" />
┌─────────────────────┐ 1. Upload PDFs ┌───────────────────────────┐
│Frontend (Next.js) │ ────────────────────> │Backend (LangGraph) │
│ - React UI w/ chat │ │ - Ingestion Graph │
│ - Upload .pdf files │ <────────────────────┤ + Vector embedding via │
└─────────────────────┘ 2. Confirmation │ SupabaseVectorStore │
(storing embeddings in DB)
┌─────────────────────┐ 3. Ask questions ┌───────────────────────────┐
│Frontend (Next.js) │ ────────────────────> │Backend (LangGraph) │
│ - Chat + SSE stream │ │ - Retrieval Graph │
│ - Display sources │ <────────────────────┤ + Chat model (OpenAI) │
└─────────────────────┘ 4. Streamed answers └───────────────────────────┘
- Supabase is used as the vector store to store and retrieve relevant documents at query time. - OpenAI (or other LLM providers) is used for language modeling. - LangGraph orchestrates the "graph" steps for ingestion, routing, and generating responses. - Next.js (React) powers the user interface for uploading PDFs and real-time chat.
The system consists of: - Backend: A Node.js/TypeScript service that contains LangGraph agent "graphs" for: - Ingestion (src/ingestion_graph.ts) - handles indexing/ingesting documents - Retrieval (src/retrieval_graph.ts) - question-answering over the ingested documents - Configuration (src/shared/configuration.ts) - handles configuration for the backend api including model providers and vector stores - Frontend: A Next.js/React app that provides a web UI for users to upload PDFs and chat with the AI. ---
Document objects, then store vector embeddings into a vector database (we use Supabase in this example).---
1. Node.js v18+ (we recommend Node v20). 2. Yarn (or npm, but this monorepo is pre-configured with Yarn). 3. Supabase project (if you plan to store embeddings in Supabase; see Setting up Supabase). - You will need: - SUPABASE_URL - SUPABASE_SERVICE_ROLE_KEY - A table named documents and a function named match_documents for vector similarity search (see LangChain documentation for guidance on setting up the tables). 4. OpenAI API Key (or another LLM provider’s key, supported by LangChain). 5. LangChain API Key (free and optional, but highly recommended for debugging and tracing your LangChain and LangGraph applications). Learn more here
---
git clone https://github.com/mayooear/ai-pdf-chatbot-langchain.git
cd ai-pdf-chatbot-langchain
yarn install
env.example files for details.To deploy your LangGraph agent to a cloud service, you can either use LangGraph's cloud as per this guide or self-host it as per this guide.
The frontend can be deployed to any hosting that supports Next.js (Vercel, Netlify, etc.).
Make sure to set relevant environment variables in your deployment environment. In particular, ensure NEXT_PUBLIC_LANGGRAPH_API_URL is pointing to your deployed backend URL.
Once both services are running:
app/api/ingest route.app/api/chat route to retrieve the most relevant documents from the vector database and use the relevant PDF context (if needed) to answer.The project relies on environment variables to configure keys and endpoints. Each sub-project (backend and frontend) has its own .env.example. Copy these to .env and fill in your details.
1. .env Not Loaded - Make sure you copied .env.example to .env in both backend and frontend. - Check your environment variables are correct and restart the dev server.
2. Supabase Vector Store - Ensure you have configured your Supabase instance with the documents table and match_documents function. Check the official LangChain docs on Supabase integration.
3. OpenAI Errors - Double-check your OPENAI_API_KEY. Make sure you have enough credits/quota.
4. LangGraph Not Running - If yarn langgraph:dev fails, confirm your Node version is >= 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.
本项目是一个基于 LangChain 和 LangGraph 构建的 AI PDF Chatbot & Agent 模板。它实现了一个完整的 RAG(检索增强生成)工作流:能够“摄取”用户上传的 PDF 文档,将文本转换为 Embedding 并存储在 Supabase 向量数据库中,随后利用 OpenAI 或其他 LLM 驱动的智能 Agent 来回答用户查询。该项目作为 O'Reilly 出版书籍《Learning LangChain》的配套示例,非常适合开发者学习如何构建复杂的 AI Agent 编排系统。
本项目具备以下核心功能:1. 文档摄取图(Document Ingestion Graph):自动解析上传的 PDF 并将其转化为 Document 对象,通过向量化后存入 Supabase 数据库;2. 检索图(Retrieval Graph):智能判断用户问题是否需要检索文档,并生成带有原文引用(References)的精准回答;3. 流式响应(Streaming Responses):支持实时流式输出回答,提供极佳的用户交互体验。
在开始之前,请确保您的开发环境已安装以下组件:1. Node.js v18+(推荐使用 v20 版本);2. 包管理工具 Yarn(本项目已预配置 Yarn,亦可使用 npm);3. Supabase 项目:若需使用 Supabase 作为向量数据库存储 Embedding,请提前准备好相关的 Supabase 实例及配置。
请按照以下步骤进行本地安装:1. 克隆仓库:使用 `git clone` 命令将项目下载至本地;2. 安装依赖:在 monorepo 根目录下运行 `yarn install` 完成所有依赖包的安装;3. 环境配置:分别在 backend 和 frontend 目录下找到 `.env.example` 文件,将其复制并重命名为 `.env`,并根据实际情况填写必要的 API 密钥及端点信息。
项目启动后,请按以下流程进行测试:1. 使用 LangGraph Studio UI 与 LangGraph server 进行交互,确保后端工作流逻辑符合预期;2. 访问 http://localhost:3000 进入前端 Chatbot 界面;3. 通过页面底部的上传按钮上传一个小型 PDF 文档,系统将触发 Ingestion Graph 提取文本并将其 Embedding 存入 Supabase;4. 在对话框中提问,即可体验基于文档内容的智能问答。
本项目高度依赖环境变量进行配置。由于采用了 monorepo 架构,backend 和 frontend 各自拥有独立的 `.env.example` 文件。请务必将这些示例文件复制为 `.env` 并填入对应的 API Key、数据库连接字符串等关键参数。特别注意,在部署前端时,必须确保 `NEXT_PUBLIC_LANGGRAPH_API_URL` 正确指向您部署后的后端 API 地址。
常见问题与故障排除:1. 环境变量未生效:请检查是否已将 `.env.example` 正确复制为 `.env`,并确保在 backend 和 frontend 两个目录下都进行了配置,修改后需重启开发服务器;2. Supabase 向量存储异常:请确保您的 Supabase 实例已正确配置了 `documents` 表以及 `match_documents` 函数,以支持向量检索功能。
设计精良的AI Agent框架,集成LangChain生态,代码质量优秀。社区活跃、维护及时,是构建PDF对话应用的优选方案。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
经综合评估,LangChain AI开发框架 在AI工具赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | ai-pdf-chatbot-langchain |
| 原始描述 | 开源AI工作流:AI PDF chatbot agent built with LangChain & LangGraph 。⭐16.5k · TypeScript |
| Topics | LangChainLangGraphPDF处理对话系统工作流自动化TypeScript |
| GitHub | https://github.com/mayooear/ai-pdf-chatbot-langchain |
| License | MIT |
| 语言 | TypeScript |
收录时间:2026-05-14 · 更新时间:2026-05-16 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。