Chris4K commited on
Commit
87532e2
·
verified ·
1 Parent(s): 4ac9b82

Upload 90 files

Browse files
hf_app.py ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ MMORPG Application - HuggingFace Space Version
4
+ Simplified version for HuggingFace deployment with fallback imports
5
+ """
6
+
7
+ import gradio as gr
8
+ import asyncio
9
+ import os
10
+ import sys
11
+ from typing import Optional
12
+
13
+ # Add current directory to Python path for HF Spaces
14
+ current_dir = os.path.dirname(os.path.abspath(__file__))
15
+ if current_dir not in sys.path:
16
+ sys.path.insert(0, current_dir)
17
+
18
+ def create_fallback_interface():
19
+ """Create a fallback interface if main components fail to load."""
20
+ with gr.Blocks(title="MMORPG - Limited Mode") as interface:
21
+ gr.Markdown("""
22
+ # 🎮 MMORPG Application - Limited Mode
23
+
24
+ **Note:** Running in limited mode due to import issues.
25
+
26
+ This is a simplified version that focuses on core functionality.
27
+ """)
28
+
29
+ with gr.Tab("🔍 SearchHF Oracle"):
30
+ gr.Markdown("""
31
+ ## 🔍 SearchHF Oracle
32
+
33
+ Advanced Hugging Face search using MCP integration.
34
+ """)
35
+
36
+ query_input = gr.Textbox(
37
+ label="Search Query",
38
+ placeholder="e.g., 'text-generation models'"
39
+ )
40
+ search_btn = gr.Button("🔍 Search", variant="primary")
41
+ search_output = gr.Textbox(
42
+ label="Search Results",
43
+ lines=10,
44
+ interactive=False
45
+ )
46
+
47
+ def simple_search(query):
48
+ if not query.strip():
49
+ return "❌ Please enter a search query"
50
+ return f"🔍 **Search Results for:** {query}\n\n⚠️ Full MCP integration not available in this environment.\n\nTo use full functionality, please run locally."
51
+
52
+ search_btn.click(
53
+ simple_search,
54
+ inputs=[query_input],
55
+ outputs=[search_output]
56
+ )
57
+
58
+ with gr.Tab("ℹ️ About"):
59
+ gr.Markdown("""
60
+ # About MMORPG Application
61
+
62
+ This is an AI-powered MMORPG with:
63
+ - **MCP Integration** - Model Context Protocol for AI agents
64
+ - **Dynamic NPCs** - AI-powered non-player characters
65
+ - **Plugin System** - Extensible addon architecture
66
+ - **Real-time Chat** - Multi-channel communication
67
+ - **Trading System** - Virtual economy
68
+
69
+ ## 🚀 Full Version
70
+
71
+ For the complete experience with all features, please run the application locally.
72
+
73
+ ## 🔧 Technical Details
74
+
75
+ - **Framework:** Gradio + Python
76
+ - **AI Integration:** MCP (Model Context Protocol)
77
+ - **Architecture:** Clean architecture with dependency injection
78
+ """)
79
+
80
+ return interface
81
+
82
+ def main():
83
+ """Main application entry point for HuggingFace Spaces."""
84
+ try:
85
+ # Try to import the full application
86
+ from src.core.game_engine import GameEngine
87
+ from src.facades.game_facade import GameFacade
88
+ from src.ui.huggingface_ui import HuggingFaceUI
89
+ from src.ui.improved_interface_manager import ImprovedInterfaceManager
90
+ from src.mcp.mcp_tools import GradioMCPTools
91
+
92
+ # Initialize full application
93
+ game_engine = GameEngine()
94
+ game_facade = GameFacade()
95
+ ui = HuggingFaceUI(game_facade)
96
+ interface_manager = ImprovedInterfaceManager(game_facade, ui)
97
+
98
+ # Create the complete interface
99
+ interface = interface_manager.create_interface()
100
+
101
+ print("✅ Full MMORPG application loaded successfully!")
102
+
103
+ except Exception as e:
104
+ print(f"⚠️ Failed to load full application: {e}")
105
+ print("🔄 Falling back to limited mode...")
106
+
107
+ # Create fallback interface
108
+ interface = create_fallback_interface()
109
+
110
+ # Launch the interface
111
+ interface.launch(
112
+ server_name="0.0.0.0",
113
+ server_port=7860, # Standard HF port
114
+ share=False,
115
+ show_error=True,
116
+ quiet=False
117
+ )
118
+
119
+ if __name__ == "__main__":
120
+ main()
plugins/__pycache__/sample_plugin.cpython-313.pyc CHANGED
Binary files a/plugins/__pycache__/sample_plugin.cpython-313.pyc and b/plugins/__pycache__/sample_plugin.cpython-313.pyc differ
 
src/addons/__pycache__/searchhf_addon.cpython-313.pyc CHANGED
Binary files a/src/addons/__pycache__/searchhf_addon.cpython-313.pyc and b/src/addons/__pycache__/searchhf_addon.cpython-313.pyc differ
 
src/addons/searchhf_addon.py CHANGED
@@ -11,9 +11,43 @@ from mcp import ClientSession
11
  from mcp.client.sse import sse_client
12
  from contextlib import AsyncExitStack
13
 
14
- from ..interfaces.npc_addon import NPCAddon
15
- # Import MCP management functions
16
- from .generic_mcp_server_addon import register_mcp_results_as_npcs, list_active_mcp_npcs, remove_mcp_npc, clear_all_mcp_npcs
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  class SearchHFOracleAddon(NPCAddon):
19
  """SearchHF Oracle Addon for searching Hugging Face using MCP and spawning NPCs."""
 
11
  from mcp.client.sse import sse_client
12
  from contextlib import AsyncExitStack
13
 
14
+ try:
15
+ # Try relative imports first (for local development)
16
+ from ..interfaces.npc_addon import NPCAddon
17
+ from .generic_mcp_server_addon import register_mcp_results_as_npcs, list_active_mcp_npcs, remove_mcp_npc, clear_all_mcp_npcs
18
+ except ImportError:
19
+ # Fall back to absolute imports (for HuggingFace Spaces)
20
+ try:
21
+ from src.interfaces.npc_addon import NPCAddon
22
+ from src.addons.generic_mcp_server_addon import register_mcp_results_as_npcs, list_active_mcp_npcs, remove_mcp_npc, clear_all_mcp_npcs
23
+ except ImportError:
24
+ # Final fallback - define minimal stubs to prevent import errors
25
+ print("[WARNING] Could not import NPC addon dependencies - running in limited mode")
26
+
27
+ class NPCAddon:
28
+ def __init__(self):
29
+ pass
30
+
31
+ @property
32
+ def addon_id(self):
33
+ return "searchhf_oracle"
34
+
35
+ @property
36
+ def addon_name(self):
37
+ return "SearchHF Oracle"
38
+
39
+ def register_mcp_results_as_npcs(results):
40
+ print(f"[WARNING] NPC registration not available - would register {len(results)} NPCs")
41
+ return []
42
+
43
+ def list_active_mcp_npcs():
44
+ return {}
45
+
46
+ def remove_mcp_npc(npc_id):
47
+ return False
48
+
49
+ def clear_all_mcp_npcs():
50
+ return 0
51
 
52
  class SearchHFOracleAddon(NPCAddon):
53
  """SearchHF Oracle Addon for searching Hugging Face using MCP and spawning NPCs."""