https://github.com/yash-learnerr/pdf-chat-assistant
Build a powerful PDF Chat Assistant using Node.js, LangChain, and Google Gemini. Upload PDFs, extract content, and interact with them using natural language queries powered by Gemini LLM. Ideal for document Q&A, contract analysis, resume review, and more.
https://github.com/yash-learnerr/pdf-chat-assistant
ai-chatbot ai-pdf-reader document-ai document-qa gemini-api google-gemini google-llm langchain langchain-nodejs llm-backend nodejs-llm openai-alternative pdf-chat-assistant pdf-chat-node pdf-chatbot pdf-question-answering rag semantic-search
Last synced: about 2 months ago
JSON representation
Build a powerful PDF Chat Assistant using Node.js, LangChain, and Google Gemini. Upload PDFs, extract content, and interact with them using natural language queries powered by Gemini LLM. Ideal for document Q&A, contract analysis, resume review, and more.
- Host: GitHub
- URL: https://github.com/yash-learnerr/pdf-chat-assistant
- Owner: yash-learnerr
- Created: 2025-07-31T16:36:57.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-01T03:44:14.000Z (10 months ago)
- Last Synced: 2025-08-13T18:29:51.317Z (10 months ago)
- Topics: ai-chatbot, ai-pdf-reader, document-ai, document-qa, gemini-api, google-gemini, google-llm, langchain, langchain-nodejs, llm-backend, nodejs-llm, openai-alternative, pdf-chat-assistant, pdf-chat-node, pdf-chatbot, pdf-question-answering, rag, semantic-search
- Language: JavaScript
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π PDF Chat Assistant using Node.js + LangChain + Google Gemini
**Chat with your PDFs using AI!** This open-source project lets you upload any PDF file and ask natural language questions about its content using **Google Gemini LLM**, **LangChain**, and **Node.js**.
> Ideal for document analysis, contract review, resume Q&A, and building AI-powered document search systems.
---
## β Features
- Upload PDF files and parse content.
- Chunk and embed text using **Gemini Embeddings**.
- Store embeddings in-memory using LangChainβs `MemoryVectorStore`.
- Perform similarity search on user questions.
- Query **Google Gemini** to generate accurate contextual responses.
## π **Powered by**:
`Google Gemini`, `LangChain`, `FAISS`, `Express.js`, and `pdf-parse`
## π **Keywords**:
`PDF Chat Assistant`, `LangChain Node.js`, `Gemini LLM`, `Document Q&A`, `RAG`, `AI Chatbot`, `PDF Parser`, `Semantic Search`
---
## π§° Tech Stack
| Component | Technology |
|----------------|-----------------------------|
| Backend | Node.js (Express) |
| AI/LLM API | Google Gemini (via LangChain)|
| PDF Parsing | `pdf-parse` |
| Embedding Store | LangChain Memory Vector DB |
| Chunking | Manual with configurable size |
---
## π οΈ Installation
```bash
git clone https://github.com/your-username/pdf-chat-gemini.git
cd pdf-chat-gemini
npm install
```
## π Environment Variables
Create a .env file in the root:
```
PORT=3000
GEMINI_API_KEY=your_google_gemini_api_key
```
##### β
You need access to Google AI Studio or Vertex AI to get your Gemini API key.
## π¦ Run the Project
```
node app.js
```
## π¬ API Endpoints
### 1. Upload PDF
```
POST /api/chat/upload
Content-Type: multipart/form-data
Form field: pdf (upload a .pdf file)
```
- Parses PDF
- Extracts text
- Chunks and embeds it into memory
### 2. Ask a Question
```
POST /api/chat/ask
Content-Type: application/json
{
"question": "What is this PDF about?"
}
```
- Returns answer based on the most relevant chunks from the uploaded PDF
#
## π Project Structure
```
pdf-chat-assistant/
βββ app.js
βββ .env
βββ controllers/
β βββ chatController.js
βββ routes/
β βββ chatRoutes.js
βββ services/
β βββ pdfService.js
β βββ embeddingService.js
β βββ geminiService.js
βββ utils/
β βββ chunkText.js
βββ uploads/
βββ vector-store/
```
## π§ How It Works
- Upload: PDF gets parsed and split into chunks.
- Embed: Each chunk is turned into a vector using Gemini Embeddings.
- Store: Vectors are stored in a temporary in-memory vector store.
- Query: User asks a question β similar chunks are retrieved.
- Answer: Gemini responds using those chunks as context.
## π§ͺ Example Usage
Use Postman or Insomnia to:
1. Upload a PDF to `/api/chat/upload`
2. Then POST to `/api/chat/ask` with your question
## Demo Link
[Demo](https://jam.dev/c/b569bc2b-6417-49ad-87ce-5672bbc63a22)
## π License
MIT License
## π Acknowledgements
LangChain
Google Generative AI (Gemini)
pdf-parse