#!/bin/bash
# Setup script for Hybrid RAG Project
# This script automates the installation process
set -e # Exit on error
echo "๐ Hybrid RAG Project Setup"
echo "=========================="
echo ""
# Check Python version
echo "๐ Checking Python version..."
if ! command -v python3 &> /dev/null; then
echo "โ Python 3 is not installed. Please install Python 3.9 or higher."
exit 1
fi
PYTHON_VERSION=$(python3 --version | cut -d' ' -f2 | cut -d'.' -f1,2)
echo "โ
Found Python $PYTHON_VERSION"
# Check if Ollama is installed
echo ""
echo "๐ Checking Ollama installation..."
if ! command -v ollama &> /dev/null; then
echo "โ ๏ธ Ollama is not installed."
echo "๐ Please install Ollama from: https://ollama.ai"
echo " After installation, run this script again."
exit 1
fi
echo "โ
Ollama is installed"
# Check if Ollama is running
echo ""
echo "๐ Checking if Ollama is running..."
if ! curl -s http://localhost:11434/api/tags > /dev/null 2>&1; then
echo "โ ๏ธ Ollama is not running."
echo "๐ Please start Ollama and run this script again."
exit 1
fi
echo "โ
Ollama is running"
# Check for required models
echo ""
echo "๐ Checking Ollama models..."
MODELS=$(curl -s http://localhost:11434/api/tags | python3 -c "import sys, json; data = json.load(sys.stdin); print(' '.join([m['name'] for m in data.get('models', [])]))" 2>/dev/null || echo "")
if [[ ! "$MODELS" =~ "nomic-embed-text" ]]; then
echo "โ ๏ธ Model 'nomic-embed-text' not found."
echo "๐ฅ Pulling nomic-embed-text model..."
ollama pull nomic-embed-text
else
echo "โ
Found nomic-embed-text model"
fi
if [[ ! "$MODELS" =~ "llama3.1" ]]; then
echo "โ ๏ธ Model 'llama3.1' not found."
echo "๐ฅ Pulling llama3.1:latest model..."
ollama pull llama3.1:latest
else
echo "โ
Found llama3.1 model"
fi
# Create virtual environment
echo ""
echo "๐ฆ Creating virtual environment..."
if [ -d ".venv" ]; then
echo "โ ๏ธ Virtual environment already exists. Skipping creation."
else
python3 -m venv .venv
echo "โ
Virtual environment created"
fi
# Activate virtual environment
echo ""
echo "๐ Activating virtual environment..."
source .venv/bin/activate
# Upgrade pip
echo ""
echo "๐ฆ Upgrading pip..."
pip install --upgrade pip -q
# Install dependencies
echo ""
echo "๐ฆ Installing dependencies..."
pip install -r requirements.txt -q
echo "โ
Dependencies installed"
# Create necessary directories
echo ""
echo "๐ Creating necessary directories..."
mkdir -p data
mkdir -p chroma_db
echo "โ
Directories created"
# Test the setup
echo ""
echo "๐งช Testing the setup..."
python3 -c "
import sys
sys.path.insert(0, '.')
from src.hybrid_rag import DocumentLoaderUtility, StructuredQueryEngine, configure_logging
print('โ
All modules import successfully')
" 2>&1 | grep -v "WARNING" | grep -v "init:" | grep -v "level=WARN" || echo "โ
Imports successful"
echo ""
echo "โ
Setup complete!"
echo ""
echo "=========================="
echo "๐ You're ready to use the Hybrid RAG system!"
echo ""
echo "๐ Next steps:"
echo " 1. Add your documents to the 'data/' directory"
echo " 2. Run the demo: python scripts/run_demo.py"
echo " 3. Or start the REST API: python scripts/mcp_server.py"
echo " 4. Or configure Claude Desktop to use the MCP server"
echo ""
echo "๐ Documentation:"
echo " - README.md - Complete guide"
echo " - docs/INSTALLATION.md - Detailed installation instructions"
echo " - docs/STRUCTURED_QUERIES.md - How to query CSV data"
echo " - docs/ASYNC_INGESTION.md - Async ingestion guide"
echo ""
echo "๐ก Quick test: python scripts/run_demo.py"
echo ""