Skip to content

Walid-Ahmed/langchain-docs-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📚 LangChain Docs Chatbot

This project lets you chat with your own documents using:

You upload your documents into a knowledge base folder, the system indexes them, and then you can ask questions in natural language. The chatbot retrieves the most relevant chunks from your docs and answers using AI.


🚀 Features

  • Chat directly with your own documents
  • Uses RAG (Retrieval-Augmented Generation) for accurate answers
  • Interactive Gradio chat UI
  • Document ingestion and chunking with metadata
  • Configurable via .env (no keys in code)

📂 Project Structure

.
├── config.py              # API keys, models, system message
├── gradio_rag_chatbot.py  # Gradio web chatbot
├── rag_chatbot.py         # Console chatbot runner
├── helper.py              # Document loading + chunking
├── requirements.txt       # Python dependencies
└── knowledge-base/        # 📌 Upload your documents here

📥 Where to Upload Your Documents

All documents must go inside the knowledge-base/ folder.

  • Supported format: Markdown (.md)
  • You can organize documents into subfolders. Each subfolder name becomes the doc_type metadata.

Example:

knowledge-base/
├── policies/
│   ├── hr_policy.md
│   └── vacation_rules.md
├── products/
│   ├── productA_specs.md
│   └── productB_specs.md

The chatbot will automatically:

  1. Read all .md files inside knowledge-base/
  2. Split them into chunks
  3. Store them in the Chroma vectorstore
  4. Use them to answer your questions

⚙️ Setup

  1. Clone the repo

    git clone https://github.com/Walid-Ahmed/langchain-docs-chatbot.git
    cd langchain-docs-chatbot
  2. Create a virtual environment

    python3 -m venv venv
    source venv/bin/activate   # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up .env file Create a .env file in the project root:

    # Required
    OPENAI_API_KEY=your_openai_api_key_here
    
    # Optional (used if you want weather + image generation features)
    OPENWEATHER_API_KEY=your_openweather_api_key_here

⚠️ Important:
Never commit your .env file to GitHub (it contains your private API keys).
Make sure .env is included in your .gitignore file:

# .gitignore
.env

▶️ Usage

Web Chatbot (Recommended)

Run:

python gradio_rag_chatbot.py

Open the link (default: http://127.0.0.1:7860) and start chatting with your documents.

Console Chatbot

Run:

python rag_chatbot.py

Ask a single query in the terminal against your knowledge base.


📚 Example

If your knowledge-base/ folder contains:

knowledge-base/
└── policies/
   └── hr_policy.md

You can ask in the chatbot:

"What are the vacation rules in our HR policy?"

The system will retrieve the relevant chunk from hr_policy.md and answer conversationally.


🛠️ Requirements

See requirements.txt.


🙌 Credits

About

RAG-powered chatbot with LangChain, Chroma, OpenAI, and Gradio to chat with your own documents

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages