Skip to content

ms-shashank/AskMyPDF-Pro---Advanced-AI-Document-Assistant

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ AskMyPDF Pro - Advanced AI Document Assistant

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.

✨ Key Features

πŸ€– Advanced AI Capabilities

  • 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

πŸ“„ Document Processing

  • 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

🧠 Memory & Learning

  • 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

πŸ“Š Analytics Dashboard

  • 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

πŸ”§ Enterprise Features

  • 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

πŸš€ Quick Start

Prerequisites

Installation

  1. Clone the repository
git clone https://github.com/yourusername/askmypdf-pro.git
cd askmypdf-pro
  1. Install dependencies
pip install -r requirements.txt
  1. Set up environment variables Create a .env file in the project root:
GEMINI_API_KEY=your_gemini_api_key_here
  1. Run the application
streamlit run app.py
  1. Open your browser Navigate to http://localhost:8501

πŸ“¦ Dependencies

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

🎯 Usage Guide

1. Upload Document

  • Drag and drop or select PDF, Word, or text files
  • Automatic processing with progress indicators
  • Support for files up to 50MB

2. Start Chatting

  • Ask questions about your document
  • Use suggested questions or type custom ones
  • Choose response styles: Comprehensive, Concise, or Detailed

3. Explore Analytics

  • View document composition and structure
  • Track conversation confidence and topics
  • Monitor AI memory usage and learning patterns

4. Memory Features

  • AI remembers previous questions and context
  • Follow-up questions receive enhanced responses
  • Conversation history persists during session

πŸ”§ Configuration

Environment Variables

Variable Description Required
GEMINI_API_KEY Google Gemini API key Yes

Model Configuration

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

πŸ“– API Reference

Core Classes

EnhancedRAGPipeline

Main orchestrator for the RAG system.

pipeline = EnhancedRAGPipeline()
result = pipeline.process_document(uploaded_file)
response = pipeline.answer_question(question, style='comprehensive')

GeminiEmbeddingManager

Handles document embeddings using Google's model.

manager = GeminiEmbeddingManager()
embeddings = manager.create_embeddings_batch(chunks)

AdvancedVectorStore

Vector search with memory enhancement.

store = AdvancedVectorStore(dimension=768)
results = store.search_with_memory(query_embedding, question)

🎨 UI Components

Main Interface

  • 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

Response Styles

  • Comprehensive: Full analysis with evidence and citations
  • Concise: Quick answers with key points
  • Detailed: In-depth analysis with supporting context

πŸ” Advanced Features

Memory System

# Conversation memory tracking
conversation_memory = [
    {
        'query': 'user_question',
        'relevant_chunks': ['chunk_1', 'chunk_2'],
        'response_quality': 0.85,
        'timestamp': '2024-01-01T12:00:00'
    }
]

Smart Search

  • Vector Similarity: Semantic understanding
  • Keyword Matching: Exact term matching
  • Memory Boost: Previous interaction awareness
  • Confidence Scoring: Response reliability assessment

Analytics Metrics

  • Document composition analysis
  • Reading time estimation
  • Chunk size distribution
  • Conversation confidence trends
  • Topic frequency tracking

πŸ›‘οΈ Security & Privacy

  • 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

πŸš€ Deployment

Local Development

streamlit run app.py

Docker Deployment

FROM python:3.9-slim

WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .
EXPOSE 8501

CMD ["streamlit", "run", "app.py"]

Cloud Deployment

Deploy to:

  • Streamlit Cloud: Connect GitHub repository
  • Heroku: Use provided Procfile
  • AWS/GCP: Container deployment
  • Railway: Direct GitHub integration

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

# Install development dependencies
pip install -r requirements-dev.txt

# Run tests
pytest tests/

# Format code
black app.py

# Lint code
flake8 app.py

πŸ“Š Performance

Benchmarks

  • 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

Optimization Tips

  • 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

πŸ› Troubleshooting

Common Issues

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

Debug Mode

Enable debug logging:

import logging
logging.basicConfig(level=logging.DEBUG)

πŸ“ˆ Roadmap

Version 2.0 (Coming Soon)

  • Multi-document chat
  • Document comparison features
  • Advanced visualization
  • Export capabilities
  • Custom model selection

Version 2.1

  • Voice input/output
  • Mobile optimization
  • Collaboration features
  • Advanced analytics

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%