co-dev0909 / chatbot-using-rag-and-langchain

Chat with your PDFs using AI! This Streamlit app uses RAG, LangChain, FAISS, and OpenAI to let you ask questions and get answers with page and file references.

Repository from Github https://github.comco-dev0909/chatbot-using-rag-and-langchainRepository from Github https://github.comco-dev0909/chatbot-using-rag-and-langchain

🧠 Chatbot Using RAG and LangChain

A Streamlit-based chatbot powered by Retrieval-Augmented Generation (RAG) and OpenAI. Upload your PDFs and chat with them! This app leverages LangChain, FAISS, and OpenAI’s GPT models to extract and query document content with metadata-aware answers.

App Screenshot


πŸ”§ Features

  • πŸ” Upload multiple PDFs and query across all of them
  • πŸ“„ Metadata-rich answers with filename and page references
  • 🧠 Uses LangChain + FAISS for semantic search
  • πŸ€– Streamlit Chat UI for natural conversation
  • πŸ’Ύ OpenAI API support with streaming responses

πŸ“ Project Structure

.
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md             # ← You're reading it
β”œβ”€β”€ app.py                # Main Streamlit app
β”œβ”€β”€ brain.py              # PDF parsing and vector index logic
β”œβ”€β”€ compare medium.gif    # Optional UI illustration
β”œβ”€β”€ requirements.txt      # Python dependencies
└── thumbnail.webp        # Preview image

πŸš€ Getting Started

1. Clone the Repository

git clone https://github.com/co-dev0909/chatbot-using-rag-and-langchain.git
cd chatbot-using-rag-and-langchain

2. Install Dependencies

pip install -r requirements.txt

3. Set OpenAI API Key

Create a .streamlit/secrets.toml file with:

OPENAI_API_KEY = "your-openai-key"

Or export it via environment variable:

export OPENAI_API_KEY="your-openai-key"

4. Run the App

streamlit run app.py

πŸ“š How It Works

  1. Upload PDFs via the UI
  2. Each PDF is parsed using PyPDF2 and chunked via LangChain’s RecursiveCharacterTextSplitter
  3. Chunks are embedded using OpenAI Embeddings
  4. Stored in a FAISS vector store for semantic similarity search
  5. Queries are matched to top PDF chunks and passed to ChatGPT with context
  6. Answers include file name and page number metadata for citation

πŸ› οΈ Tech Stack


βœ… Example Prompt

"What are the main points from the introduction?"

Answer: The introduction highlights... (example.pdf, page 1)


πŸ“„ License

This project is licensed under the MIT License.


πŸ“¬ Contact

Made with ❀️ by co-dev0909. Contributions welcome!


About

Chat with your PDFs using AI! This Streamlit app uses RAG, LangChain, FAISS, and OpenAI to let you ask questions and get answers with page and file references.

License:MIT License


Languages

Language:Python 100.0%