Chris4K's picture
Upload 90 files
87532e2 verified
#!/usr/bin/env python3
"""
MMORPG Application - HuggingFace Space Version
Simplified version for HuggingFace deployment with fallback imports
"""
import gradio as gr
import asyncio
import os
import sys
from typing import Optional
# Add current directory to Python path for HF Spaces
current_dir = os.path.dirname(os.path.abspath(__file__))
if current_dir not in sys.path:
sys.path.insert(0, current_dir)
def create_fallback_interface():
"""Create a fallback interface if main components fail to load."""
with gr.Blocks(title="MMORPG - Limited Mode") as interface:
gr.Markdown("""
# 🎮 MMORPG Application - Limited Mode
**Note:** Running in limited mode due to import issues.
This is a simplified version that focuses on core functionality.
""")
with gr.Tab("🔍 SearchHF Oracle"):
gr.Markdown("""
## 🔍 SearchHF Oracle
Advanced Hugging Face search using MCP integration.
""")
query_input = gr.Textbox(
label="Search Query",
placeholder="e.g., 'text-generation models'"
)
search_btn = gr.Button("🔍 Search", variant="primary")
search_output = gr.Textbox(
label="Search Results",
lines=10,
interactive=False
)
def simple_search(query):
if not query.strip():
return "❌ Please enter a search query"
return f"🔍 **Search Results for:** {query}\n\n⚠️ Full MCP integration not available in this environment.\n\nTo use full functionality, please run locally."
search_btn.click(
simple_search,
inputs=[query_input],
outputs=[search_output]
)
with gr.Tab("ℹ️ About"):
gr.Markdown("""
# About MMORPG Application
This is an AI-powered MMORPG with:
- **MCP Integration** - Model Context Protocol for AI agents
- **Dynamic NPCs** - AI-powered non-player characters
- **Plugin System** - Extensible addon architecture
- **Real-time Chat** - Multi-channel communication
- **Trading System** - Virtual economy
## 🚀 Full Version
For the complete experience with all features, please run the application locally.
## 🔧 Technical Details
- **Framework:** Gradio + Python
- **AI Integration:** MCP (Model Context Protocol)
- **Architecture:** Clean architecture with dependency injection
""")
return interface
def main():
"""Main application entry point for HuggingFace Spaces."""
try:
# Try to import the full application
from src.core.game_engine import GameEngine
from src.facades.game_facade import GameFacade
from src.ui.huggingface_ui import HuggingFaceUI
from src.ui.improved_interface_manager import ImprovedInterfaceManager
from src.mcp.mcp_tools import GradioMCPTools
# Initialize full application
game_engine = GameEngine()
game_facade = GameFacade()
ui = HuggingFaceUI(game_facade)
interface_manager = ImprovedInterfaceManager(game_facade, ui)
# Create the complete interface
interface = interface_manager.create_interface()
print("✅ Full MMORPG application loaded successfully!")
except Exception as e:
print(f"⚠️ Failed to load full application: {e}")
print("🔄 Falling back to limited mode...")
# Create fallback interface
interface = create_fallback_interface()
# Launch the interface
interface.launch(
server_name="0.0.0.0",
server_port=7860, # Standard HF port
share=False,
show_error=True,
quiet=False
)
if __name__ == "__main__":
main()