#!/usr/bin/env python3 """ Setup script for Hugging Face Spaces deployment """ import os import sys import subprocess from pathlib import Path def check_requirements(): """Check if all requirements are met""" print("šŸ” Checking requirements...") # Check git try: subprocess.run(["git", "--version"], capture_output=True, check=True) print("āœ… Git available") except (subprocess.CalledProcessError, FileNotFoundError): print("āŒ Git not found. Please install git.") return False # Check if we're in the right directory if not Path("scripts").exists(): print("āŒ Scripts directory not found. Please run from project root.") return False print("āœ… All requirements met") return True def create_space_repository(): """Guide user to create HF Space repository""" print("\n🌐 Creating Hugging Face Space Repository") print("=" * 50) print("1. Go to https://huggingface.co/spaces") print("2. Click 'Create new Space'") print("3. Fill in the details:") print(" - Name: textilindo-ai-assistant") print(" - SDK: Docker") print(" - Hardware: GPU Basic") print(" - Visibility: Public or Private") print("4. Click 'Create Space'") print("5. Copy the repository URL (e.g., https://huggingface.co/spaces/your-username/textilindo-ai-assistant)") return input("\nšŸ“‹ Enter your Hugging Face Space URL: ").strip() def setup_git_remote(space_url): """Setup git remote for the space""" print(f"\nšŸ”— Setting up git remote...") try: # Remove existing remote if any subprocess.run(["git", "remote", "remove", "origin"], capture_output=True) # Add new remote subprocess.run(["git", "remote", "add", "origin", space_url], check=True) print(f"āœ… Remote added: {space_url}") return True except subprocess.CalledProcessError as e: print(f"āŒ Failed to add remote: {e}") return False def main(): """Main setup function""" print("šŸš€ Textilindo AI Assistant - Hugging Face Spaces Setup") print("=" * 60) # Check requirements if not check_requirements(): sys.exit(1) # Guide user to create space space_url = create_space_repository() if not space_url: print("āŒ No space URL provided. Exiting.") sys.exit(1) # Setup git remote if not setup_git_remote(space_url): sys.exit(1) print("\nāœ… Setup complete!") print("\nšŸ“‹ Next steps:") print("1. Run: python push_to_hf_space.py") print("2. Check your Hugging Face Space") print("3. Monitor the build logs") print("4. Test the application when ready") if __name__ == "__main__": main()