AI_Personas / deploy_fix.sh
Claude
Add automated deployment fix script for HF Spaces
d27506a unverified
#!/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 ""