""" League of Legends Multi-Agent Coach - Hugging Face Spaces Version This is a wrapper for deploying to Hugging Face Spaces. """ import os import sys import gradio as gr # Check for required API keys missing_keys = [] if not os.getenv("OPENAI_API_KEY"): missing_keys.append("OPENAI_API_KEY") if not os.getenv("RIOT_API_KEY"): missing_keys.append("RIOT_API_KEY") if not os.getenv("TAVILY_API_KEY"): missing_keys.append("TAVILY_API_KEY") # If API keys are missing, create a simple error interface if missing_keys: print(f"⚠️ ERROR: Missing required API keys: {', '.join(missing_keys)}") def show_error(message, history): return f""" ❌ **Configuration Error** Missing required API keys: **{', '.join(missing_keys)}** Please add these secrets in your Hugging Face Space settings: 1. Go to Settings → Repository secrets 2. Add the following secrets: - OPENAI_API_KEY - RIOT_API_KEY - TAVILY_API_KEY The Space will automatically restart once you add the secrets. """ demo = gr.ChatInterface( show_error, title="⚔️ LoL Multi-Agent Coach - Configuration Required", description="Please configure API keys to use this Space." ) else: # Import the main application only if API keys are present print("✅ All API keys found, initializing system...") from multi_agent_coach import create_multi_agent_coach, create_gradio_interface # Create the coach system print("🚀 Initializing Multi-Agent LoL Coach System...") try: coach = create_multi_agent_coach() print("✅ Coach system initialized successfully!") # Create the Gradio interface print("🎨 Creating Gradio interface...") demo = create_gradio_interface(coach) print("✅ Gradio interface created!") except Exception as e: print(f"❌ Error initializing coach system: {e}") import traceback traceback.print_exc() # Create error interface def show_init_error(message, history): return f"❌ System initialization error: {str(e)}\n\nPlease check the logs for details." demo = gr.ChatInterface( show_init_error, title="⚔️ LoL Multi-Agent Coach - Initialization Error" ) # Launch with Hugging Face-compatible settings if __name__ == "__main__": print("🚀 Launching Gradio interface...") demo.launch( server_name="0.0.0.0", # Required for Hugging Face Spaces server_port=7860, share=False # Not needed on HF Spaces ) print("✅ Gradio launched successfully!")