Transform any document into an intelligent AI assistant with conversation memory and advanced analytics
A production-ready RAG (Retrieval-Augmented Generation) system powered by Google Gemini 2.0 Flash that enables intelligent document interaction with memory-enhanced conversations, smart analytics, and enterprise-grade features.
- Google Gemini 2.0 Flash: Latest AI model for superior responses
- Memory-Enhanced Chat: AI remembers conversation context and learns from interactions
- Smart Search: Hybrid vector + keyword search with conversation memory
- Confidence Scoring: Real-time assessment of response reliability
- Multiple Formats: PDF, Word (.docx), and Text files
- Intelligent Chunking: Context-aware text segmentation
- Metadata Extraction: Automatic document structure analysis
- Caching System: Faster reprocessing of uploaded documents
- Conversation History: Persistent chat memory across sessions
- Learning Insights: AI analyzes question patterns and provides feedback
- Context Awareness: Responses improve based on previous interactions
- Topic Tracking: Automatic identification of discussion themes
- Document Analytics: Word count, reading time, complexity analysis
- Conversation Metrics: Confidence trends, topic analysis
- Memory Insights: Usage patterns and learning effectiveness
- Visual Charts: Interactive plots and graphs using Plotly
- Auto-Configuration: No manual setup required for users
- Environment Variables: Secure API key management
- Error Handling: Robust error management and fallbacks
- Privacy-First: Local processing with no permanent data storage
- Python 3.8 or higher
- Google Gemini API key (Get one here)
- Clone the repository
git clone https://github.com/yourusername/askmypdf-pro.git
cd askmypdf-pro- Install dependencies
pip install -r requirements.txt- Set up environment variables
Create a
.envfile in the project root:
GEMINI_API_KEY=your_gemini_api_key_here- Run the application
streamlit run app.py- Open your browser
Navigate to
http://localhost:8501
Create a requirements.txt file with:
streamlit>=1.28.0
PyPDF2>=3.0.1
python-docx>=0.8.11
numpy>=1.24.0
faiss-cpu>=1.7.4
sentence-transformers>=2.2.2
google-generativeai>=0.3.0
plotly>=5.17.0
pandas>=2.0.0
python-dotenv>=1.0.0- Drag and drop or select PDF, Word, or text files
- Automatic processing with progress indicators
- Support for files up to 50MB
- Ask questions about your document
- Use suggested questions or type custom ones
- Choose response styles: Comprehensive, Concise, or Detailed
- View document composition and structure
- Track conversation confidence and topics
- Monitor AI memory usage and learning patterns
- AI remembers previous questions and context
- Follow-up questions receive enhanced responses
- Conversation history persists during session
| Variable | Description | Required |
|---|---|---|
GEMINI_API_KEY |
Google Gemini API key | Yes |
The application automatically uses:
- Response Generation:
gemini-2.0-flash-exp - Embeddings:
models/embedding-001 - Vector Dimensions: 768
- Chunk Size: 1000 words with 200-word overlap
Main orchestrator for the RAG system.
pipeline = EnhancedRAGPipeline()
result = pipeline.process_document(uploaded_file)
response = pipeline.answer_question(question, style='comprehensive')Handles document embeddings using Google's model.
manager = GeminiEmbeddingManager()
embeddings = manager.create_embeddings_batch(chunks)Vector search with memory enhancement.
store = AdvancedVectorStore(dimension=768)
results = store.search_with_memory(query_embedding, question)- Document Upload: Drag-and-drop with file validation
- Chat Interface: Memory-enhanced conversation
- Analytics Dashboard: Interactive charts and metrics
- Memory Insights: AI learning and usage patterns
- Comprehensive: Full analysis with evidence and citations
- Concise: Quick answers with key points
- Detailed: In-depth analysis with supporting context
# Conversation memory tracking
conversation_memory = [
{
'query': 'user_question',
'relevant_chunks': ['chunk_1', 'chunk_2'],
'response_quality': 0.85,
'timestamp': '2024-01-01T12:00:00'
}
]- Vector Similarity: Semantic understanding
- Keyword Matching: Exact term matching
- Memory Boost: Previous interaction awareness
- Confidence Scoring: Response reliability assessment
- Document composition analysis
- Reading time estimation
- Chunk size distribution
- Conversation confidence trends
- Topic frequency tracking
- Local Processing: Documents processed on your machine
- No Data Persistence: Files not stored permanently
- Secure API Keys: Environment variable management
- Privacy-First Design: Minimal data collection
streamlit run app.pyFROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8501
CMD ["streamlit", "run", "app.py"]Deploy to:
- Streamlit Cloud: Connect GitHub repository
- Heroku: Use provided Procfile
- AWS/GCP: Container deployment
- Railway: Direct GitHub integration
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
pytest tests/
# Format code
black app.py
# Lint code
flake8 app.py- Document Processing: ~2-5 seconds for typical PDFs
- Embedding Generation: ~0.1 seconds per chunk
- Search Response: <1 second for most queries
- Memory Usage: ~200-500MB depending on document size
- Use smaller documents for faster processing
- Enable caching for repeated document uploads
- Adjust chunk size based on document type
- Monitor memory usage for large files
API Key Error
Error: GEMINI_API_KEY not found
Solution: Add your API key to .env file
Memory Issues
Error: Out of memory
Solution: Reduce chunk size or use smaller documents
Slow Processing
Issue: Document processing takes too long
Solution: Enable caching or reduce file size
Enable debug logging:
import logging
logging.basicConfig(level=logging.DEBUG)- Multi-document chat
- Document comparison features
- Advanced visualization
- Export capabilities
- Custom model selection
- Voice input/output
- Mobile optimization
- Collaboration features
- Advanced analytics