#!/bin/bash # Quick deployment script to fix HF Spaces initialization error # Run this on your LOCAL machine where you can authenticate with HuggingFace set -e echo "🔧 Deploying LLM Initialization Fix to Hugging Face Spaces" echo "===========================================================" echo "" # Check if HF Space is cloned if [ ! -d ~/AI_Personas_HF ]; then echo "📥 Step 1: Cloning your Hugging Face Space..." cd ~ git clone https://huggingface.co/spaces/MatthewStroud/AI_Personas AI_Personas_HF echo "✓ Cloned successfully" else echo "✓ HF Space directory already exists" cd ~/AI_Personas_HF git pull origin main fi echo "" echo "📋 Step 2: Copying updated files..." echo "" # Get the source directory (where this script is located) SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" HF_DIR=~/AI_Personas_HF # Copy main web app with fixes cp -v "$SCRIPT_DIR/web_app.py" "$HF_DIR/" echo " ✓ web_app.py (with diagnostics)" # Copy updated LLM client mkdir -p "$HF_DIR/src/llm" cp -v "$SCRIPT_DIR/src/llm/anthropic_client.py" "$HF_DIR/src/llm/" echo " ✓ src/llm/anthropic_client.py (with validation)" # Copy all src directories cp -r "$SCRIPT_DIR/src/"* "$HF_DIR/src/" echo " ✓ All src/ files" # Copy requirements with updated anthropic version cp -v "$SCRIPT_DIR/requirements.txt" "$HF_DIR/requirements.txt" echo " ✓ requirements.txt (anthropic>=0.34.0)" # Copy pages cp -r "$SCRIPT_DIR/pages/"* "$HF_DIR/pages/" 2>/dev/null || echo " ℹ No pages to copy" # Copy data cp -r "$SCRIPT_DIR/data/"* "$HF_DIR/data/" 2>/dev/null || echo " ℹ No data to copy" # Copy streamlit config mkdir -p "$HF_DIR/.streamlit" cp -r "$SCRIPT_DIR/.streamlit/"* "$HF_DIR/.streamlit/" 2>/dev/null || echo " ℹ No streamlit config to copy" # Copy README for HF cp -v "$SCRIPT_DIR/README_HF.md" "$HF_DIR/README.md" echo " ✓ README.md" echo "" echo "📝 Step 3: Committing changes..." cd "$HF_DIR" git add . git commit -m "Fix LLM initialization with diagnostics and API key validation - Add comprehensive error diagnostics in sidebar - Validate API key format (must start with sk-ant-) - Update anthropic SDK to >=0.34.0 - Add System Diagnostics panel for debugging - Improve error messages and setup instructions" echo "" echo "🚀 Step 4: Pushing to Hugging Face Spaces..." git push echo "" echo "✅ Deployment complete!" echo "" echo "⏱️ Your Space will rebuild in 5-10 minutes." echo "🌐 Check status at: https://huggingface.co/spaces/MatthewStroud/AI_Personas" echo "" echo "After rebuild:" echo " 1. The sidebar should show 'System Diagnostics' section" echo " 2. API Key Status should show '✓ Found'" echo " 3. You should see '✅ Anthropic Claude initialized successfully!'" echo ""