This is a Streamlit application that lets you upload PDF documents, analyze their content, and interact with them using a Retrieval-Augmented Generation (RAG) chatbot.
Project description
📄 Document Analysis & RAG Chatbot
This is a Streamlit application that lets you upload PDF documents, analyze their content, and interact with them using a Retrieval-Augmented Generation (RAG) chatbot.
✨ Features
- Document Ingestion: Upload PDF files to the application. The content is extracted using PyMuPDF and saved for analysis.
- Document Analysis Dashboard: Get key insights from your documents, including overall sentiment, readability scores, word counts, and topic modeling using LDA.
- RAG Chatbot: Chat with your documents. The chatbot retrieves relevant text chunks from a ChromaDB vector store and uses an OpenAI large language model to generate answers.
- Dockerized: The application is containerized with Docker for easy deployment and portability.
🚀 Getting Started
Prerequisites
- Docker Desktop: Required to build and run the application in a container.
- OpenAI API Key: An API key is needed to use the OpenAI embeddings and language model.
1. Local Setup (Without Docker)
-
Clone the repository:
git clone <your-repository-url> cd <your-repository-name>
-
Install dependencies:
pip install -r requirements.txt
-
Set your OpenAI API Key: You need to set your OpenAI API key as an environment variable.
- Windows (Command Prompt):
set OPENAI_API_KEY="your_api_key_here"
- macOS/Linux (Terminal):
export OPENAI_API_KEY="your_api_key_here"
- Windows (Command Prompt):
-
Run the application:
streamlit run main.py
2. Docker Setup (Recommended)
Using Docker is the recommended way to run this application, as it ensures all dependencies and configurations are handled consistently.
-
Create
.dockerignore: To prevent unnecessary or sensitive files from being included in your Docker image, create a.dockerignorefile in your project's root directory.# Git .git # Docker Dockerfile .dockerignore # Streamlit config and caches .streamlit .venv .cache # Python-specific files __pycache__/ *.pyc # Data and database directories data/ chroma_db/ -
Build the Docker image: Navigate to your project's root directory in a terminal and run the following command. This will build the image and tag it as
rag-app.docker build -t rag-app .
-
Run the Docker container: Run the container using the following command. This command maps the application's port and sets the OpenAI API key via an environment variable. It also mounts volumes for your
dataandchroma_dbdirectories to persist uploaded documents and the vector database.- Windows:
docker run -p 8501:8501 -e OPENAI_API_KEY="your_api_key_here" -v C:\path\to\your\data:/app/data -v C:\path\to\your\chroma_db:/app/chroma_db rag-app
- macOS/Linux:
docker run -p 8501:8501 -e OPENAI_API_KEY="your_api_key_here" -v /path/to/your/data:/app/data -v /path/to/your/chroma_db:/app/chroma_db rag-app
Note: Replace
C:\path\to\youror/path/to/yourwith the absolute path to your project directory. - Windows:
-
Access the application: Once the container is running, open your web browser and navigate to
http://localhost:8501.
📁 Folder Structure
.
├── data/
│ ├── documents/ # Uploaded PDFs are stored here
│ └── ocr/ # Extracted text (JSON) is stored here
├── chroma_db/ # The persistent ChromaDB vector store
├── .dockerignore # Specifies files to exclude from the Docker image
├── Dockerfile # Instructions for building the Docker image
├── requirements.txt # Python dependencies
└── main.py # Main Streamlit application script
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ofa_technical_task-0.1.0.tar.gz.
File metadata
- Download URL: ofa_technical_task-0.1.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae115e84e7c198cac0700cdb0f55522b789b72325bef9bdfe2aad0ff621d529b
|
|
| MD5 |
da51dadc6bcb572c1ed423fe6adde844
|
|
| BLAKE2b-256 |
00d03567bccc086af3f257663dd4d1b5918bc0ec735ced9a9e3813d45edee9a2
|
File details
Details for the file ofa_technical_task-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ofa_technical_task-0.1.0-py3-none-any.whl
- Upload date:
- Size: 31.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecebd5820c35da0b05350102d0d014c58a45b4fedf48b4392389a42e90ca74b8
|
|
| MD5 |
f64c463f31fb1acb6eb7a4bdde520430
|
|
| BLAKE2b-256 |
f787fac1dc3d2f2d3f73e8c4380e78bc0918c15ec8ebac1756bacfc76cd79e43
|