thera-guide-ai / run_api.sh
Said Lfagrouche
Fix NLTK data permission issues by pre-downloading during build
ed78072
raw
history blame contribute delete
951 Bytes
#!/bin/bash
# This script handles startup for the API on Hugging Face Spaces
echo "===== Application Startup at $(date -u '+%Y-%m-%d %H:%M:%S') ====="
# Make sure our custom directories exist
echo "Setting up directories..."
mkdir -p data/users data/sessions data/conversations data/feedback
mkdir -p mental_health_model_artifacts/chroma_db
# Verify NLTK data exists and is accessible
echo "Checking NLTK data..."
if [ -d "/app/nltk_data" ]; then
echo "NLTK data directory exists at /app/nltk_data"
# List contents to verify
ls -la /app/nltk_data
else
echo "WARNING: NLTK data directory not found at /app/nltk_data"
# Create the directory anyway
mkdir -p /app/nltk_data
fi
# Create .env file if it doesn't exist
if [ ! -f .env ]; then
echo "Creating .env file from .env.example..."
cp .env.example .env
fi
# Start the API with uvicorn
echo "Starting API server..."
exec uvicorn app:app --host 0.0.0.0 --port 7860