File size: 1,338 Bytes
65be7f3 |
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 |
#!/usr/bin/env python3
"""
KGraph-MCP Platform - HF Spaces Optimized Entry Point
Optimized version for Hugging Face Spaces deployment.
"""
import logging
import sys
from pathlib import Path
# Set up paths
current_dir = Path(__file__).parent
sys.path.insert(0, str(current_dir))
# Configure logging for HF Spaces
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
# Import main app
from app import create_gradio_interface, initialize_agent_system
def main():
"""Main entry point for HF Spaces."""
# Initialize agents
print("π Initializing KGraph-MCP Agent System...")
planner_agent, executor_agent = initialize_agent_system()
if planner_agent is None or executor_agent is None:
print("β Failed to initialize agent system")
sys.exit(1)
print(f"β
Agent system ready with {len(planner_agent.kg.tools)} tools")
# Create and launch interface
print("π¨ Creating Gradio interface...")
interface = create_gradio_interface()
# Launch with HF Spaces optimized settings
interface.launch(
server_name="0.0.0.0",
server_port=7860,
share=False,
debug=False,
show_error=True,
enable_queue=True,
max_threads=10
)
if __name__ == "__main__":
main()
|