File size: 2,723 Bytes
150be64
 
80fda88
 
150be64
 
80fda88
 
150be64
80fda88
 
 
150be64
80fda88
 
 
 
 
 
 
5668917
80fda88
 
 
 
 
 
 
 
 
 
 
 
 
 
5668917
150be64
80fda88
 
 
 
 
 
5668917
80fda88
 
 
 
 
 
 
150be64
80fda88
 
 
 
5668917
80fda88
 
 
5668917
80fda88
 
 
 
 
 
 
 
 
 
150be64
80fda88
 
 
 
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
#!/usr/bin/env python3
"""

Huggingface Spaces entry point for MoneyPrinterTurbo

Stage 2: Streamlit Integration

"""
import os
import sys
import subprocess

# Add the root directory to Python path
root_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, root_dir)

def setup_environment():
    """Setup environment for Huggingface Spaces"""
    print("πŸ“ Creating storage directories...")
    # Create necessary directories
    os.makedirs(os.path.join(root_dir, "storage", "tasks"), exist_ok=True)
    os.makedirs(os.path.join(root_dir, "storage", "cache_videos"), exist_ok=True)
    os.makedirs(os.path.join(root_dir, "storage", "temp"), exist_ok=True)

def load_env_variables():
    """Load environment variables into config"""
    print("πŸ”‘ Loading environment variables...")
    try:
        # Try to load environment variables into config
        env_vars = {
            'MONEYPRINTER_API_KEY': 'api_key',
            'DEEPSEEK_API_KEY': 'deepseek_api_key', 
            'MOONSHOT_API_KEY': 'moonshot_api_key',
            'OPENAI_API_KEY': 'openai_api_key',
            'PEXELS_API_KEY': 'pexels_api_keys',
            'PIXABAY_API_KEY': 'pixabay_api_keys',
            'AZURE_SPEECH_KEY': 'azure_speech_key',
            'AZURE_SPEECH_REGION': 'azure_speech_region'
        }
        
        loaded_count = 0
        for env_key, config_key in env_vars.items():
            value = os.getenv(env_key)
            if value:
                print(f"βœ… Loaded {env_key}")
                loaded_count += 1
        
        if loaded_count > 0:
            print(f"🎯 Successfully loaded {loaded_count} environment variables")
        else:
            print("πŸ’‘ No environment variables found - will use WebUI configuration")
            
    except Exception as e:
        print(f"⚠️ Warning loading environment variables: {e}")

def start_streamlit():
    """Start Streamlit app"""
    print("πŸš€ Starting MoneyPrinterTurbo Streamlit WebUI...")
    print("🎯 Stage 2: Basic Streamlit Integration")
    
    # Setup environment first
    setup_environment()
    load_env_variables()
    
    # Use SimpleMain.py for basic functionality
    streamlit_app = os.path.join(root_dir, "webui", "SimpleMain.py")
    
    # Start Streamlit using exec to replace current process
    os.execvp(sys.executable, [
        sys.executable, "-m", "streamlit", "run", 
        streamlit_app,
        "--server.port=7860",
        "--server.address=0.0.0.0",
        "--browser.gatherUsageStats=false"
    ])

if __name__ == "__main__":
    print("🎬 MoneyPrinterTurbo - Stage 2: Streamlit Integration")
    start_streamlit()