File size: 4,164 Bytes
518e57c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/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!")