Spaces:
Sleeping
Sleeping
File size: 2,752 Bytes
aaa201d 4b714f4 aaa201d 4b714f4 aaa201d 4b714f4 aaa201d 4b714f4 aaa201d 4b714f4 aaa201d 4b714f4 aaa201d 4b714f4 aaa201d 4b714f4 | 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 | """
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!")
|