Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 3,541 Bytes
61d29fc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | #!/bin/bash
set -e
echo "π¦· Oral Health Policy Pulse - Installation Script"
echo "=================================================="
echo ""
# Install system-level OCR dependency when possible
echo "Checking for Tesseract OCR..."
if command -v tesseract &> /dev/null; then
echo "β Tesseract already installed: $(tesseract --version | head -n 1)"
else
echo "Tesseract not found. Attempting automatic install..."
if command -v apt-get &> /dev/null; then
if [ "$(id -u)" -eq 0 ]; then
apt-get update && apt-get install -y tesseract-ocr
elif command -v sudo &> /dev/null; then
sudo apt-get update && sudo apt-get install -y tesseract-ocr
else
echo "β Could not auto-install Tesseract (no root/sudo)."
echo " Install manually: apt-get install -y tesseract-ocr"
fi
elif command -v brew &> /dev/null; then
brew install tesseract || true
else
echo "β Unsupported package manager for automatic Tesseract install."
echo " Install manually, then re-run setup."
fi
if command -v tesseract &> /dev/null; then
echo "β Tesseract installed: $(tesseract --version | head -n 1)"
else
echo "β Tesseract is still missing. OCR fallback will remain disabled."
fi
fi
# Check Python version
echo "Checking Python version..."
if ! command -v python3 &> /dev/null; then
echo "β Error: Python 3 is not installed"
exit 1
fi
PYTHON_VERSION=$(python3 --version | cut -d' ' -f2 | cut -d'.' -f1,2)
echo "β Found Python $PYTHON_VERSION"
# Create virtual environment
echo ""
echo "Creating virtual environment..."
if [ -d "venv" ]; then
echo "β Virtual environment already exists. Removing old one..."
rm -rf venv
fi
python3 -m venv venv
echo "β Virtual environment created"
# Activate virtual environment
echo ""
echo "Activating virtual environment..."
source venv/bin/activate
echo "β Virtual environment activated"
# Upgrade pip
echo ""
echo "Upgrading pip..."
python -m pip install --upgrade pip
echo "β pip upgraded"
# Install dependencies
echo ""
echo "Installing dependencies (this may take a few minutes)..."
# Use CPU-only requirements if available, otherwise use full requirements
if [ -f "requirements-cpu.txt" ]; then
echo "Using CPU-only requirements (no GPU needed)..."
pip install -r requirements-cpu.txt
else
pip install -r requirements.txt
fi
echo "β Dependencies installed"
# Create .env file if it doesn't exist
echo ""
if [ ! -f ".env" ]; then
echo "Creating .env file from template..."
cp .env.example .env
echo "β .env file created"
echo ""
echo "β IMPORTANT: Please edit .env and add your API keys:"
echo " - OPENAI_API_KEY"
echo " - DATABRICKS_HOST"
echo " - DATABRICKS_TOKEN"
else
echo "β .env file already exists"
fi
# Create logs directory
echo ""
echo "Creating logs directory..."
mkdir -p logs
echo "β logs directory created"
# Installation complete
echo ""
echo "=================================================="
echo "β
Installation Complete!"
echo "=================================================="
echo ""
echo "To activate the virtual environment, run:"
echo " source venv/bin/activate"
echo ""
echo "Then you can use the CLI:"
echo " python main.py --help"
echo " python main.py serve"
echo ""
echo "Or run the example workflow:"
echo " python examples/example_workflow.py"
echo ""
echo "Don't forget to configure your .env file with API keys!"
echo ""
|