""" Free AI Setup Helper =================== This script helps you set up completely free AI models for data analysis. """ import os import subprocess import sys def setup_free_huggingface(): """Setup free Hugging Face models""" print("๐Ÿ†“ SETTING UP FREE HUGGING FACE AI") print("=" * 40) print("๐Ÿ“ Steps to get free Hugging Face access:") print("1. Go to: https://huggingface.co/join") print("2. Create a free account") print("3. Go to: https://huggingface.co/settings/tokens") print("4. Create a new token (read access is enough)") print("5. Copy the token") token = input("\n๐Ÿ”‘ Paste your Hugging Face token here (or press Enter to skip): ").strip() if token: # Set environment variable for current session os.environ['HF_TOKEN'] = token print("โœ… Token set for current session!") # Try to test the token try: import requests headers = {"Authorization": f"Bearer {token}"} response = requests.get("https://huggingface.co/api/whoami", headers=headers) if response.status_code == 200: user_info = response.json() print(f"โœ… Token verified! Hello, {user_info.get('name', 'User')}!") return True else: print("โš ๏ธ Token verification failed. Please check your token.") return False except Exception as e: print(f"โš ๏ธ Could not verify token: {e}") return False else: print("โš ๏ธ No token provided. Some models may not work without authentication.") return False def setup_ollama_quick(): """Quick Ollama setup guide""" print("\n๐Ÿ†“ SETTING UP FREE LOCAL OLLAMA AI") print("=" * 40) print("๐Ÿ“ Quick Ollama setup:") print("1. Download from: https://ollama.ai/") print("2. Install the application") print("3. Open terminal and run: ollama pull llama2") print("4. Start server: ollama serve") print("5. Your script will automatically detect it!") choice = input("\nโ“ Open Ollama website now? (y/n): ").strip().lower() if choice == 'y': try: if sys.platform == 'win32': os.startfile("https://ollama.ai/") elif sys.platform == 'darwin': subprocess.run(['open', "https://ollama.ai/"]) else: subprocess.run(['xdg-open', "https://ollama.ai/"]) print("โœ… Ollama website opened!") except Exception as e: print(f"โš ๏ธ Could not open website: {e}") print("Please manually go to: https://ollama.ai/") def test_current_setup(): """Test what AI models are currently available""" print("\n๐Ÿงช TESTING CURRENT AI SETUP") print("=" * 30) try: from upload import EnhancedDataExplorer explorer = EnhancedDataExplorer() if explorer.agent is not None: print("โœ… AI model is configured and ready!") print("๐Ÿš€ You can now use AI analysis in your data explorer!") return True else: print("โŒ No AI model configured yet.") return False except Exception as e: print(f"โŒ Error testing setup: {e}") return False def main(): print("๐Ÿค– FREE AI MODELS SETUP") print("=" * 25) print("Choose your free AI option:") print("1. ๐Ÿ†“ Hugging Face (cloud-based, free account needed)") print("2. ๐Ÿ†“ Ollama (local, completely free, more private)") print("3. ๐Ÿงช Test current setup") print("4. โŒ Skip AI setup") choice = input("\nEnter your choice (1-4): ").strip() if choice == "1": setup_free_huggingface() elif choice == "2": setup_ollama_quick() elif choice == "3": test_current_setup() elif choice == "4": print("โœ… You can still use all non-AI features!") else: print("โŒ Invalid choice. Please run the script again.") print("\n๐Ÿš€ Next steps:") print("1. Run: python upload.py") print("2. Choose option 2 (Enhanced mode)") print("3. Try AI analysis with menu option 4") if __name__ == "__main__": main()