A RAG-based application that allows you to upload documents, chat with them using natural language, and generate intelligent summaries.
- Python 3.9+ (recommended: Python 3.11)
-
Clone the repository:
git clone <your-repo-url> cd ChatWithDocs
-
Make the run script executable:
chmod +x run.sh
-
Run the application:
./run.sh
That's it! The script will:
- β Create a virtual environment
- β Install all dependencies
- β Start the backend API server
- β Launch the Streamlit frontend
- β Open your browser automatically
If you prefer to set up manually or encounter issues with the script:
# Create virtual environment
python -m venv venv
# Activate it
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activate# Install backend dependencies
cd backend
pip install -r requirements.txt
# Install frontend dependencies
cd ../frontend
pip install -r requirements.txtTerminal 1 - Backend:
cd backend
python main.pyTerminal 2 - Frontend:
cd frontend
streamlit run app.pyChoose one of the following options:
- Get an API key from OpenAI
- In the Streamlit interface:
- Select "openai" as provider
- Choose your model (gpt-4, gpt-3.5-turbo)
- Enter your API key
- Click "Configure LLM"
-
Install Ollama:
# macOS brew install ollama # Linux curl -fsSL https://ollama.ai/install.sh | sh # Windows: Download from https://ollama.ai
-
Start Ollama and pull a model:
# Start Ollama service ollama serve # In another terminal, pull a model ollama pull llama3 # or mistral, phi3, codellama
-
Configure in Streamlit:
- Select "ollama" as provider
- Choose your model (llama3, mistral, etc.)
- Click "Configure LLM"
- Go to the Upload tab
- Drag & drop or select files (PDF, DOCX, TXT)
- Click "Upload and Process"
- Wait for processing to complete
- Go to the Chat tab
- Select a document from the sidebar
- Ask questions like:
- "What is this document about?"
- "What are the main conclusions?"
- "Explain the methodology used"
- "Find information about X"
- Go to the Summary tab
- Select document and summary type:
- General: Main points for general audience
- Executive: Business-focused insights
- Technical: Detailed technical summary
- Bullet Points: Easy-to-scan format
- Choose length (100-1000 words)
- Click "Generate Summary"
- Go to the Analytics tab
- View document statistics
- Check system health
- Monitor chat history
Once running, access the application at:
- Frontend (Streamlit): http://localhost:8501
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
# Ensure you're in the virtual environment
source venv/bin/activate # or venv\Scripts\activate on Windows
# Reinstall dependencies
pip install -r backend/requirements.txt
pip install -r frontend/requirements.txt# Kill existing processes
lsof -ti:8000 | xargs kill -9 # Backend
lsof -ti:8501 | xargs kill -9 # Frontend
# Or use different ports
streamlit run app.py --server.port 8502- Check if backend is running: http://localhost:8000/health
- Ensure both services are running
- Check firewall settings
# Clear vector database if corrupted
rm -rf backend/chroma_db/
rm backend/app_database.db
# Restart application
./run.sh- OpenAI: Verify API key is valid and has credits
- Ollama: Ensure Ollama service is running (
ollama serve) - Check the configuration in Streamlit sidebar
Enable debug information in the Streamlit sidebar:
- Check "Show Debug Info"
- Click "Debug Backend Storage" to see document status
- Click "Debug Vector Store" to check embeddings
- For large documents: Increase chunk size in settings
- For better results: Use OpenAI models (gpt-4)
- For privacy: Use local Ollama models
- For speed: Use smaller models (gpt-3.5-turbo)
ChatWithDocs/
βββ run.sh # Main startup script
βββ backend/
β βββ main.py # FastAPI server
β βββ database.py # SQLite database
β βββ requirements.txt # Python dependencies
β βββ services/ # Business logic
β βββ models/ # Data models
βββ frontend/
β βββ app.py # Streamlit interface
β βββ requirements.txt # Frontend dependencies
βββ chroma_db/ # Vector database (auto-created)
βββ uploads/ # Temporary file storage
βββ .gitignore # Git ignore rules
Create a .env file in the backend directory:
# OpenAI Configuration
OPENAI_API_KEY=your_api_key_here
# Ollama Configuration
OLLAMA_BASE_URL=http://localhost:11434
# Database Configuration
DATABASE_URL=sqlite:///app_database.db
# Vector Store Configuration
CHROMA_PERSIST_DIRECTORY=./chroma_dbEdit configuration in the service files:
- Chunk size:
services/document_processor.py - Similarity threshold:
services/chat_service.py - Model parameters:
services/llm_service.py
- β Multi-format support: PDF, Word, TXT files
- β Intelligent chat: RAG-based document interaction
- β Smart summaries: Multiple summary styles
- β Dual LLM support: OpenAI API + Local Ollama
- β Vector search: Semantic similarity matching
- β Conversation memory: Multi-turn chat history
- β Source attribution: See which parts of documents were used
- β Real-time processing: Instant document analysis
- β Privacy options: Local-only processing with Ollama