Spaces:
Sleeping
Sleeping
| #!/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!") |