|
|
|
|
|
"""
|
|
|
Huggingface Spaces entry point for MoneyPrinterTurbo
|
|
|
Stage 2: Streamlit Integration
|
|
|
"""
|
|
|
import os
|
|
|
import sys
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
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...")
|
|
|
|
|
|
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:
|
|
|
|
|
|
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()
|
|
|
load_env_variables()
|
|
|
|
|
|
|
|
|
streamlit_app = os.path.join(root_dir, "webui", "SimpleMain.py")
|
|
|
|
|
|
|
|
|
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() |