Spaces:
Sleeping
Sleeping
| # Quick Git Deployment to Hugging Face Spaces | |
| # Run this script to deploy your Memory Chat application | |
| echo "π Memory Chat - Quick Git Deployment to Hugging Face Spaces" | |
| echo "==============================================================" | |
| # Check if git is installed | |
| if ! command -v git &> /dev/null; then | |
| echo "β Git is not installed. Please install Git first." | |
| exit 1 | |
| fi | |
| # Check if required files exist | |
| required_files=("app.py" "memory_manager.py" "chat_interface.py" "config.py" "requirements.txt" "README.md") | |
| for file in "${required_files[@]}"; do | |
| if [ ! -f "$file" ]; then | |
| echo "β Missing file: $file" | |
| echo "Please ensure all required files are in the current directory." | |
| exit 1 | |
| fi | |
| done | |
| echo "β All required files found" | |
| # Get user input | |
| read -p "Enter your Hugging Face username: " username | |
| read -p "Enter your Space name (e.g., memory-chat): " space_name | |
| # Check if this is a new Space or existing | |
| echo "" | |
| echo "Is this a new Space? (y/n)" | |
| read -p "Choice [y/n]: " new_space | |
| if [ "$new_space" = "y" ] || [ "$new_space" = "Y" ]; then | |
| echo "" | |
| echo "π Creating new Space..." | |
| echo "Please create your Space at: https://huggingface.co/spaces/new" | |
| echo "" | |
| echo "Space details:" | |
| echo "- Name: $space_name" | |
| echo "- Type: Gradio" | |
| echo "- Visibility: Public" | |
| echo "" | |
| echo "After creating the Space, press Enter to continue..." | |
| read | |
| fi | |
| # Setup Git | |
| echo "" | |
| echo "π§ Setting up Git repository..." | |
| # Initialize if not already | |
| if [ ! -d ".git" ]; then | |
| git init | |
| fi | |
| # Get Hugging Face token | |
| echo "" | |
| echo "π Getting Hugging Face credentials..." | |
| echo "Please get your Hugging Face API token:" | |
| echo "1. Go to: https://huggingface.co/settings/tokens" | |
| echo "2. Click 'New token'" | |
| echo "3. Set name: 'spaces-deploy'" | |
| echo "4. Set role: 'write'" | |
| echo "5. Copy the token" | |
| echo "" | |
| read -s -p "Enter your Hugging Face API token: " hf_token | |
| echo "" | |
| # Setup remote URL | |
| remote_url="https://$username:$hf_token@huggingface.co/spaces/$username/$space_name" | |
| # Remove existing remote if exists | |
| git remote remove origin 2>/dev/null || true | |
| # Add remote | |
| git remote add origin "$remote_url" | |
| echo "β Git remote configured" | |
| # Add files and commit | |
| echo "" | |
| echo "π Preparing files..." | |
| git add . | |
| git commit -m "Initial commit: Memory Chat application" | |
| echo "β Files committed" | |
| # Push to Hugging Face | |
| echo "" | |
| echo "π Deploying to Hugging Face Spaces..." | |
| if git push -u origin main; then | |
| echo "" | |
| echo "π Successfully deployed!" | |
| echo "π Your Space: https://huggingface.co/spaces/$username/$space_name" | |
| echo "" | |
| echo "π‘ Check the 'Logs' tab in your Space for build progress." | |
| echo "π‘ Your Space should be live in 3-5 minutes." | |
| else | |
| echo "β Deployment failed. Trying force push..." | |
| if git push -u origin main --force; then | |
| echo "" | |
| echo "π Successfully deployed (force push)!" | |
| echo "π Your Space: https://huggingface.co/spaces/$username/$space_name" | |
| else | |
| echo "β Failed to deploy. Please check your credentials and try again." | |
| exit 1 | |
| fi | |
| fi |