| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """ | |
| Code Review Agent - Hugging Face Spaces Entry Point | |
| This module serves as the entry point for the Code Review Agent application | |
| when deployed to Hugging Face Spaces. | |
| """ | |
| import os | |
| import sys | |
| import logging | |
| from dotenv import load_dotenv | |
| # Add the project root to the Python path | |
| sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) | |
| # Import application modules | |
| from src.ui.gradio_app import create_gradio_app | |
| from src.core.agent_manager import AgentManager | |
| # Configure logging | |
| logging.basicConfig( | |
| level=logging.INFO, | |
| format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', | |
| handlers=[ | |
| logging.StreamHandler() | |
| ] | |
| ) | |
| logger = logging.getLogger(__name__) | |
| # Load environment variables | |
| load_dotenv() | |
| # Create logs directory if it doesn't exist | |
| logs_dir = os.path.join(os.path.dirname(__file__), 'logs') | |
| os.makedirs(logs_dir, exist_ok=True) | |
| # Initialize the agent manager | |
| agent_manager = AgentManager() | |
| # Create the Gradio app | |
| app = create_gradio_app(agent_manager) | |
| # Launch the app with specific server configuration for Hugging Face Spaces | |
| app.launch(server_name="0.0.0.0", server_port=7860, share=False) |