Spaces:
Runtime error
Runtime error
| set -e | |
| echo "Starting TMC Chatbot on Hugging Face Spaces..." | |
| # Disable telemetry | |
| export ANONYMIZED_TELEMETRY=False | |
| export CHROMA_TELEMETRY_ENABLED=false | |
| export CHROMADB_TELEMETRY_DISABLED=true | |
| export POSTHOG_DISABLED=true | |
| # Create necessary directories | |
| mkdir -p /app/data/transformers_cache | |
| mkdir -p /app/data/huggingface_cache | |
| mkdir -p /app/data/vector_db | |
| mkdir -p /app/data/sentence_transformers_cache | |
| # Set database path | |
| export DATABASE_PATH=${DATABASE_PATH:-/app/data/tmc_customer_service.db} | |
| # Initialize database if needed | |
| if [ ! -f "$DATABASE_PATH" ]; then | |
| echo "Database not found. Creating tables and default users..." | |
| python -c " | |
| from scripts.init_database import init_sample_data | |
| init_sample_data() | |
| print('Database initialized with default users.') | |
| " | |
| else | |
| # Check if users exist | |
| USER_COUNT=$(python -c "import sqlite3; conn = sqlite3.connect('$DATABASE_PATH'); cur = conn.cursor(); cur.execute('SELECT COUNT(*) FROM users'); print(cur.fetchone()[0]); conn.close()" 2>/dev/null || echo "0") | |
| if [ "$USER_COUNT" = "0" ]; then | |
| echo "Database exists but has no users. Adding default users..." | |
| python -c " | |
| from scripts.init_database import init_sample_data | |
| init_sample_data() | |
| print('Default users added.') | |
| " | |
| else | |
| echo "Database already initialized with $USER_COUNT user(s)." | |
| fi | |
| fi | |
| echo "Starting Flask application on port 7860..." | |
| exec python app.py |