| #!/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() | |