Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ“ AI-Assistant-Self Tutoring

A self-tutoring AI assistant with document grounding, knowledge graphs, and deep research capabilities. Upload your learning materials and get intelligent, cited answers from your documents. image

Python Flask License


✨ Key Features

  • πŸ“„ Document-Grounded Answers - Responses based ONLY on your uploaded documents
  • πŸ” Hybrid RAG Search - Combines vector similarity + knowledge graph traversal
  • πŸ•ΈοΈ Knowledge Graph - Builds entity relationships using Neo4j (optional)
  • πŸ”¬ Deep Research - Web search + document synthesis
  • πŸ€– Local LLM - Uses Ollama (no API keys needed)
  • πŸ›‘οΈ Security Guardrails - Configurable content filtering and safety checks
  • πŸ’Ύ Large File Support - Up to 50MB per document

πŸš€ Quick Start

Prerequisites

  • Python 3.10+
  • Ollama - Download here
  • Neo4j (optional) - For knowledge graph features
  • Docker (optional) - For containerized deployment

Installation

Linux/macOS:

# Clone the repository
git clone <repository-url>


# Make scripts executable
chmod +x startup.sh 

# Run the startup script (handles everything automatically)
./startup.sh

Windows:

REM Clone the repository
git clone <repository-url>


REM Run the startup script
startup.bat

The startup script will:

  1. βœ… Check system requirements
  2. βœ… Verify Ollama is running
  3. βœ… Check/download required models
  4. βœ… Install Python dependencies
  5. βœ… Start the application

Access the application at: http://localhost:5000


πŸ“– Usage

Basic Workflow

  1. Start the Application

    ./startup.sh
  2. Upload Documents

    • Go to http://localhost:5000
    • Upload PDFs, DOCX, TXT, or other supported formats
    • Maximum size: 50MB per file
  3. Ask Questions

    • Type your question in the chat interface
    • Get answers grounded in your documents
    • See source citations for each answer

Supported File Formats

  • πŸ“„ PDF
  • πŸ“ DOCX
  • πŸ“ƒ TXT, MD
  • πŸ“Š CSV, JSON
  • 🌐 HTML, XML

βš™οΈ Configuration

Operating Modes

Fast Mode (Default) - Vector search only, no knowledge graph

./startup.sh --fast

Full Mode - With knowledge graph (requires Neo4j)

./startup.sh --full

Docker Mode - Containerized deployment

./startup.sh --docker

Environment Variables

Create a .env file (copy from .env.example):

# LLM Configuration
LLM_MODEL=llama3.2:3b                 # Recommended: 3b or 8b variant
EMBEDDING_MODEL=nomic-embed-text      # Most reliable option

# Ollama Connection
OLLAMA_HOST=http://localhost:11434

# Optional: Neo4j (for knowledge graph)
# ENABLE_KNOWLEDGE_GRAPH=true
# NEO4J_URI=bolt://localhost:7687
# NEO4J_USER=neo4j
# NEO4J_PASSWORD=your-password

Model Recommendations

Model Size RAM Required Best For Performance
llama3.2:3b 2GB 4GB+ Balanced use ⭐⭐⭐⭐ Recommended
llama3:8b 5GB 8GB+ High accuracy ⭐⭐⭐⭐⭐ Best quality
qwen2.5:7b 4GB 8GB+ Technical docs ⭐⭐⭐⭐⭐
phi3:3.8b 2.3GB 4GB+ Low resources ⭐⭐⭐

Embedding Models

Model Size Speed Reliability
nomic-embed-text 700MB Fast βœ… Most reliable
all-minilm 80MB Very Fast βœ… Very reliable
mxbai-embed-large 1.5GB Slower ⚠️ May have detection issues

πŸ”§ Troubleshooting

Common Issues

1. Model Not Found After Pulling

Problem: Ran ollama pull <model> but model still shows 404 errors

Solution:

# Restart Ollama service
pkill ollama && ollama serve &

# Verify model appears
ollama list

2. ChromaDB Reset After Model Change

Problem: Changing embedding models wipes the database

Solution:

# Stick with one embedding model, or re-index
./startup.sh
# Wait for documents to re-index automatically

For detailed troubleshooting, see TROUBLESHOOTING_INDEXING.md.


🐳 Docker Deployment

Quick Start

