Skip to content

Latest commit

Β 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– AI Knowledge Assistant

An AI-powered Knowledge Assistant that allows users to upload PDF documents, generate embeddings, and chat with their documents using Retrieval-Augmented Generation (RAG).

The system retrieves relevant document chunks, provides accurate answers, and includes source citations with page references for transparency and trust.


🌐 Live Demo

https://ai-knowledge-assistant-project.streamlit.app/


✨ Features

πŸ“„ Document Upload

  • Upload PDF documents securely.
  • Extract text from PDF pages automatically.
  • Store document metadata and content in Supabase.

🧠 Intelligent Retrieval

  • Generate embeddings using Sentence Transformers.
  • Perform semantic similarity search.
  • Retrieve the most relevant document chunks.

πŸ’¬ AI-Powered Chat

  • Ask questions in natural language.
  • Get answers based only on uploaded documents.
  • Maintain conversation history.

πŸ“š Source Citations

  • Every answer includes:
    • Source document name
    • Page number
  • Improves transparency and trustworthiness.

πŸ” Retrieval-Augmented Generation (RAG)

  • Query embeddings generated from user questions.
  • Relevant chunks retrieved from vector database.
  • Context sent to the LLM for grounded responses.

πŸ‘€ User Authentication

  • User Signup
  • User Login
  • Secure password hashing with bcrypt

πŸ“œ Conversation History

  • Save previous conversations.
  • Resume old chats anytime.
  • Delete conversations when needed.

πŸ“‚ Document Management

  • View uploaded documents.
  • Delete documents.
  • Generate embeddings from uploaded files.

πŸ—οΈ System Architecture

User Query
    β”‚
    β–Ό
Generate Query Embedding
    β”‚
    β–Ό
Vector Search (Supabase)
    β”‚
    β–Ό
Retrieve Relevant Chunks
    β”‚
    β–Ό
Build Context
    β”‚
    β–Ό
Groq LLM (Qwen 3 32B)
    β”‚
    β–Ό
Answer + Source Citations

πŸ› οΈ Tech Stack

Frontend

  • Streamlit

Backend

  • Python

Database

  • Supabase

AI Models

  • Groq (Qwen/Qwen3-32B)

Embedding Model

  • sentence-transformers/all-MiniLM-L6-v2

PDF Processing

  • PyMuPDF

Authentication

  • bcrypt

πŸ“ Project Structure

β”œβ”€β”€ src/ 
    β”œβ”€β”€ UI/ 
    β”‚   β”œβ”€β”€ __init__.py
    β”‚   β”œβ”€β”€ __pycache__/ 
    β”‚   β”‚   β”œβ”€β”€ base_layout.cpython-313.pyc
    β”‚   β”‚   └── base_layout.cpython-313.pyc.2414922744208
    β”‚   └── base_layout.py 
    β”œβ”€β”€ screens/ (5200 tokens)
    β”‚   β”œβ”€β”€ __init__.py
    β”‚   β”œβ”€β”€ __pycache__/ 
    β”‚   β”‚   β”œβ”€β”€ Login.cpython-313.pyc
    β”‚   β”‚   └── Signup.cpython-313.pyc
    β”‚   β”œβ”€β”€ Setting.py
    β”‚   β”œβ”€β”€ Documents.py 
    β”‚   β”œβ”€β”€ History.py 
    β”‚   β”œβ”€β”€ Home.py 
    β”‚   β”œβ”€β”€ Chat.py 
    β”‚   β”œβ”€β”€ Upload.py 
    β”‚   β”œβ”€β”€ Login.py 
    β”‚   └── Signup.py 
    β”œβ”€β”€ database/ 
    β”‚   β”œβ”€β”€ __init__.py
    β”‚   β”œβ”€β”€ config.py
    β”‚   └── db.py 
    β”œβ”€β”€ assets/ 
    β”‚   β”œβ”€β”€ user_logo_img.png
    β”‚   β”œβ”€β”€ right_panel_img.png
    β”‚   └── Signup_right_panel_img.jpg
    └── RAG/ (2400 tokens)
    β”‚   β”œβ”€β”€ ingestion/ 
    β”‚       β”œβ”€β”€ text_cleaner.py 
    β”‚       └── chunker.py 
    β”‚   β”œβ”€β”€ embeddings/ 
    β”‚       └── embedder.py 
    β”‚   β”œβ”€β”€ Generation/ 
    β”‚       β”œβ”€β”€ searchtool.py 
    β”‚       β”œβ”€β”€ agent.py 
    β”‚       └── generation_pipline.py 
    β”‚   β”œβ”€β”€ retrieval/ 
    β”‚       └── retriever.py 
    β”‚   └── pipline/ 
    β”‚       └── ragpipline.py 
β”œβ”€β”€ .gitignore
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .streamlit/ 
    └── config.toml
└── app.py 

βš™οΈ Installation

1. Clone Repository

git clone https://github.com/your-username/AI-Knowledge-Assistant.git
cd AI-Knowledge-Assistant

2. Create Virtual Environment

python -m venv venv

Activate:

venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

πŸ” Environment Variables

Create:

.streamlit/secrets.toml

Add:

SUPABASE_URL="your_supabase_url"
SUPABASE_KEY="your_supabase_key"
GROQ_API_KEY="your_groq_api_key"

▢️ Run Application

streamlit run app.py

πŸ“‹ Workflow

Upload Phase

  1. User uploads PDF.
  2. PDF text is extracted.
  3. Pages stored in Supabase.
  4. Text cleaned.
  5. Text chunked.
  6. Embeddings generated.
  7. Embeddings stored in database.

Retrieval Phase

  1. User asks a question.
  2. Query embedding generated.
  3. Similar chunks retrieved.
  4. Context built from chunks.
  5. Context sent to LLM.
  6. Response returned with citations.

🎯 Example Questions

  • Summarize the document.
  • What are the main conclusions?
  • What is the leave policy?
  • Explain chapter 3.
  • What benefits are mentioned?
  • List important dates from the document.

πŸ”’ Security

  • Passwords hashed using bcrypt.
  • User documents isolated by user ID.
  • Secure API key management through Streamlit Secrets.
  • Citation-based responses reduce hallucinations.

πŸš€ Future Improvements

  • Multi-document chat
  • Hybrid Search (Keyword + Vector)
  • Reranking
  • OCR Support
  • Document Summarization
  • Multi-LLM Support
  • Bookmark System
  • Citation Highlighting
  • Streaming Responses
  • Role-Based Access Control

πŸ‘¨β€πŸ’» Author

Bhupati Nadar

GitHub: https://github.com/BhupatiNadar


⭐ Support

If you found this project useful:

⭐ Star the repository

🍴 Fork the project

πŸ› οΈ Contribute improvements


Built with ❀️ using Streamlit, Supabase, Groq, and RAG.

About

AI-powered Knowledge Assistant that lets users upload PDF documents, generate embeddings, and chat with their knowledge base using Retrieval-Augmented Generation (RAG) with source citations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages