#!/usr/bin/env python3 """ AI Agent Brainstorming Studio Setup Script ========================================== Quick setup script for installing all dependencies and verifying the installation. """ import subprocess import sys import os from pathlib import Path def run_command(command, description): """Run a command and handle errors gracefully""" print(f"šŸ”§ {description}...") try: result = subprocess.run(command, shell=True, capture_output=True, text=True) if result.returncode == 0: print(f"āœ… {description} completed successfully") return True else: print(f"āŒ Error in {description}: {result.stderr}") return False except Exception as e: print(f"āŒ Error running {description}: {e}") return False def check_python_version(): """Check if Python version is compatible""" version = sys.version_info if version.major >= 3 and version.minor >= 10: print(f"āœ… Python {version.major}.{version.minor}.{version.micro} is compatible") return True else: print(f"āŒ Python {version.major}.{version.minor}.{version.micro} is not compatible. Need Python 3.10+") return False def setup_environment(): """Set up the AI Agent Brainstorming Studio environment""" print("🧠 AI Agent Brainstorming Studio Setup") print("=" * 40) # Check Python version if not check_python_version(): print("\nšŸ”§ Please upgrade Python to version 3.10 or higher") print(" Download from: https://www.python.org/downloads/") return False # Upgrade pip if not run_command("python -m pip install --upgrade pip", "Upgrading pip"): return False # Install requirements requirements_file = "requirements.txt" if Path(requirements_file).exists(): if not run_command(f"pip install -r {requirements_file}", "Installing dependencies"): return False else: print(f"āŒ Requirements file '{requirements_file}' not found") return False # Download NLTK data print("šŸ”§ Downloading NLTK data...") try: import nltk nltk.download('punkt', quiet=True) nltk.download('stopwords', quiet=True) nltk.download('vader_lexicon', quiet=True) print("āœ… NLTK data downloaded successfully") except Exception as e: print(f"āš ļø NLTK data download failed: {e}") print(" This is optional - the system will still work") # Test imports print("šŸ”§ Testing key imports...") try: import gradio import openai import mcp import plotly import sklearn import nltk import textblob print("āœ… All key imports successful") except ImportError as e: print(f"āŒ Import test failed: {e}") return False # Check for .env file if not Path(".env").exists(): print("\nšŸ’” Optional: Create .env file for OpenAI API key") print(" echo 'OPENAI_API_KEY=sk-your-key-here' > .env") print(" (Or enter it in the web interface)") print("\nšŸŽ‰ Setup Complete!") print("šŸ“‹ Next Steps:") print(" 1. (Optional) Add OpenAI API key to .env file or web interface") print(" 2. Run: python app.py") print(" 3. Open: http://localhost:7864") print(" 4. Start brainstorming with AI agents!") return True if __name__ == "__main__": success = setup_environment() if not success: print("\nāŒ Setup failed. Please check the errors above.") sys.exit(1) else: print("\nāœ… Ready to launch your AI Agent Brainstorming Studio!") # Ask if user wants to launch immediately try: launch = input("\nšŸš€ Launch the brainstorming studio now? (y/N): ").lower().strip() if launch in ['y', 'yes']: print("šŸš€ Launching AI Agent Brainstorming Studio...") os.system("python app.py") except KeyboardInterrupt: print("\nšŸ‘‹ Setup complete. Run 'python app.py' when ready!")