# Fast Mode (uses host Ollama)
docker-compose up -d graphrag

# Full Mode (with Neo4j knowledge graph)
docker-compose --profile kg up -d

# With containerized Ollama (GPU)
docker-compose --profile ollama up -d

Environment Configuration

# Create .env file
cp .env.example .env

# Edit configuration
nano .env

πŸ“š API Reference

Core Endpoints

Endpoint Method Description
/ask POST Ask a question
/upload POST Upload document
/deep-research POST Web research + synthesis
/config-status GET Get configuration

Diagnostic Endpoints

Endpoint Method Description
/chroma-status GET Index statistics
/debug-search POST Test vector search
/graph-stats GET Knowledge graph stats
/data-store-files GET List indexed files

Example: Ask Question

curl -X POST http://localhost:5000/ask \
  -H "Content-Type: application/json" \
  -d '{
    "question": "What are the security best practices?",
    "mode": "hybrid"
  }'

Example: Upload Document

curl -X POST http://localhost:5000/upload \
  -F "file=@document.pdf"

πŸ“ Project Structure

graphrag_project/
β”œβ”€β”€ graphrag_app.py          # Main Flask application
β”œβ”€β”€ config.py                # Configuration with auto-detection
β”œβ”€β”€ search.py                # Hybrid RAG search
β”œβ”€β”€ document_processor.py    # Document parsing & chunking
β”œβ”€β”€ deep_research.py         # Web research functionality
β”œβ”€β”€ guardrails_handler.py    # Security guardrails
β”‚
β”œβ”€β”€ entity_extractor.py      # LLM-based entity extraction
β”œβ”€β”€ entity_resolver.py       # Entity deduplication
β”œβ”€β”€ neo4j_graph.py           # Knowledge graph operations
β”œβ”€β”€ ontology.py              # Entity schemas
β”‚
β”œβ”€β”€ startup.sh               # Linux/macOS startup script
β”œβ”€β”€ startup.bat              # Windows startup script
β”œβ”€β”€ check_models.sh          # Model verification
β”œβ”€β”€ check_indexing.sh        # Indexing diagnostics
β”œβ”€β”€ upgrade_llm.sh           # LLM upgrade helper
β”‚
β”œβ”€β”€ Dockerfile               # Container build
β”œβ”€β”€ docker-compose.yml       # Multi-service orchestration
β”œβ”€β”€ docker-entrypoint.sh     # Container startup
β”‚
β”œβ”€β”€ templates/               # Web UI templates
β”œβ”€β”€ guardrails/              # Guardrails configuration
β”‚
β”œβ”€β”€ requirements.txt         # Python dependencies
β”œβ”€β”€ .env.example             # Environment template
└── README.md                # This file

πŸ”„ Advanced Features

Knowledge Graph Mode

Enable entity extraction and relationship mapping:

# Start with knowledge graph
./startup.sh --full

# Or enable via API
curl -X POST http://localhost:5000/config/enable-kg

Deep Research

Perform web-based research with document synthesis:

curl -X POST http://localhost:5000/deep-research \
  -H "Content-Type: application/json" \
  -d '{
    "topic": "Machine learning best practices",
    "include_web": true,
    "include_docs": true,
    "depth": "standard"
  }'

Depth Levels:

  • quick - ~5 sources, 30 seconds
  • standard - ~15 sources, 1 minute
  • deep - ~25+ sources, 2 minutes

Configurable Search Parameters

curl -X POST http://localhost:5000/config/search-params \
  -H "Content-Type: application/json" \
  -d '{
    "top_k": 8,
    "min_relevance": 0.4,
    "search_mode": "hybrid",
    "context_window": 8000
  }'

πŸ“ Model Variant Auto-Detection

The application automatically detects model variants installed in Ollama:

  • βœ… .env specifies LLM_MODEL=llama3.2
  • βœ… You have llama3.2:3b installed
  • βœ… App auto-detects and uses llama3.2:3b

Console Output:

πŸ€– Initializing LLM (llama3.2)...
ℹ️  Auto-detected model variant: llama3.2:3b (configured: llama3.2)
βœ… LLM ready

No configuration needed - it just works!


🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

πŸ“„ License

MIT License - See LICENSE file for details.


πŸ™ Acknowledgments

Built with:


Built with ❀️ for self-directed learners

About

It has deepresearch with UI also added guardrails

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages